00001
00005 #include "system.h"
00006
00007 #include "rpmbuild.h"
00008 #include "debug.h"
00009
00010
00011
00012
00013 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
00014 {
00015 int nextPart, rc;
00016 StringBuf *sbp = NULL;
00017 const char *name = NULL;
00018
00019
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
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
00044 if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00045 return PART_NONE;
00046 if (rc)
00047 return rc;
00048
00049 while (! (nextPart = isPart(spec->line))) {
00050 appendStringBuf(*sbp, spec->line);
00051 if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
00052 return PART_NONE;
00053 if (rc)
00054 return rc;
00055 }
00056
00057 return nextPart;
00058 }
00059