From a162f5ddbd8aed0a8cbae61bc4b408152c010b6a Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 25 May 1999 20:24:46 +0000 Subject: [PATCH] permit multiple "Provides: " lines in rpmrc (#2999). CVS patchset: 3077 CVS date: 1999/05/25 20:24:46 --- CHANGES | 1 + lib/rpmrc.c | 165 +++++++++++++++++++++++++++++++++--------------------------- po/rpm.pot | 20 ++++---- 3 files changed, 101 insertions(+), 85 deletions(-) diff --git a/CHANGES b/CHANGES index c631a42..58bcc6d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ 3.0.1 -> 3.0.2 - eliminate armv4 entries from rpmrc (Andrew E. Mileski). + - permit multiple "Provides: " lines in rpmrc (#2999). 3.0 -> 3.0.1 - fix: %verifyscript resurrected (Shing-Gene Yung). diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 8ccf789..ac2f36b 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -112,7 +112,7 @@ static int addCanon(struct canonEntry **table, int *tableLen, char *line, static int addDefault(struct defaultEntry **table, int *tableLen, char *line, const char *fn, int lineNum); static void freeRpmVar(struct rpmvarValue * orig); -static void rpmSetVarArch(int var, char * val, char * arch); +static void rpmSetVarArch(int var, const char * val, const char * arch); static struct canonEntry *lookupInCanonTable(char *name, struct canonEntry *table, int tableLen); @@ -595,13 +595,11 @@ int rpmReadRC(const char * rcfiles) return rc; } -static int doReadRC(FD_t fd, const char * filename) { - char buf[BUFSIZ]; - char * start, * chptr, * next, * rest; +static int doReadRC(FD_t fd, const char * filename) +{ + char *s, *se, *next; int linenum = 0; struct rpmOption searchOption, * option; - int i; - int gotit; int rc; { struct stat sb; @@ -619,137 +617,154 @@ static int doReadRC(FD_t fd, const char * filename) { while (*next) { linenum++; - chptr = start = next; - while (*chptr != '\n') chptr++; - - *chptr = '\0'; - next = chptr + 1; + se = s = next; + while (*se && *se != '\n') se++; + if (*se) *se++ = '\0'; + next = se; - while (isspace(*start)) start++; + while (*s && isspace(*s)) s++; /* we used to allow comments to begin anywhere, but not anymore */ - if (*start == '#' || !*start) continue; + if (*s == '#' || *s == '\0') continue; - chptr = start; - while (!isspace(*chptr) && *chptr != ':' && *chptr) chptr++; + se = s; + while (*se && !isspace(*se) && *se != ':') se++; - if (isspace(*chptr)) { - *chptr++ = '\0'; - while (isspace(*chptr) && *chptr != ':' && *chptr) chptr++; + if (isspace(*se)) { + *se++ = '\0'; + while (*se && isspace(*se) && *se != ':') se++; } - if (*chptr != ':') { + if (*se != ':') { rpmError(RPMERR_RPMRC, _("missing ':' at %s:%d"), filename, linenum); return 1; } + *se++ = '\0'; + while (*se && isspace(*se)) se++; - *chptr++ = '\0'; - - searchOption.name = start; + /* Find keyword in table */ + searchOption.name = s; option = bsearch(&searchOption, optionTable, optionTableSize, sizeof(struct rpmOption), optionCompare); - if (option) { - start = chptr; - while (isspace(*start) && *start) start++; + if (option) { /* For configuration variables ... */ + const char *arch, *val, *fn; - if (! *start) { + arch = val = fn = NULL; + if (*se == '\0') { rpmError(RPMERR_RPMRC, _("missing argument for %s at %s:%d"), option->name, filename, linenum); return 1; } switch (option->var) { - case RPMVAR_INCLUDE: { FD_t fdinc; + s = se; + while (*se && !isspace(*se)) se++; + if (*se) *se++ = '\0'; + rpmRebuildTargetVars(NULL, NULL); - strcpy(buf, start); - if (expandMacros(NULL, NULL, buf, sizeof(buf))) { + fn = rpmGetPath(s, NULL); + if (fn == NULL || *fn == '\0') { rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\""), - option->name, filename, linenum, start); + option->name, filename, linenum, s); + if (fn) xfree(fn); return 1; } - if (fdFileno(fdinc = fdOpen(buf, O_RDONLY, 0)) < 0) { + fdinc = fdOpen(fn, O_RDONLY, 0); + if (fdFileno(fdinc) < 0) { rpmError(RPMERR_RPMRC, _("cannot open %s at %s:%d"), - buf, filename, linenum); - return 1; + fn, filename, linenum); + rc = 1; + } else { + rc = doReadRC(fdinc, fn); + fdClose(fdinc); } - rc = doReadRC(fdinc, buf); - fdClose(fdinc); + if (fn) xfree(fn); if (rc) return rc; + continue; /* XXX don't save include value as var/macro */ } break; case RPMVAR_MACROFILES: - buf[0] = '\0'; - strncat(buf, start, sizeof(buf) - strlen(buf)); - if (expandMacros(NULL, NULL, buf, sizeof(buf))) { + fn = rpmGetPath(se, NULL); + if (fn == NULL || *fn == '\0') { rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\""), - option->name, filename, linenum, start); + option->name, filename, linenum, fn); + if (fn) xfree(fn); return 1; } - start = buf; + se = (char *)fn; break; + case RPMVAR_PROVIDES: + { char *t; + s = rpmGetVar(RPMVAR_PROVIDES); + fn = t = malloc(strlen(s) + strlen(se) + 2); + while (*s) *t++ = *s++; + *t++ = ' '; + while (*se) *t++ = *se++; + *t++ = '\0'; + se = (char *)fn; + } break; default: break; } - chptr = start; if (option->archSpecific) { - while (!isspace(*chptr) && *chptr) chptr++; - - if (!*chptr) { + arch = se; + while (*se && !isspace(*se)) se++; + if (*se == '\0') { rpmError(RPMERR_RPMRC, _("missing architecture for %s at %s:%d"), option->name, filename, linenum); return 1; } - - *chptr++ = '\0'; - - while (isspace(*chptr) && *chptr) chptr++; - if (!*chptr) { + *se++ = '\0'; + while (*se && isspace(*se)) se++; + if (*se == '\0') { rpmError(RPMERR_RPMRC, _("missing argument for %s at %s:%d"), option->name, filename, linenum); return 1; } - if (option->macroize && !strcmp(start, current[ARCH])) { - char *s = buf; - if (option->localize) - *s++ = '_'; - strcpy(s, option->name); - addMacro(NULL, buf, NULL, chptr, RMIL_RPMRC); - } - } else { - start = NULL; /* no arch */ - /* XXX for now only non-arch values can get macroized */ - if (option->macroize) { - char *s = buf; - if (option->localize) - *s++ = '_'; - strcpy(s, option->name); - addMacro(NULL, buf, NULL, chptr, RMIL_RPMRC); - } } - rpmSetVarArch(option->var, chptr, start); - } else { + + val = se; + + /* Only add macros if appropriate for this arch */ + if (option->macroize && + (arch == NULL || !strcmp(arch, current[ARCH]))) { + char *n, *name; + n = name = malloc(strlen(option->name)+2); + if (option->localize) + *n++ = '_'; + strcpy(n, option->name); + addMacro(NULL, name, NULL, val, RMIL_RPMRC); + free(name); + } + rpmSetVarArch(option->var, val, arch); + if (fn) xfree(fn); + + } else { /* For arch/os compatibilty tables ... */ + int gotit; + int i; + gotit = 0; for (i = 0; i < RPM_MACHTABLE_COUNT; i++) { - if (!strncmp(tables[i].key, start, strlen(tables[i].key))) + if (!strncmp(tables[i].key, s, strlen(tables[i].key))) break; } if (i < RPM_MACHTABLE_COUNT) { - rest = start + strlen(tables[i].key); + char *rest = s + strlen(tables[i].key); if (*rest == '_') rest++; if (!strcmp(rest, "compat")) { - if (machCompatCacheAdd(chptr, filename, linenum, + if (machCompatCacheAdd(se, filename, linenum, &tables[i].cache)) return 1; gotit = 1; @@ -757,13 +772,13 @@ static int doReadRC(FD_t fd, const char * filename) { !strcmp(rest, "translate")) { if (addDefault(&tables[i].defaults, &tables[i].defaultsLength, - chptr, filename, linenum)) + se, filename, linenum)) return 1; gotit = 1; } else if (tables[i].hasCanon && !strcmp(rest, "canon")) { if (addCanon(&tables[i].canons, &tables[i].canonsLength, - chptr, filename, linenum)) + se, filename, linenum)) return 1; gotit = 1; } @@ -771,7 +786,7 @@ static int doReadRC(FD_t fd, const char * filename) { if (!gotit) { rpmError(RPMERR_RPMRC, _("bad option '%s' at %s:%d"), - start, filename, linenum); + s, filename, linenum); } } } @@ -977,7 +992,7 @@ void rpmSetVar(int var, const char *val) { values[var].value = (val ? strdup(val) : NULL); } -static void rpmSetVarArch(int var, char * val, char * arch) { +static void rpmSetVarArch(int var, const char * val, const char * arch) { struct rpmvarValue * next = values + var; if (next->value) { diff --git a/po/rpm.pot b/po/rpm.pot index 955ef90..acad66b 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-05-24 11:40-0400\n" +"POT-Creation-Date: 1999-05-25 16:14-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3100,47 +3100,47 @@ msgstr "" msgid "Unable to open %s for reading: %s." msgstr "" -#: ../lib/rpmrc.c:611 +#: ../lib/rpmrc.c:609 #, c-format msgid "Failed to read %s: %s." msgstr "" -#: ../lib/rpmrc.c:642 +#: ../lib/rpmrc.c:639 #, c-format msgid "missing ':' at %s:%d" msgstr "" -#: ../lib/rpmrc.c:658 ../lib/rpmrc.c:716 +#: ../lib/rpmrc.c:656 ../lib/rpmrc.c:729 #, c-format msgid "missing argument for %s at %s:%d" msgstr "" -#: ../lib/rpmrc.c:672 ../lib/rpmrc.c:690 +#: ../lib/rpmrc.c:673 ../lib/rpmrc.c:695 #, c-format msgid "%s expansion failed at %s:%d \"%s\"" msgstr "" -#: ../lib/rpmrc.c:678 +#: ../lib/rpmrc.c:681 #, c-format msgid "cannot open %s at %s:%d" msgstr "" -#: ../lib/rpmrc.c:706 +#: ../lib/rpmrc.c:721 #, c-format msgid "missing architecture for %s at %s:%d" msgstr "" -#: ../lib/rpmrc.c:773 +#: ../lib/rpmrc.c:788 #, c-format msgid "bad option '%s' at %s:%d" msgstr "" -#: ../lib/rpmrc.c:1109 +#: ../lib/rpmrc.c:1124 #, c-format msgid "Unknown system: %s\n" msgstr "" -#: ../lib/rpmrc.c:1110 +#: ../lib/rpmrc.c:1125 msgid "Please contact rpm-list@redhat.com\n" msgstr "" -- 2.7.4