1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#include "rpmbuild.h"
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
#include "popt/popt.h"
|
|
|
|
|
1998-03-05 00:51:06 +08:00
|
|
|
/* These have to be global to make up for stupid compilers */
|
|
|
|
static int leaveDirs, skipDefaultAction;
|
|
|
|
static int createDir, quietly;
|
|
|
|
static char * dirName;
|
|
|
|
static struct poptOption optionsTable[] = {
|
|
|
|
{ NULL, 'a', POPT_ARG_STRING, NULL, 'a' },
|
|
|
|
{ NULL, 'b', POPT_ARG_STRING, NULL, 'b' },
|
|
|
|
{ NULL, 'c', 0, &createDir, 0 },
|
|
|
|
{ NULL, 'D', 0, &leaveDirs, 0 },
|
|
|
|
{ NULL, 'n', POPT_ARG_STRING, &dirName, 0 },
|
|
|
|
{ NULL, 'T', 0, &skipDefaultAction, 0 },
|
|
|
|
{ NULL, 'q', 0, &quietly, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
#ifdef DYING
|
1998-01-13 05:31:29 +08:00
|
|
|
static int doSetupMacro(Spec spec, char *line);
|
|
|
|
static int doPatchMacro(Spec spec, char *line);
|
|
|
|
static char *doPatch(Spec spec, int c, int strip, char *db,
|
|
|
|
int reverse, int removeEmpties);
|
|
|
|
static int checkOwners(char *file);
|
|
|
|
static char *doUntar(Spec spec, int c, int quietly);
|
1998-08-01 04:11:49 +08:00
|
|
|
#endif
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
static int checkOwners(char *file)
|
1998-01-13 05:31:29 +08:00
|
|
|
{
|
1998-08-01 04:11:49 +08:00
|
|
|
struct stat sb;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
if (lstat(file, &sb)) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad source: %s: %s"), file, strerror(errno));
|
1998-08-01 04:11:49 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
if (!getUname(sb.st_uid) || !getGname(sb.st_gid)) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad owner/group: %s"), file);
|
1998-01-13 05:31:29 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
static char *doPatch(Spec spec, int c, int strip, char *db,
|
|
|
|
int reverse, int removeEmpties)
|
|
|
|
{
|
|
|
|
static char buf[BUFSIZ];
|
|
|
|
char file[BUFSIZ];
|
|
|
|
char args[BUFSIZ];
|
|
|
|
struct Source *sp;
|
|
|
|
int compressed;
|
|
|
|
|
1998-09-06 04:02:08 +08:00
|
|
|
for (sp = spec->sources; sp != NULL; sp = sp->next) {
|
1998-08-01 04:11:49 +08:00
|
|
|
if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
|
1998-01-13 05:31:29 +08:00
|
|
|
break;
|
|
|
|
}
|
1998-08-01 04:11:49 +08:00
|
|
|
}
|
1998-09-06 04:02:08 +08:00
|
|
|
if (sp == NULL) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("No patch number %d"), c);
|
1998-08-01 04:11:49 +08:00
|
|
|
return NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-09-06 04:02:08 +08:00
|
|
|
strcpy(file, "%{_sourcedir}/");
|
|
|
|
expandMacros(spec, spec->macros, file, sizeof(file));
|
|
|
|
strcat(file, sp->source);
|
1998-08-01 04:11:49 +08:00
|
|
|
|
|
|
|
args[0] = '\0';
|
|
|
|
if (db) {
|
|
|
|
#if HAVE_OLDPATCH_21 == 0
|
|
|
|
strcat(args, "-b ");
|
|
|
|
#endif
|
|
|
|
strcat(args, "--suffix ");
|
|
|
|
strcat(args, db);
|
|
|
|
}
|
|
|
|
if (reverse) {
|
|
|
|
strcat(args, " -R");
|
|
|
|
}
|
|
|
|
if (removeEmpties) {
|
|
|
|
strcat(args, " -E");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isCompressed(file, &compressed)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (checkOwners(file)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (compressed) {
|
|
|
|
sprintf(buf,
|
|
|
|
"echo \"Patch #%d:\"\n"
|
|
|
|
"%s -dc %s | patch -p%d %s -s\n"
|
|
|
|
"STATUS=$?\n"
|
|
|
|
"if [ $STATUS -ne 0 ]; then\n"
|
|
|
|
" exit $STATUS\n"
|
|
|
|
"fi",
|
|
|
|
c,
|
|
|
|
(compressed == COMPRESSED_BZIP2) ?
|
|
|
|
rpmGetVar(RPMVAR_BZIP2BIN) : rpmGetVar(RPMVAR_GZIPBIN),
|
|
|
|
file, strip, args);
|
|
|
|
} else {
|
|
|
|
sprintf(buf,
|
|
|
|
"echo \"Patch #%d:\"\n"
|
|
|
|
"patch -p%d %s -s < %s", c, strip, args, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *doUntar(Spec spec, int c, int quietly)
|
|
|
|
{
|
|
|
|
static char buf[BUFSIZ];
|
|
|
|
char file[BUFSIZ];
|
1998-10-08 19:55:37 +08:00
|
|
|
char *taropts;
|
1998-08-01 04:11:49 +08:00
|
|
|
struct Source *sp;
|
|
|
|
int compressed;
|
|
|
|
|
1998-09-06 04:02:08 +08:00
|
|
|
for (sp = spec->sources; sp != NULL; sp = sp->next) {
|
1998-08-01 04:11:49 +08:00
|
|
|
if ((sp->flags & RPMBUILD_ISSOURCE) && (sp->num == c)) {
|
|
|
|
break;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-08-01 04:11:49 +08:00
|
|
|
}
|
1998-09-06 04:02:08 +08:00
|
|
|
if (sp == NULL) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("No source number %d"), c);
|
1998-08-01 04:11:49 +08:00
|
|
|
return NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-04-10 04:20:17 +08:00
|
|
|
|
1998-09-06 04:02:08 +08:00
|
|
|
strcpy(file, "%{_sourcedir}/");
|
|
|
|
expandMacros(spec, spec->macros, file, sizeof(file));
|
|
|
|
strcat(file, sp->source);
|
|
|
|
|
1998-10-08 19:55:37 +08:00
|
|
|
taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
if (isCompressed(file, &compressed)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (checkOwners(file)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (compressed) {
|
|
|
|
sprintf(buf,
|
|
|
|
"%s -dc %s | tar %s -\n"
|
|
|
|
"STATUS=$?\n"
|
|
|
|
"if [ $STATUS -ne 0 ]; then\n"
|
|
|
|
" exit $STATUS\n"
|
|
|
|
"fi",
|
|
|
|
(compressed == COMPRESSED_BZIP2) ?
|
|
|
|
rpmGetVar(RPMVAR_BZIP2BIN) : rpmGetVar(RPMVAR_GZIPBIN),
|
|
|
|
file, taropts);
|
|
|
|
} else {
|
|
|
|
sprintf(buf, "tar %s %s", taropts, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int doSetupMacro(Spec spec, char *line)
|
|
|
|
{
|
|
|
|
char *version, *name;
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
StringBuf before;
|
|
|
|
StringBuf after;
|
|
|
|
poptContext optCon;
|
|
|
|
int argc;
|
|
|
|
char ** argv;
|
|
|
|
int arg;
|
|
|
|
char * optArg;
|
|
|
|
char * chptr;
|
|
|
|
int rc;
|
|
|
|
int num;
|
1998-03-05 00:51:06 +08:00
|
|
|
|
|
|
|
leaveDirs = skipDefaultAction = 0;
|
|
|
|
createDir = quietly = 0;
|
|
|
|
dirName = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
if ((rc = poptParseArgvString(line, &argc, &argv))) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Error parsing %%setup: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
poptStrerror(rc));
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
before = newStringBuf();
|
|
|
|
after = newStringBuf();
|
|
|
|
|
|
|
|
optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
|
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
|
|
|
optArg = poptGetOptArg(optCon);
|
|
|
|
|
|
|
|
/* We only parse -a and -b here */
|
|
|
|
|
|
|
|
if (parseNum(optArg, &num)) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad arg to %%setup %c: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, num, optArg);
|
|
|
|
free(argv);
|
|
|
|
freeStringBuf(before);
|
|
|
|
freeStringBuf(after);
|
|
|
|
poptFreeContext(optCon);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
chptr = doUntar(spec, num, quietly);
|
|
|
|
if (!chptr) {
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg == 'a')
|
|
|
|
appendLineStringBuf(after, chptr);
|
|
|
|
else
|
|
|
|
appendLineStringBuf(before, chptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg < -1) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad %%setup option %s: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
|
|
poptStrerror(arg));
|
|
|
|
free(argv);
|
|
|
|
freeStringBuf(before);
|
|
|
|
freeStringBuf(after);
|
|
|
|
poptFreeContext(optCon);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dirName) {
|
|
|
|
spec->buildSubdir = strdup(dirName);
|
|
|
|
} else {
|
|
|
|
headerGetEntry(spec->packages->header, RPMTAG_VERSION, NULL,
|
|
|
|
(void *) &version, NULL);
|
|
|
|
headerGetEntry(spec->packages->header, RPMTAG_NAME, NULL,
|
|
|
|
(void *) &name, NULL);
|
|
|
|
sprintf(buf, "%s-%s", name, version);
|
|
|
|
spec->buildSubdir = strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(argv);
|
|
|
|
poptFreeContext(optCon);
|
|
|
|
|
|
|
|
/* cd to the build dir */
|
1998-09-06 04:02:08 +08:00
|
|
|
strcpy(buf, "cd %{_builddir}");
|
|
|
|
expandMacros(spec, spec->macros, buf, sizeof(buf));
|
1998-01-13 05:31:29 +08:00
|
|
|
appendLineStringBuf(spec->prep, buf);
|
|
|
|
|
|
|
|
/* delete any old sources */
|
|
|
|
if (!leaveDirs) {
|
|
|
|
sprintf(buf, "rm -rf %s", spec->buildSubdir);
|
|
|
|
appendLineStringBuf(spec->prep, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if necessary, create and cd into the proper dir */
|
|
|
|
if (createDir) {
|
1998-03-05 00:51:06 +08:00
|
|
|
sprintf(buf, MKDIR_P " %s\ncd %s",
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->buildSubdir, spec->buildSubdir);
|
|
|
|
appendLineStringBuf(spec->prep, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do the default action */
|
1998-09-06 04:02:08 +08:00
|
|
|
if (!createDir && !skipDefaultAction) {
|
1998-01-13 05:31:29 +08:00
|
|
|
chptr = doUntar(spec, 0, quietly);
|
|
|
|
if (!chptr) {
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
appendLineStringBuf(spec->prep, chptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
appendStringBuf(spec->prep, getStringBuf(before));
|
|
|
|
freeStringBuf(before);
|
|
|
|
|
|
|
|
if (!createDir) {
|
|
|
|
sprintf(buf, "cd %s", spec->buildSubdir);
|
|
|
|
appendLineStringBuf(spec->prep, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (createDir && !skipDefaultAction) {
|
|
|
|
chptr = doUntar(spec, 0, quietly);
|
|
|
|
if (!chptr) {
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
appendLineStringBuf(spec->prep, chptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
appendStringBuf(spec->prep, getStringBuf(after));
|
|
|
|
freeStringBuf(after);
|
|
|
|
|
|
|
|
/* clean up permissions etc */
|
|
|
|
if (!geteuid()) {
|
|
|
|
appendLineStringBuf(spec->prep, "chown -R root .");
|
1998-03-05 00:51:06 +08:00
|
|
|
appendLineStringBuf(spec->prep, "chgrp -R " ROOT_GROUP " .");
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rpmGetVar(RPMVAR_FIXPERMS)) {
|
|
|
|
appendStringBuf(spec->prep, "chmod -R ");
|
|
|
|
appendStringBuf(spec->prep, rpmGetVar(RPMVAR_FIXPERMS));
|
|
|
|
appendLineStringBuf(spec->prep, " .");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int doPatchMacro(Spec spec, char *line)
|
|
|
|
{
|
|
|
|
char *opt_b;
|
|
|
|
int opt_P, opt_p, opt_R, opt_E;
|
|
|
|
char *s;
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
int patch_nums[1024]; /* XXX - we can only handle 1024 patches! */
|
|
|
|
int patch_index, x;
|
|
|
|
|
|
|
|
opt_P = opt_p = opt_R = opt_E = 0;
|
|
|
|
opt_b = NULL;
|
|
|
|
patch_index = 0;
|
|
|
|
|
|
|
|
if (! strchr(" \t\n", line[6])) {
|
|
|
|
/* %patchN */
|
|
|
|
sprintf(buf, "%%patch -P %s", line + 6);
|
|
|
|
} else {
|
|
|
|
strcpy(buf, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
strtok(buf, " \t\n"); /* remove %patch */
|
|
|
|
while ((s = strtok(NULL, " \t\n"))) {
|
|
|
|
if (!strcmp(s, "-P")) {
|
|
|
|
opt_P = 1;
|
|
|
|
} else if (!strcmp(s, "-R")) {
|
|
|
|
opt_R = 1;
|
|
|
|
} else if (!strcmp(s, "-E")) {
|
|
|
|
opt_E = 1;
|
|
|
|
} else if (!strcmp(s, "-b")) {
|
|
|
|
/* orig suffix */
|
|
|
|
opt_b = strtok(NULL, " \t\n");
|
|
|
|
if (! opt_b) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Need arg to %%patch -b: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
} else if (!strcmp(s, "-z")) {
|
|
|
|
/* orig suffix */
|
|
|
|
opt_b = strtok(NULL, " \t\n");
|
|
|
|
if (! opt_b) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Need arg to %%patch -z: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
} else if (!strncmp(s, "-p", 2)) {
|
|
|
|
/* unfortunately, we must support -pX */
|
|
|
|
if (! strchr(" \t\n", s[2])) {
|
|
|
|
s = s + 2;
|
|
|
|
} else {
|
|
|
|
s = strtok(NULL, " \t\n");
|
|
|
|
if (! s) {
|
|
|
|
rpmError(RPMERR_BADSPEC,
|
1998-09-28 06:03:52 +08:00
|
|
|
_("line %d: Need arg to %%patch -p: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (parseNum(s, &opt_p)) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad arg to %%patch -p: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Must be a patch num */
|
|
|
|
if (patch_index == 1024) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Too many patches!"));
|
1998-01-13 05:31:29 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
if (parseNum(s, &(patch_nums[patch_index]))) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad arg to %%patch: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
patch_index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All args processed */
|
|
|
|
|
|
|
|
if (! opt_P) {
|
|
|
|
s = doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E);
|
|
|
|
if (! s) {
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
appendLineStringBuf(spec->prep, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
while (x < patch_index) {
|
|
|
|
s = doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E);
|
|
|
|
if (! s) {
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
appendLineStringBuf(spec->prep, s);
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
int parsePrep(Spec spec)
|
1998-01-13 05:31:29 +08:00
|
|
|
{
|
1998-08-01 04:11:49 +08:00
|
|
|
int nextPart, res, rc;
|
|
|
|
StringBuf buf;
|
|
|
|
char **lines, **saveLines;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
if (spec->prep) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: second %%prep"), spec->lineNum);
|
1998-08-01 04:11:49 +08:00
|
|
|
return RPMERR_BADSPEC;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
spec->prep = newStringBuf();
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
/* There are no options to %prep */
|
|
|
|
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
|
|
|
|
return PART_NONE;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-08-01 04:11:49 +08:00
|
|
|
if (rc) {
|
|
|
|
return rc;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-08-01 04:11:49 +08:00
|
|
|
|
|
|
|
buf = newStringBuf();
|
|
|
|
|
|
|
|
while (! (nextPart = isPart(spec->line))) {
|
|
|
|
/* Need to expand the macros inline. That way we */
|
|
|
|
/* can give good line number information on error. */
|
|
|
|
appendStringBuf(buf, spec->line);
|
|
|
|
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
|
|
|
|
nextPart = PART_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
lines = splitString(getStringBuf(buf), strlen(getStringBuf(buf)), '\n');
|
|
|
|
saveLines = lines;
|
|
|
|
while (*lines) {
|
|
|
|
res = 0;
|
|
|
|
if (! strncmp(*lines, "%setup", 6)) {
|
|
|
|
res = doSetupMacro(spec, *lines);
|
|
|
|
} else if (! strncmp(*lines, "%patch", 6)) {
|
|
|
|
res = doPatchMacro(spec, *lines);
|
|
|
|
} else {
|
|
|
|
appendLineStringBuf(spec->prep, *lines);
|
|
|
|
}
|
|
|
|
if (res) {
|
|
|
|
freeSplitString(saveLines);
|
|
|
|
freeStringBuf(buf);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
lines++;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
freeSplitString(saveLines);
|
|
|
|
freeStringBuf(buf);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
return nextPart;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|