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