diff -urN rpm-4.0.3.orig/build/pack.c rpm-4.0.3/build/pack.c --- rpm-4.0.3.orig/build/pack.c Tue Apr 17 22:26:32 2001 +++ rpm-4.0.3/build/pack.c Sun Jun 17 18:14:31 2001 @@ -443,8 +443,20 @@ if (Fileno(csa->cpioFdIn) < 0) { #ifndef DYING + if (headerIsEntry(h, RPMTAG_ARCH)) { + char *_arch; + headerGetEntry(h, RPMTAG_ARCH, NULL, (void **)&_arch, NULL); + rpmGetArchNum(_arch, &archnum); + } else { rpmGetArchInfo(NULL, &archnum); + } + if (headerIsEntry(h, RPMTAG_OS)) { + char *_os; + headerGetEntry(h, RPMTAG_OS, NULL, (void **)&_os, NULL); + rpmGetOsNum(_os, &osnum); + } else { rpmGetOsInfo(NULL, &osnum); + } #endif } else if (csa->lead != NULL) { archnum = csa->lead->archnum; diff -urN rpm-3.0.4.orig/build/parsePreamble.c rpm-3.0.4/build/parsePreamble.c --- rpm-3.0.4.orig/build/parsePreamble.c Tue Aug 24 17:09:22 1999 +++ rpm-3.0.4/build/parsePreamble.c Thu Sep 30 20:11:20 1999 @@ -140,6 +140,7 @@ { const char *arch = NULL; const char *os = NULL; + Package pkg; rpmGetArchInfo(&arch, NULL); rpmGetOsInfo(&os, NULL); @@ -154,6 +155,23 @@ rpmError(RPMERR_BADSPEC, _("Architecture is not included: %s"), arch); return RPMERR_BADSPEC; } + pkg = spec->packages; + while (pkg) { + if (headerIsEntry(pkg->header, RPMTAG_ARCH)) { + headerGetEntry(pkg->header, RPMTAG_ARCH, NULL, (void **)&arch, NULL); + if (isMemberInEntry(spec->buildRestrictions, + arch, RPMTAG_EXCLUDEARCH) == 1) { + rpmError(RPMERR_BADSPEC, _("Architecture is excluded: %s"), arch); + return RPMERR_BADSPEC; + } + if (isMemberInEntry(spec->buildRestrictions, + arch, RPMTAG_EXCLUSIVEARCH) == 0) { + rpmError(RPMERR_BADSPEC, _("Architecture is not included: %s"), arch); + return RPMERR_BADSPEC; + } + } + pkg = pkg->next; + } if (isMemberInEntry(spec->buildRestrictions, os, RPMTAG_EXCLUDEOS) == 1) { rpmError(RPMERR_BADSPEC, _("OS is excluded: %s"), os); @@ -164,6 +182,23 @@ rpmError(RPMERR_BADSPEC, _("OS is not included: %s"), os); return RPMERR_BADSPEC; } + pkg = spec->packages; + while (pkg) { + if (headerIsEntry(pkg->header, RPMTAG_OS)) { + headerGetEntry(pkg->header, RPMTAG_OS, NULL, (void **)&os, NULL); + if (isMemberInEntry(spec->buildRestrictions, + os, RPMTAG_EXCLUDEOS) == 1) { + rpmError(RPMERR_BADSPEC, _("OS is excluded: %s"), os); + return RPMERR_BADSPEC; + } + if (isMemberInEntry(spec->buildRestrictions, + os, RPMTAG_EXCLUSIVEOS) == 0) { + rpmError(RPMERR_BADSPEC, _("OS is not included: %s"), os); + return RPMERR_BADSPEC; + } + } + pkg = pkg->next; + } return 0; } @@ -367,6 +402,8 @@ case RPMTAG_NAME: case RPMTAG_VERSION: case RPMTAG_RELEASE: + case RPMTAG_ARCH: + case RPMTAG_OS: case RPMTAG_URL: SINGLE_TOKEN_ONLY; /* These macros are for backward compatibility */ @@ -611,7 +648,9 @@ {RPMTAG_AUTOREQPROV, 0, 0, "autoreqprov"}, {RPMTAG_AUTOREQ, 0, 0, "autoreq"}, {RPMTAG_AUTOPROV, 0, 0, "autoprov"}, - {RPMTAG_DOCDIR, 0, 0, "docdir"}, + {RPMTAG_DOCDIR, 0, 0, "docdir"}, + {RPMTAG_ARCH, 0, 0, "targetarch"}, + {RPMTAG_OS, 0, 0, "targetos"}, {0, 0, 0, 0} }; diff -urN rpm-3.0.3.orig/build/parseSpec.c rpm-3.0.3/build/parseSpec.c --- rpm-3.0.3.orig/build/parseSpec.c Mon Sep 6 23:51:54 1999 +++ rpm-3.0.3/build/parseSpec.c Thu Sep 30 20:11:20 1999 @@ -496,8 +496,10 @@ return RPMERR_BADSPEC; } - headerAddEntry(pkg->header, RPMTAG_OS, RPM_STRING_TYPE, os, 1); - headerAddEntry(pkg->header, RPMTAG_ARCH, RPM_STRING_TYPE, arch, 1); + if (!headerIsEntry(pkg->header, RPMTAG_OS)) + headerAddEntry(pkg->header, RPMTAG_OS, RPM_STRING_TYPE, os, 1); + if (!headerIsEntry(pkg->header, RPMTAG_ARCH)) + headerAddEntry(pkg->header, RPMTAG_ARCH, RPM_STRING_TYPE, arch, 1); } FREE(myos); } diff -urN rpm-4.0.3.orig/lib/rpmlib.h rpm-4.0.3/lib/rpmlib.h --- rpm-4.0.3.orig/lib/rpmlib.h Thu Apr 19 18:11:00 2001 +++ rpm-4.0.3/lib/rpmlib.h Sun Jun 17 18:08:16 2001 @@ -475,6 +475,7 @@ * @retval num address of arch number (or NULL) */ void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num); +void rpmGetArchNum(char * name, int * num); /** \ingroup rpmrc * Return current os name and/or number. @@ -483,6 +484,7 @@ * @retval num address of os number (or NULL) */ void rpmGetOsInfo( /*@out@*/ const char ** name, /*@out@*/ int * num); +void rpmGetOsNum(char * name, int * num); /** \ingroup rpmrc * Return arch/os score of a name. diff -urN rpm-3.0.3.orig/lib/rpmrc.c rpm-3.0.3/lib/rpmrc.c --- rpm-3.0.3.orig/lib/rpmrc.c Mon Aug 16 19:05:03 1999 +++ rpm-3.0.3/lib/rpmrc.c Thu Sep 30 20:11:20 1999 @@ -1136,6 +1136,38 @@ getMachineInfo(OS, name, num); } +static void getNum(int type, char * name, int * num) { + struct canonEntry * canon; + int which = currTables[type]; + + /* use the normal canon tables, even if we're looking up build stuff */ + if (which >= 2) which -= 2; + + canon = lookupInCanonTable(name, + tables[which].canons, + tables[which].canonsLength); + + if (canon) { + if (num) *num = canon->num; + } else { + if (num) *num = 255; + + if (tables[currTables[type]].hasCanon) { + rpmMessage(RPMMESS_WARNING, _("Unknown system: %s\n"), name); +/* rpmMessage(RPMMESS_WARNING, _("Please contact rpm-list@redhat.com\n"));*/ + } + } +} + +void rpmGetArchNum(char * name, int * num) { + getNum(ARCH, name, num); +} + +void rpmGetOsNum(char * name, int * num) { + getNum(OS, name, num); +} + + void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget) {