diff --git a/build/rpmfc.c b/build/rpmfc.c index e9d459dbf..14bc1e44c 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -7,7 +7,6 @@ #include "rpmfc.h" #include "rpmerr.h" -#define _RPMDS_INTERNAL #include "rpmds.h" #include "rpmfi.h" @@ -1661,34 +1660,70 @@ assert(ac == c); /* Add Provides: */ if (fc->provides != NULL && (c = rpmdsCount(fc->provides)) > 0 && !fc->skipProv) { - p = (const void **) fc->provides->N; - xx = headerAddEntry(pkg->header, RPMTAG_PROVIDENAME, RPM_STRING_ARRAY_TYPE, - p, c); - /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */ - p = (const void **) fc->provides->EVR; -assert(p != NULL); - xx = headerAddEntry(pkg->header, RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY_TYPE, - p, c); - p = (const void **) fc->provides->Flags; -assert(p != NULL); - xx = headerAddEntry(pkg->header, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE, - p, c); + const char **names = xcalloc(c, sizeof(char *)); + const char **evrs = xcalloc(c, sizeof(char *)); + const char **flags = xcalloc(c, sizeof(int_32 *)); + int i; + rpmds pi = rpmdsInit(fc->provides); + while ((i = rpmdsNext(pi)) >= 0) { + names[i] = rpmdsN(pi); + evrs[i] = rpmdsEVR(pi); + flags[i] = rpmdsFlags(pi); + } + +assert(names != NULL); + xx = headerAddEntry(pkg->header, + RPMTAG_PROVIDENAME, + RPM_STRING_ARRAY_TYPE, + names, c); + /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */ +assert(evrs != NULL); + xx = headerAddEntry(pkg->header, + RPMTAG_PROVIDEVERSION, + RPM_STRING_ARRAY_TYPE, + evrs, c); +assert(flags != NULL); + xx = headerAddEntry(pkg->header, + RPMTAG_PROVIDEFLAGS, + RPM_INT32_TYPE, + flags, c); + free(names); + free(evrs); + free(flags); } /* Add Requires: */ if (fc->requires != NULL && (c = rpmdsCount(fc->requires)) > 0 && !fc->skipReq) { - p = (const void **) fc->requires->N; - xx = headerAddEntry(pkg->header, RPMTAG_REQUIRENAME, RPM_STRING_ARRAY_TYPE, - p, c); - /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */ - p = (const void **) fc->requires->EVR; -assert(p != NULL); - xx = headerAddEntry(pkg->header, RPMTAG_REQUIREVERSION, RPM_STRING_ARRAY_TYPE, - p, c); - p = (const void **) fc->requires->Flags; -assert(p != NULL); - xx = headerAddEntry(pkg->header, RPMTAG_REQUIREFLAGS, RPM_INT32_TYPE, - p, c); + const char **names = xcalloc(c, sizeof(char *)); + const char **evrs = xcalloc(c, sizeof(char *)); + const char **flags = xcalloc(c, sizeof(int_32 *)); + int i; + rpmds ri = rpmdsInit(fc->requires); + while ((i = rpmdsNext(ri)) >= 0) { + names[i] = rpmdsN(ri); + evrs[i] = rpmdsEVR(ri); + flags[i] = rpmdsFlags(ri); + } + +assert(names != NULL); + xx = headerAddEntry(pkg->header, + RPMTAG_REQUIRENAME, + RPM_STRING_ARRAY_TYPE, + names, c); + /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */ +assert(evrs != NULL); + xx = headerAddEntry(pkg->header, + RPMTAG_REQUIREVERSION, + RPM_STRING_ARRAY_TYPE, + evrs, c); +assert(flags != NULL); + xx = headerAddEntry(pkg->header, + RPMTAG_REQUIREFLAGS, + RPM_INT32_TYPE, + flags, c); + free(names); + free(evrs); + free(flags); } /* Add dependency dictionary(#dependencies) */ diff --git a/lib/rpmds.c b/lib/rpmds.c index 4de501bf1..ee91740a8 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -5,7 +5,6 @@ #include "rpmlib.h" -#define _RPMDS_INTERNAL #include "rpmds.h" #include "debug.h" @@ -21,6 +20,28 @@ int _rpmds_nopromote = 1; int _rpmds_unspecified_epoch_noise = 0; +/** + * A package dependency set. + */ +struct rpmds_s { + const char * Type; /*!< Tag name. */ + const char * DNEVR; /*!< Formatted dependency string. */ + Header h; /*!< Header for dependency set (or NULL) */ + const char ** N; /*!< Name. */ + const char ** EVR; /*!< Epoch-Version-Release. */ + int32_t * Flags; /*!< Bit(s) identifying context/comparison. */ + uint32_t * Color; /*!< Bit(s) calculated from file color(s). */ + int32_t * Refs; /*!< No. of file refs. */ + int32_t BT; /*!< Package build time tie breaker. */ + rpmTag tagN; /*!< Header tag. */ + rpmTagType Nt, EVRt, Ft; /*!< Tag data types. */ + int32_t Count; /*!< No. of elements */ + int i; /*!< Element index. */ + unsigned l; /*!< Low element (bsearch). */ + unsigned u; /*!< High element (bsearch). */ + int nopromote; /*!< Don't promote Epoch: in rpmdsCompare()? */ + int nrefs; /*!< Reference count. */ +}; rpmds XrpmdsUnlink(rpmds ds, const char * msg, const char * fn, unsigned ln) { if (ds == NULL) return NULL; diff --git a/lib/rpmds.h b/lib/rpmds.h index 8984aae41..32bc25a0e 100644 --- a/lib/rpmds.h +++ b/lib/rpmds.h @@ -21,31 +21,6 @@ extern int _rpmds_debug; */ extern int _rpmds_nopromote; -#if defined(_RPMDS_INTERNAL) -/** - * A package dependency set. - */ -struct rpmds_s { - const char * Type; /*!< Tag name. */ - const char * DNEVR; /*!< Formatted dependency string. */ - Header h; /*!< Header for dependency set (or NULL) */ - const char ** N; /*!< Name. */ - const char ** EVR; /*!< Epoch-Version-Release. */ - int32_t * Flags; /*!< Bit(s) identifying context/comparison. */ - uint32_t * Color; /*!< Bit(s) calculated from file color(s). */ - int32_t * Refs; /*!< No. of file refs. */ - int32_t BT; /*!< Package build time tie breaker. */ - rpmTag tagN; /*!< Header tag. */ - rpmTagType Nt, EVRt, Ft; /*!< Tag data types. */ - int32_t Count; /*!< No. of elements */ - int i; /*!< Element index. */ - unsigned l; /*!< Low element (bsearch). */ - unsigned u; /*!< High element (bsearch). */ - int nopromote; /*!< Don't promote Epoch: in rpmdsCompare()? */ - int nrefs; /*!< Reference count. */ -}; -#endif /* _RPMDS_INTERNAL */ - /** * Unreference a dependency set instance. * @param ds dependency set diff --git a/lib/rpmts.c b/lib/rpmts.c index e794a047b..c297b42d3 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -16,7 +16,6 @@ #include "rpmlock.h" #include "rpmerr.h" -#define _RPMTE_INTERNAL /* XXX te->h */ #include "rpmte.h" #define _RPMTS_INTERNAL @@ -1418,11 +1417,13 @@ void * rpmtsNotify(rpmts ts, rpmte te, { void * ptr = NULL; if (ts && ts->notify && te) { -assert(!(te->type == TR_ADDED && te->h == NULL)); + Header h = rpmteHeader(te); +assert(!(rpmteType(te) == TR_ADDED && h == NULL)); /* FIX: cast? */ /* FIX: check rc */ - ptr = ts->notify(te->h, what, amount, total, + ptr = ts->notify(h, what, amount, total, rpmteKey(te), ts->notifyData); + headerUnlink(h); /* undo rpmteHeader() ref */ } return ptr; } diff --git a/lib/transaction.c b/lib/transaction.c index 04742312c..a38076642 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -35,19 +35,6 @@ #include "idtx.h" - -/* XXX: This is a hack. I needed a to setup a notify callback - * for the rollback transaction, but I did not want to create - * a header for rpminstall.c. - */ -extern void * rpmShowProgress(const void * arg, - const rpmCallbackType what, - const unsigned long amount, - const unsigned long total, - fnpyKey key, - void * data) - ; - /** */ static int archOkay(const char * pkgArch) @@ -988,14 +975,16 @@ static rpmRC _rpmtsRollback(rpmts rollbackTransaction) */ tsi = rpmtsiInit(rollbackTransaction); while((te = rpmtsiNext(tsi, 0)) != NULL) { + fnpyKey key = NULL; rpmlog(RPMLOG_NOTICE, _("Cleaning up repackaged packages:\n")); switch (rpmteType(te)) { /* The install elements are repackaged packages */ case TR_ADDED: /* Make sure the filename is still there. XXX: Can't happen */ - if(te->key) { - rpmlog(RPMLOG_NOTICE, _("\tRemoving %s:\n"), te->key); - (void) unlink(te->key); /* XXX: Should check for an error? */ + key = rpmteKey(te); + if(key) { + rpmlog(RPMLOG_NOTICE, _("\tRemoving %s:\n"), key); + (void) unlink(key); /* XXX: Should check for an error? */ } break;