From 44184bacebad7f7e3d8afc6e31015683ff78e5f5 Mon Sep 17 00:00:00 2001 From: jbj Date: Wed, 7 Oct 1998 17:06:10 +0000 Subject: [PATCH] arch/os (and platform) should be case insensitive everywhere forever. CVS patchset: 2417 CVS date: 1998/10/07 17:06:10 --- CHANGES | 1 + build/pack.c | 19 ++++++++++--------- build/parsePreamble.c | 7 ++++++- build/parseSpec.c | 39 ++++++++++++++++++++++++++------------- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index 41fd269..b8fa7c1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ 2.5.5 -> 2.90 + - arch/os (and platform) should be case insensitive everywhere forever. - attempt to deal rationally with os as "Linux" or "linux". - add generalized expression handler (Tom Dyas) - use /usr/lib/rpm/mkinstalldirs if mkdir -p fails. diff --git a/build/pack.c b/build/pack.c index 887875a..6d68cc4 100644 --- a/build/pack.c +++ b/build/pack.c @@ -166,7 +166,8 @@ int packageBinaries(Spec spec) int writeRPM(Header header, char *fileName, int type, CSA_t *csa, char *passPhrase, char **cookie) { - int fd, ifd, rc, count, arch, os, sigtype; + int fd, ifd, rc, count, sigtype; + int archnum, osnum; char *sigtarget, *name, *version, *release; char buf[BUFSIZ]; Header sig; @@ -235,22 +236,22 @@ int writeRPM(Header header, char *fileName, int type, sprintf(buf, "%s-%s-%s", name, version, release); if (csa->cpioFdIn < 0) { - rpmGetArchInfo(NULL, &arch); - rpmGetOsInfo(NULL, &os); + rpmGetArchInfo(NULL, &archnum); + rpmGetOsInfo(NULL, &osnum); } else if (csa->lead != NULL) { /* XXX FIXME: exorcize lead/arch/os */ - arch = csa->lead->archnum; - os = csa->lead->osnum; + archnum = csa->lead->archnum; + osnum = csa->lead->osnum; } else { - arch = -1; - os = -1; + archnum = -1; + osnum = -1; } memset(&lead, 0, sizeof(lead)); lead.major = RPM_MAJOR_NUMBER; lead.minor = 0; lead.type = type; - lead.archnum = arch; - lead.osnum = os; + lead.archnum = archnum; + lead.osnum = osnum; lead.signature_type = RPMSIG_HEADERSIG; /* New-style signature */ strncpy(lead.name, buf, sizeof(lead.name)); if (writeLead(fd, &lead)) { diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 446399d..a1f25fe 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -124,9 +124,14 @@ static int isMemberInEntry(Header header, char *name, int tag) char **names; int count; + /* + * XXX The strcasecmp below is necessary so the old (rpm < 2.90) style + * XXX os-from-uname (e.g. "Linux") is compatible with the new + * XXX os-from-platform (e.g "linux" from "sparc-*-linux"). + */ if (headerGetEntry(header, tag, NULL, (void **)&names, &count)) { while (count--) { - if (!strcmp(names[count], name)) { + if (!strcasecmp(names[count], name)) { FREE(names); return 1; } diff --git a/build/parseSpec.c b/build/parseSpec.c index f66ab0b..47a8af0 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -72,10 +72,15 @@ static int matchTok(char *token, char *line) { char buf[BUFSIZ], *tok; + /* + * XXX The strcasecmp below is necessary so the old (rpm < 2.90) style + * XXX os-from-uname (e.g. "Linux") is compatible with the new + * XXX os-from-platform (e.g "linux" from "sparc-*-linux"). + */ strcpy(buf, line); strtok(buf, " \n\t"); while ((tok = strtok(NULL, " \n\t"))) { - if (! strcmp(tok, token)) { + if (! strcasecmp(tok, token)) { return 1; } } @@ -183,6 +188,7 @@ retry: rpmGetArchInfo(&arch, NULL); rpmGetOsInfo(&os, NULL); + s = spec->line; SKIPSPACE(s); match = -1; @@ -277,7 +283,7 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot, { int parsePart = PART_PREAMBLE; int initialPackage = 1; - char *name, *arch, *os; + char *name; char *saveArch; Package pkg; int x, index; @@ -314,13 +320,6 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot, spec->timeCheck = 0; } - /* Add some standard macros */ - rpmGetArchInfo(&arch, NULL); - rpmGetOsInfo(&os, NULL); -#ifdef DEAD - setStandardMacros(spec, arch, os); -#endif - /* All the parse*() functions expect to have a line pre-read */ /* in the spec's line buffer. Except for parsePreamble(), */ /* which handles the initial entry into a spec file. */ @@ -405,8 +404,22 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot, } /* Check for description in each package and add arch and os */ - pkg = spec->packages; - while (pkg) { + { char *arch, *os, *myos = NULL; + + rpmGetArchInfo(&arch, NULL); + rpmGetOsInfo(&os, NULL); + /* + * XXX Capitalizing the 'L' is needed to insure that old + * XXX os-from-uname (e.g. "Linux") is compatible with the new + * XXX os-from-platform (e.g "linux" from "sparc-*-linux"). + * XXX A copy of this string is embedded in headers. + */ + if (!strcmp(os, "linux")) { + os = myos = strdup(os); + *os = 'L'; + } + + for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { headerGetEntry(pkg->header, RPMTAG_NAME, NULL, (void **) &name, NULL); if (!headerIsEntry(pkg->header, RPMTAG_DESCRIPTION)) { rpmError(RPMERR_BADSPEC, _("Package has no %%description: %s"), name); @@ -416,8 +429,8 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot, headerAddEntry(pkg->header, RPMTAG_OS, RPM_STRING_TYPE, os, 1); headerAddEntry(pkg->header, RPMTAG_ARCH, RPM_STRING_TYPE, arch, 1); - - pkg = pkg->next; + } + FREE(myos); } closeSpec(spec); -- 2.7.4