• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

build/parseBuildInstallClean.c

Go to the documentation of this file.
00001 
00005 #include "system.h"
00006 
00007 #include <rpmio.h>
00008 #include <rpmiotypes.h>
00009 #include <rpmlog.h>
00010 #define _RPMTAG_INTERNAL
00011 #include "rpmbuild.h"
00012 #include "debug.h"
00013 
00014 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
00015 {
00016     rpmParseState nextPart;
00017     rpmiob *iobp = NULL;
00018     const char *name = NULL;
00019     rpmRC rc;
00020 
00021     if (parsePart == PART_BUILD) {
00022         iobp = &spec->build;
00023         name = "build";
00024     } else if (parsePart == PART_INSTALL) {
00025         iobp = &spec->install;
00026         name = "install";
00027     } else if (parsePart == PART_CHECK) {
00028         iobp = &spec->check;
00029         name = "check";
00030     } else if (parsePart == PART_CLEAN) {
00031         iobp = &spec->clean;
00032         name = "clean";
00033     } else if (parsePart == PART_ARBITRARY) {
00034 assert(spec->nfoo > 0);
00035         iobp = &spec->foo[spec->nfoo-1].iob;
00036         name = spec->foo[spec->nfoo-1].str;
00037     }
00038     
00039     if (*iobp != NULL) {
00040         rpmlog(RPMLOG_ERR, _("line %d: second %%%s section\n"),
00041                 spec->lineNum, name);
00042         return RPMRC_FAIL;
00043     }
00044     
00045     *iobp = rpmiobNew(0);
00046 
00047     /* Make sure the buildroot is removed where needed. */
00048     if (parsePart == PART_INSTALL) {
00049         const char * s = rpmExpand("%{!?__spec_install_pre:%{?buildroot:%{__rm} -rf '%{buildroot}'\n%{__mkdir_p} '%{buildroot}'\n}}\n", NULL);
00050         if (s && *s)
00051             *iobp = rpmiobAppend(*iobp, s, 0);
00052         s = _free(s);
00053     } else if (parsePart == PART_CLEAN) {
00054         const char * s = rpmExpand("%{?__spec_clean_body}%{!?__spec_clean_body:%{?buildroot:rm -rf '%{buildroot}'\n}}\n", NULL);
00055         if (s && *s)
00056             *iobp = rpmiobAppend(*iobp, s, 0);
00057         s = _free(s);
00058 #if !defined(RPM_VENDOR_OPENPKG) /* still-support-section-clean */
00059         /* OpenPKG still wishes to use "%clean" script/section */
00060         iobp = NULL;    /* XXX skip %clean from spec file. */
00061 #endif
00062     }
00063 
00064     /* There are no options to %build, %install, %check, or %clean */
00065     if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00066         return PART_NONE;
00067     if (rc != RPMRC_OK)
00068         return rc;
00069     
00070     while ((nextPart = isPart(spec)) == PART_NONE) {
00071         if (iobp)
00072             *iobp = rpmiobAppend(*iobp, spec->line, 0);
00073         if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00074             return PART_NONE;
00075         if (rc)
00076             return rc;
00077     }
00078 
00079     return nextPart;
00080 }

Generated on Fri Dec 3 2010 20:53:15 for rpm by  doxygen 1.7.2