((struct rpmOption *) b)->name);
}
-static void rpmRebuildTargetVars(const char ** canontarget);
+static void rpmRebuildTargetVars(const char **target, const char ** canontarget);
static struct machCacheEntry * machCacheFindEntry(struct machCache * cache,
int rpmReadConfigFiles(const char * file, const char * target)
{
- rpmSetMachine(NULL, NULL);
-
- if (target == NULL) {
- rpmRebuildTargetVars(&target);
- } else {
- addMacro(&globalMacroContext, "_target", NULL, target, RMIL_RPMRC);
- }
+ /* Preset target macros */
+ rpmRebuildTargetVars(&target, NULL);
+ /* Read the files */
if (rpmReadRC(file)) return -1;
- rpmRebuildTargetVars(&target);
+ /* Reset target macros */
+ rpmRebuildTargetVars(&target, NULL);
- { const char *cpu = getMacroBody(&globalMacroContext, "_target_cpu");
- const char *os = getMacroBody(&globalMacroContext, "_target_os");
+ /* Finally set target platform */
+ { const char *cpu = rpmExpand("%{_target_cpu}", NULL);
+ const char *os = rpmExpand("%{_target_os}", NULL);
rpmSetMachine(cpu, os);
- }
+ xfree(cpu);
+ xfree(os);
+ }
return 0;
}
}
-const char * rpmGetPath(const char *path, ...) {
+/* Return concatenated and expanded macro list */
+char * rpmExpand(const char *arg, ...)
+{
+ char buf[BUFSIZ], *p, *pe;
+ const char *s;
+ va_list ap;
+
+ if (arg == NULL)
+ return strdup("");
+
+ p = buf;
+ strcpy(p, arg);
+ pe = p + strlen(p);
+ *pe = '\0';
+
+ va_start(ap, arg);
+ while ((s = va_arg(ap, const char *)) != NULL) {
+ strcpy(pe, s);
+ pe += strlen(pe);
+ *pe = '\0';
+ }
+ va_end(ap);
+ expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
+ return strdup(buf);
+}
+
+/* Return concatenated and expanded path with multiple /'s removed */
+const char * rpmGetPath(const char *path, ...)
+{
char buf[BUFSIZ], *p, *pe;
const char *s;
va_list ap;
case RPMVAR_INCLUDE:
{ FD_t fdinc;
- rpmRebuildTargetVars(NULL);
+ rpmRebuildTargetVars(NULL, NULL);
strcpy(buf, start);
if (expandMacros(NULL, &globalMacroContext, buf, sizeof(buf))) {
getMachineInfo(OS, name, num);
}
-void rpmRebuildTargetVars(const char ** canontarget)
+void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget)
{
- char * ca = NULL, * co = NULL;
+ char *ca = NULL, *co = NULL, *ct;
const char * target = NULL;
int x;
-/*
- * XXX getMacroBody() may be nuked -- I originally added it for tdyas and it's
- * kinda half-baked (remember, each macro is actually a stack so it's not
- * clear which body is intended).
- *
- * You can, however, always do
- * char buf[BUFSIZ];
- * strcpy(buf, "%_target")
- * expandMacros(NULL, &globalMacroContext, buf, sizeof(buf)))
- * target = strdup(buf);
- *
- */
- if ((target = getMacroBody(&globalMacroContext, "_target")) != NULL)
- target = strdup(target);
-
/* Rebuild the compat table to recalculate the current target arch. */
rpmSetMachine(NULL, NULL);
rpmSetTables(RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS);
rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
- rpmGetArchInfo(&ca,NULL);
- rpmGetOsInfo(&co,NULL);
+ if (buildtarget && *buildtarget) {
+ /* Set arch and os from specified build target */
+ ca = ct = strdup(*buildtarget);
+ if ((co = strrchr(ct, '-')) != NULL) {
+ *co++ = '\0';
+ if (!strcmp(co, "gnu") && (co = strrchr(ct, '-')) != NULL)
+ *co++ = '\0';
+ }
+ if (co == NULL)
+ co = "linux";
+ } else {
+ /* Set build target from default arch and os */
+ rpmGetArchInfo(&ca,NULL);
+ rpmGetOsInfo(&co,NULL);
- if (ca == NULL) defaultMachine(&ca, NULL);
- if (co == NULL) defaultMachine(NULL, &co);
+ if (ca == NULL) defaultMachine(&ca, NULL);
+ if (co == NULL) defaultMachine(NULL, &co);
- for (x = 0; ca[x]; x++)
- ca[x] = tolower(ca[x]);
- for (x = 0; co[x]; x++)
- co[x] = tolower(co[x]);
+ for (x = 0; ca[x]; x++)
+ ca[x] = tolower(ca[x]);
+ for (x = 0; co[x]; x++)
+ co[x] = tolower(co[x]);
- if (target == NULL) {
- char *ct = malloc(strlen(co)+strlen(ca)+2);
+ ct = malloc(strlen(co)+strlen(ca)+2);
sprintf(ct, "%s-%s", ca, co);
target = ct;
}
/*
- * XXX All this macro pokery/jiggery could be achieved (I think)
- * by doing a delayed
+ * XXX All this macro pokery/jiggery could be achieved by doing a delayed
* initMacros(&globalMacroContext, PER-PLATFORM-MACRO-FILE-NAMES);
- * (I haven't looked at the code :-)
- *
- * In fact, if you want to get really sophisticated, you could encapsulate
- * within per-platform MacroContexts (but I'm not quite ready for that yet).
*/
delMacro(&globalMacroContext, "_target");
addMacro(&globalMacroContext, "_target", NULL, target, RMIL_RPMRC);
if (canontarget)
*canontarget = target;
+ if (ct != NULL && ct != target)
+ free(ct);
}
int rpmShowRC(FILE *f)
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-03-08 22:28-0500\n"
+"POT-Creation-Date: 1999-03-12 00:43-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "error reading header from package\n"
msgstr ""
-#: ../url.c:127
+#: ../url.c:138
#, c-format
msgid "Password for %s@%s: "
msgstr ""
-#: ../url.c:146 ../url.c:168
+#: ../url.c:157 ../url.c:179
#, c-format
msgid "error: %sport must be a number\n"
msgstr ""
-#: ../url.c:250
+#: ../url.c:261
msgid "url port must be a number\n"
msgstr ""
-#: ../url.c:286
+#: ../url.c:297
#, c-format
msgid "logging into %s as %s, pw %s\n"
msgstr ""
-#: ../lib/rpmdb.c:168 ../url.c:397
+#: ../lib/rpmdb.c:168 ../url.c:408
#, c-format
msgid "failed to open %s\n"
msgstr ""
-#: ../url.c:412
+#: ../url.c:423
#, c-format
msgid "failed to create %s\n"
msgstr ""
msgid "Too many args in default line at %s:%d"
msgstr ""
-#: ../lib/rpmrc.c:627
+#: ../lib/rpmrc.c:671
#, c-format
msgid "Cannot expand %s"
msgstr ""
-#: ../lib/rpmrc.c:642
+#: ../lib/rpmrc.c:686
#, c-format
msgid "Unable to open %s for reading: %s."
msgstr ""
-#: ../lib/rpmrc.c:676
+#: ../lib/rpmrc.c:720
#, c-format
msgid "Failed to read %s: %s."
msgstr ""
-#: ../lib/rpmrc.c:707
+#: ../lib/rpmrc.c:751
#, c-format
msgid "missing ':' at %s:%d"
msgstr ""
-#: ../lib/rpmrc.c:723 ../lib/rpmrc.c:771
+#: ../lib/rpmrc.c:767 ../lib/rpmrc.c:815
#, c-format
msgid "missing argument for %s at %s:%d"
msgstr ""
-#: ../lib/rpmrc.c:737
+#: ../lib/rpmrc.c:781
#, c-format
msgid "expansion failed at %s:d \"%s\""
msgstr ""
-#: ../lib/rpmrc.c:743
+#: ../lib/rpmrc.c:787
#, c-format
msgid "cannot open %s at %s:%d"
msgstr ""
-#: ../lib/rpmrc.c:761
+#: ../lib/rpmrc.c:805
#, c-format
msgid "missing architecture for %s at %s:%d"
msgstr ""
-#: ../lib/rpmrc.c:828
+#: ../lib/rpmrc.c:872
#, c-format
msgid "bad option '%s' at %s:%d"
msgstr ""
-#: ../lib/rpmrc.c:1186
+#: ../lib/rpmrc.c:1230
#, c-format
msgid "Unknown system: %s\n"
msgstr ""
-#: ../lib/rpmrc.c:1187
+#: ../lib/rpmrc.c:1231
msgid "Please contact rpm-list@redhat.com\n"
msgstr ""
msgid "Invalid signature spec in rc file"
msgstr ""
-#: ../lib/transaction.c:705
+#: ../lib/transaction.c:721
#, c-format
msgid "relocating %s to %s\n"
msgstr ""
-#: ../lib/transaction.c:711
+#: ../lib/transaction.c:727
#, c-format
msgid "excluding %s\n"
msgstr ""
-#: ../lib/transaction.c:799
+#: ../lib/transaction.c:815
#, c-format
msgid "%s skipped due to missingok flag\n"
msgstr ""