From 4f3c571a16fc2b6bf6a2e46d587b90039d4d99ba Mon Sep 17 00:00:00 2001 From: marc Date: Tue, 3 Feb 1998 15:11:23 +0000 Subject: [PATCH] Added sanity check on Prefixes: Added some support for bzip2. Still needs configure and lib-rpmrc.in stuff. CVS patchset: 1983 CVS date: 1998/02/03 15:11:23 --- CHANGES | 2 ++ build/parsePreamble.c | 15 ++++++++++++++- build/parsePrep.c | 24 ++++++++++++++++++------ lib/rpmlib.h | 3 ++- lib/rpmrc.c | 1 + 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 7ae46e9..831b4d2 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,8 @@ (use --relocate =, i.e. --relocate /usr=/foo) - added --badreloc flag to force RPM to relocate files which packages haven't advertised as relocateable + - fix return code on failed uncompresses in %prep + - preliminary handling of bzip2 compressed files 2.4.99 -> 2.4.100: - fixed handling of --rebuild and --recompile diff --git a/build/parsePreamble.c b/build/parsePreamble.c index e7b15f1..58e065f 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -294,8 +294,9 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro, { char *field = spec->line; char *end; + char **array; int multiToken = 0; - int num, rc; + int num, rc, len; /* Find the start of the "field" and strip trailing space */ while ((*field) && (*field != ':')) { @@ -368,6 +369,18 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro, break; case RPMTAG_PREFIXES: addOrAppendListEntry(pkg->header, tag, field); + headerGetEntry(pkg->header, tag, NULL, (void **)&array, &num); + while (num--) { + len = strlen(array[num]); + if (array[num][len - 1] == '/') { + rpmError(RPMERR_BADSPEC, + "line %d: Prefixes must not end with \"/\": %s", + spec->lineNum, spec->line); + FREE(array); + return RPMERR_BADSPEC; + } + } + FREE(array); break; case RPMTAG_DOCDIR: SINGLE_TOKEN_ONLY; diff --git a/build/parsePrep.c b/build/parsePrep.c index df22013..6935b52 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -23,6 +23,10 @@ static int isCompressed(char *file, int *compressed); static int checkOwners(char *file); static char *doUntar(Spec spec, int c, int quietly); +#define COMPRESSED_NOT 0 +#define COMPRESSED_OTHER 1 +#define COMPRESSED_BZIP2 2 + int parsePrep(Spec spec) { int nextPart, res; @@ -263,7 +267,9 @@ static char *doUntar(Spec spec, int c, int quietly) "if [ $STATUS -ne 0 ]; then\n" " exit $STATUS\n" "fi", - rpmGetVar(RPMVAR_GZIPBIN), file, taropts); + (compressed == COMPRESSED_BZIP2) ? + rpmGetVar(RPMVAR_GZIPBIN) : rpmGetVar(RPMVAR_BZIP2BIN), + file, taropts); } else { sprintf(buf, "tar %s %s", taropts, file); } @@ -422,10 +428,14 @@ static char *doPatch(Spec spec, int c, int strip, char *db, sprintf(buf, "echo \"Patch #%d:\"\n" "%s -dc %s | patch -p%d %s -s\n" - "if [ $? -ne 0 ]; then\n" - " exit $?\n" + "STATUS=$?\n" + "if [ $STATUS -ne 0 ]; then\n" + " exit $STATUS\n" "fi", - c, rpmGetVar(RPMVAR_GZIPBIN), file, strip, args); + c, + (compressed == COMPRESSED_BZIP2) ? + rpmGetVar(RPMVAR_GZIPBIN) : rpmGetVar(RPMVAR_BZIP2BIN), + file, strip, args); } else { sprintf(buf, "echo \"Patch #%d:\"\n" @@ -456,7 +466,7 @@ static int isCompressed(char *file, int *compressed) int fd; unsigned char magic[4]; - *compressed = 0; + *compressed = COMPRESSED_NOT; if (!(fd = open(file, O_RDONLY))) { return 1; @@ -474,7 +484,9 @@ static int isCompressed(char *file, int *compressed) ((magic[0] == 0120) && (magic[1] == 0113) && (magic[2] == 0003) && (magic[3] == 0004)) /* pkzip */ ) { - *compressed = 1; + *compressed = COMPRESSED_OTHER; + } else if ((magic[0] == 'B') && (magic[1] == 'Z')) { + *compressed = COMPRESSED_BZIP2; } return 0; diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 9153cd7..286cf92 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -220,8 +220,9 @@ extern const struct headerSprintfExtension rpmHeaderFormats[]; #define RPMVAR_PROVIDES 38 #define RPMVAR_BUILDSHELL 39 #define RPMVAR_INSTCHANGELOG 40 +#define RPMVAR_BZIP2BIN 41 -#define RPMVAR_NUM 41 /* number of RPMVAR entries */ +#define RPMVAR_NUM 42 /* number of RPMVAR entries */ char * rpmGetVar(int var); int rpmGetBooleanVar(int var); diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 5191c5a..eec0b7c 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -102,6 +102,7 @@ static struct rpmOption optionTable[] = { { "builddir", RPMVAR_BUILDDIR, 0, 0 }, { "buildroot", RPMVAR_BUILDROOT, 0, 0 }, { "buildshell", RPMVAR_BUILDSHELL, 0, 0 }, + { "bzip2bin", RPMVAR_BZIP2BIN, 0, 1 }, { "dbpath", RPMVAR_DBPATH, 0, 1 }, { "defaultdocdir", RPMVAR_DEFAULTDOCDIR, 0, 0 }, { "distribution", RPMVAR_DISTRIBUTION, 0, 0 }, -- 2.7.4