Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

build/parseBuildInstallClean.c

Go to the documentation of this file.
00001 
00005 #include "system.h"
00006 
00007 #include "rpmbuild.h"
00008 #include "debug.h"
00009 
00010 /*@access StringBuf @*/
00011 
00012 /*@-boundswrite@*/
00013 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
00014 {
00015     int nextPart, rc;
00016     StringBuf *sbp = NULL;
00017     const char *name = NULL;
00018 
00019     /*@-branchstate@*/
00020     if (parsePart == PART_BUILD) {
00021         sbp = &spec->build;
00022         name = "%build";
00023     } else if (parsePart == PART_INSTALL) {
00024         sbp = &spec->install;
00025         name = "%install";
00026     } else if (parsePart == PART_CHECK) {
00027         sbp = &spec->check;
00028         name = "%check";
00029     } else if (parsePart == PART_CLEAN) {
00030         sbp = &spec->clean;
00031         name = "%clean";
00032     }
00033     /*@=branchstate@*/
00034     
00035     if (*sbp != NULL) {
00036         rpmError(RPMERR_BADSPEC, _("line %d: second %s\n"),
00037                 spec->lineNum, name);
00038         return RPMERR_BADSPEC;
00039     }
00040     
00041     *sbp = newStringBuf();
00042 
00043     /* Make sure the buildroot is removed where needed. */
00044     if (parsePart == PART_INSTALL) {
00045         const char * s = rpmExpand("%{!?__spec_install_pre:%{?buildroot:rm -rf '%{buildroot}'\n}}\n", NULL);
00046         if (s && *s)
00047             appendStringBuf(*sbp, s);
00048         s = _free(s);
00049     } else if (parsePart == PART_CLEAN) {
00050         const char * s = rpmExpand("%{?__spec_clean_body}%{!?__spec_clean_body:%{?buildroot:rm -rf '%{buildroot}'\n}}\n", NULL);
00051         if (s && *s)
00052             appendStringBuf(*sbp, s);
00053         s = _free(s);
00054     }
00055 
00056     /* There are no options to %build, %install, %check, or %clean */
00057     if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00058         return PART_NONE;
00059     if (rc)
00060         return rc;
00061     
00062     while (! (nextPart = isPart(spec->line))) {
00063         if (sbp)
00064             appendStringBuf(*sbp, spec->line);
00065         if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00066             return PART_NONE;
00067         if (rc)
00068             return rc;
00069     }
00070 
00071     return nextPart;
00072 }
00073 /*@=boundswrite@*/

Generated on Tue Dec 27 22:20:13 2016 for rpm by  doxygen 1.4.4