int parsePrep(rpmSpec spec) { int nextPart, res, rc; StringBuf sb; char **lines; ARGV_t saveLines = NULL; if (spec->prep != NULL) { rpmlog(RPMLOG_ERR, _("line %d: second %%prep\n"), spec->lineNum); return PART_ERROR; } spec->prep = newStringBuf(); /* There are no options to %prep */ if ((rc = readLine(spec, STRIP_NOTHING)) > 0) { return PART_NONE; } else if (rc < 0) { return PART_ERROR; } sb = newStringBuf(); while (! (nextPart = isPart(spec->line))) { /* Need to expand the macros inline. That way we */ /* can give good line number information on error. */ appendStringBuf(sb, spec->line); if ((rc = readLine(spec, STRIP_NOTHING)) > 0) { nextPart = PART_NONE; break; } else if (rc < 0) { goto exit; } } saveLines = argvSplitString(getStringBuf(sb), "\n", ARGV_NONE); for (lines = saveLines; *lines; lines++) { res = 0; if (rstreqn(*lines, "%setup", sizeof("%setup")-1)) { res = doSetupMacro(spec, *lines); } else if (rstreqn(*lines, "%patch", sizeof("%patch")-1)) { res = doPatchMacro(spec, *lines); } else { appendLineStringBuf(spec->prep, *lines); } if (res && !spec->force) { /* fixup from RPMRC_FAIL do*Macro() codes for now */ nextPart = PART_ERROR; goto exit; } } res = nextPart; exit: argvFree(saveLines); sb = freeStringBuf(sb); return nextPart; }
int parsePrep(Spec spec, int verify) { rpmParseState nextPart; int res, rc; rpmiob iob; ARGV_t saveLines = NULL; ARGV_t lines; const char * cp; int xx; if (spec->prep != NULL) { rpmlog(RPMLOG_ERR, _("line %d: second %%prep\n"), spec->lineNum); return RPMRC_FAIL; } spec->prep = rpmiobNew(0); /* There are no options to %prep */ if ((rc = readLine(spec, STRIP_NOTHING)) > 0) return PART_NONE; if (rc) return rc; /* Check to make sure that all sources/patches are present. */ if (verify) { rc = prepFetch(spec); if (rc) return RPMRC_FAIL; } iob = rpmiobNew(0); while ((nextPart = isPart(spec)) == PART_NONE) { /* Need to expand the macros inline. That way we */ /* can give good line number information on error. */ iob = rpmiobAppend(iob, spec->line, 0); if ((rc = readLine(spec, STRIP_NOTHING)) > 0) { nextPart = PART_NONE; break; } if (rc) return rc; } xx = argvSplit(&saveLines, rpmiobStr(iob), "\n"); /*@-usereleased@*/ for (lines = saveLines; *lines; lines++) { res = 0; for (cp = *lines; *cp == ' ' || *cp == '\t'; cp++) {}; if (!strncmp(cp, "%setup", sizeof("%setup")-1)) { res = doSetupMacro(spec, cp); #ifndef DYING } else if (! strncmp(cp, "%patch", sizeof("%patch")-1)) { res = doPatchMacro(spec, cp); #endif } else { spec->prep = rpmiobAppend(spec->prep, *lines, 1); } if (res && !spec->force) { saveLines = argvFree(saveLines); iob = rpmiobFree(iob); return res; } } /*@=usereleased@*/ saveLines = argvFree(saveLines); iob = rpmiobFree(iob); return nextPart; }