00001
00005 #include "system.h"
00006
00007 #include "rpmbuild.h"
00008 #include "debug.h"
00009
00010
00011
00012 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
00013 {
00014 int nextPart, rc;
00015 StringBuf *sbp = NULL;
00016 const char *name = NULL;
00017
00018
00019 if (parsePart == PART_BUILD) {
00020 sbp = &(spec->build);
00021 name = "%build";
00022 } else if (parsePart == PART_INSTALL) {
00023 sbp = &(spec->install);
00024 name = "%install";
00025 } else if (parsePart == PART_CLEAN) {
00026 sbp = &(spec->clean);
00027 name = "%clean";
00028 }
00029
00030
00031 if (*sbp != NULL) {
00032 rpmError(RPMERR_BADSPEC, _("line %d: second %s\n"),
00033 spec->lineNum, name);
00034 return RPMERR_BADSPEC;
00035 }
00036
00037 *sbp = newStringBuf();
00038
00039
00040 if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00041 return PART_NONE;
00042 if (rc)
00043 return rc;
00044
00045 while (! (nextPart = isPart(spec->line))) {
00046 appendStringBuf(*sbp, spec->line);
00047 if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00048 return PART_NONE;
00049 if (rc)
00050 return rc;
00051 }
00052
00053 return nextPart;
00054 }