diff -ur rpm-4.4.7.org/build/build.c rpm-4.4.7/build/build.c --- rpm-4.4.7.org/build/build.c 2005-02-10 21:09:43.000000000 +0100 +++ rpm-4.4.7/build/build.c 2007-01-13 20:28:18.114303000 +0100 @@ -330,6 +330,15 @@ (rc = processSourceFiles(spec))) goto exit; + /* XXX Reset buildroot to its expansion to insure invariant. */ + { const char *buildroot = rpmExpand("%{?buildroot}", NULL); + if (buildroot && *buildroot) { + (void) delMacro(NULL, "buildroot"); + (void) addMacro(NULL, ".buildroot", NULL, buildroot, -1); + } + buildroot = _free(buildroot); + } + if (((what & RPMBUILD_INSTALL) || (what & RPMBUILD_PACKAGEBINARY) || (what & RPMBUILD_FILECHECK)) && (rc = processBinaryFiles(spec, what & RPMBUILD_INSTALL, test))) diff -ur rpm-4.4.7.org/build/files.c rpm-4.4.7/build/files.c --- rpm-4.4.7.org/build/files.c 2007-01-13 20:27:16.002421000 +0100 +++ rpm-4.4.7/build/files.c 2007-01-13 20:28:18.118303250 +0100 @@ -2640,6 +2640,8 @@ if (pkg->fileList == NULL) continue; + (void) headerMacrosLoad(pkg->header); + (void) headerNVR(pkg->header, &n, &v, &r); rpmMessage(RPMMESS_NORMAL, _("Processing files: %s-%s-%s\n"), n, v, r); @@ -2654,6 +2656,8 @@ /* XXX this should be earlier for deps to be entirely sorted. */ providePackageNVR(pkg->header); + + (void) headerMacrosUnload(pkg->header); } /* Now we have in fileList list of files from all packages. diff -ur rpm-4.4.7.org/lib/psm.c rpm-4.4.7/lib/psm.c --- rpm-4.4.7.org/lib/psm.c 2007-01-13 20:27:16.102427000 +0100 +++ rpm-4.4.7/lib/psm.c 2007-01-13 20:28:41.251749000 +0100 @@ -82,70 +82,6 @@ } /** - * Macros to be defined from per-header tag values. - * @todo Should other macros be added from header when installing a package? - */ -/*@observer@*/ /*@unchecked@*/ -static struct tagMacro { -/*@observer@*/ /*@null@*/ const char * macroname; /*!< Macro name to define. */ - rpmTag tag; /*!< Header tag to use for value. */ -} tagMacros[] = { - { "name", RPMTAG_NAME }, - { "version", RPMTAG_VERSION }, - { "release", RPMTAG_RELEASE }, - { "epoch", RPMTAG_EPOCH }, - { NULL, 0 } -}; - -/** - * Define per-header macros. - * @param fi transaction element file info - * @param h header - * @return 0 always - */ -static int rpmInstallLoadMacros(rpmfi fi, Header h) - /*@globals rpmGlobalMacroContext @*/ - /*@modifies rpmGlobalMacroContext @*/ -{ - HGE_t hge = (HGE_t) fi->hge; - struct tagMacro * tagm; - union { -/*@unused@*/ void * ptr; -/*@unused@*/ const char ** argv; - const char * str; - int_32 * i32p; - } body; - char numbuf[32]; - rpmTagType type; - - for (tagm = tagMacros; tagm->macroname != NULL; tagm++) { - if (!hge(h, tagm->tag, &type, (void **) &body, NULL)) - continue; - switch (type) { - case RPM_INT32_TYPE: -/*@-boundsread@*/ - sprintf(numbuf, "%d", *body.i32p); -/*@=boundsread@*/ - addMacro(NULL, tagm->macroname, NULL, numbuf, -1); - /*@switchbreak@*/ break; - case RPM_STRING_TYPE: - addMacro(NULL, tagm->macroname, NULL, body.str, -1); - /*@switchbreak@*/ break; - case RPM_NULL_TYPE: - case RPM_CHAR_TYPE: - case RPM_INT8_TYPE: - case RPM_INT16_TYPE: - case RPM_BIN_TYPE: - case RPM_STRING_ARRAY_TYPE: - case RPM_I18NSTRING_TYPE: - default: - /*@switchbreak@*/ break; - } - } - return 0; -} - -/** * Mark files in database shared with this package as "replaced". * @param psm package state machine data * @return 0 always @@ -294,7 +230,7 @@ hge = fi->hge; hfd = fi->hfd; -/*@i@*/ (void) rpmInstallLoadMacros(fi, fi->h); +/*@i@*/ (void) headerMacrosLoad(fi->h); psm->fi = rpmfiLink(fi, NULL); /*@-assignexpose -usereleased @*/ diff -ur rpm-4.4.7.org/lib/rpmlib.h rpm-4.4.7/lib/rpmlib.h --- rpm-4.4.7.org/lib/rpmlib.h 2006-10-08 21:01:41.000000000 +0200 +++ rpm-4.4.7/lib/rpmlib.h 2007-01-13 20:28:18.118303250 +0100 @@ -123,6 +123,24 @@ */ typedef /*@abstract@*/ /*@refcounted@*/ struct rpmgi_s * rpmgi; +/** + * Define per-header macros. + * @param h header + * @return 0 always + */ +int headerMacrosLoad(Header h) + /*@globals rpmGlobalMacroContext @*/ + /*@modifies rpmGlobalMacroContext @*/; + +/** + * Define per-header macros. + * @param h header + * @return 0 always + */ +int headerMacrosUnload(Header h) + /*@globals rpmGlobalMacroContext @*/ + /*@modifies rpmGlobalMacroContext @*/; + /** \ingroup header * Return name, version, release strings from header. * @param h header diff -ur rpm-4.4.7.org/macros.in rpm-4.4.7/macros.in --- rpm-4.4.7.org/macros.in 2007-01-13 20:27:16.078426000 +0100 +++ rpm-4.4.7/macros.in 2007-01-13 20:28:18.122303500 +0100 @@ -1348,8 +1348,8 @@ # # Note: Used iff _use_internal_dependency_generator is non-zero. The # helpers are also used by @RPMCONFIGDIR@/rpmdeps {--provides|--requires}. -%__libtool_provides @RPMCONFIGDIR@/libtooldeps.sh --provides %{buildroot} -%__libtool_requires @RPMCONFIGDIR@/libtooldeps.sh --requires %{buildroot} +%__libtool_provides @RPMCONFIGDIR@/libtooldeps.sh --provides %{buildroot} %{name} +%__libtool_requires @RPMCONFIGDIR@/libtooldeps.sh --requires %{buildroot} %{name} #------------------------------------------------------------------------ # pkgconfig(...) configuration. diff -ur rpm-4.4.7.org/rpmdb/hdrNVR.c rpm-4.4.7/rpmdb/hdrNVR.c --- rpm-4.4.7.org/rpmdb/hdrNVR.c 2003-01-17 18:43:45.000000000 +0100 +++ rpm-4.4.7/rpmdb/hdrNVR.c 2007-01-13 20:28:18.122303500 +0100 @@ -3,9 +3,112 @@ */ #include "system.h" -#include "lib/rpmlib.h" +#include +#include #include "debug.h" +/** + * Macros to be defined from per-header tag values. + * @todo Should other macros be added from header when installing a package? + */ +/*@observer@*/ /*@unchecked@*/ +static struct tagMacro { +/*@observer@*/ /*@null@*/ + const char *macroname; /*!< Macro name to define. */ + rpmTag tag; /*!< Header tag to use for value. */ +} tagMacros[] = { + { "name", RPMTAG_NAME }, + { "version", RPMTAG_VERSION }, + { "release", RPMTAG_RELEASE }, + { "epoch", RPMTAG_EPOCH }, + { "arch", RPMTAG_ARCH }, + { "os", RPMTAG_OS }, + { NULL, 0 } +}; + +int headerMacrosLoad(Header h) +{ + struct tagMacro * tagm; + union { + const void * ptr; +/*@unused@*/ + const char ** argv; + const char * str; + int_32 * i32p; + } body; + char numbuf[32]; + int_32 type; + int xx; + + for (tagm = tagMacros; tagm->macroname != NULL; tagm++) { + xx = headerGetEntryMinMemory(h, tagm->tag, &type, (hPTR_t *) &body.ptr, NULL); + if (!xx) + continue; + switch (type) { + case RPM_INT32_TYPE: +/*@-boundsread@*/ + sprintf(numbuf, "%d", *body.i32p); +/*@=boundsread@*/ + addMacro(NULL, tagm->macroname, NULL, numbuf, -1); + /*@switchbreak@*/ break; + case RPM_STRING_TYPE: + addMacro(NULL, tagm->macroname, NULL, body.str, -1); + /*@switchbreak@*/ break; + case RPM_STRING_ARRAY_TYPE: + case RPM_I18NSTRING_TYPE: + case RPM_BIN_TYPE: + body.ptr = headerFreeData(body.ptr, type); + /*@fallthrough@*/ + case RPM_NULL_TYPE: + case RPM_CHAR_TYPE: + case RPM_INT8_TYPE: + case RPM_INT16_TYPE: + default: + /*@switchbreak@*/ break; + } + } + return 0; +} +int headerMacrosUnload(Header h) +{ + struct tagMacro * tagm; + union { + const void * ptr; +/*@unused@*/ + const char ** argv; + const char * str; + int_32 * i32p; + } body; + int_32 type; + int xx; + + for (tagm = tagMacros; tagm->macroname != NULL; tagm++) { + xx = headerGetEntryMinMemory(h, tagm->tag, &type, (hPTR_t *) &body.ptr, NULL); + if (!xx) + continue; + switch (type) { + case RPM_INT32_TYPE: + delMacro(NULL, tagm->macroname); + /*@switchbreak@*/ break; + case RPM_STRING_TYPE: + delMacro(NULL, tagm->macroname); + /*@switchbreak@*/ break; + case RPM_STRING_ARRAY_TYPE: + case RPM_I18NSTRING_TYPE: + case RPM_BIN_TYPE: + body.ptr = headerFreeData(body.ptr, type); + /*@fallthrough@*/ + case RPM_NULL_TYPE: + case RPM_CHAR_TYPE: + case RPM_INT8_TYPE: + case RPM_INT16_TYPE: + default: + /*@switchbreak@*/ break; + } + } + return 0; +} + int headerNVR(Header h, const char **np, const char **vp, const char **rp) { int type; diff -ur rpm-4.4.7.org/rpmdb/librpmdb.vers rpm-4.4.7/rpmdb/librpmdb.vers --- rpm-4.4.7.org/rpmdb/librpmdb.vers 2006-07-08 18:53:54.000000000 +0200 +++ rpm-4.4.7/rpmdb/librpmdb.vers 2007-01-13 20:28:18.122303500 +0100 @@ -28,6 +28,8 @@ headerDump; headerGetLangs; headerGetRawEntry; + headerMacrosLoad; + headerMacrosUnload; headerNEVRA; headerNVR; htAddEntry;