2011/7/12 Jeff Johnson <n3...@mac.com>: > > On Jul 12, 2011, at 8:21 AM, Per Øyvind Karlsen wrote: > >> 2011/7/12 Jeff Johnson <n3...@mac.com>: >>> This isn't at all the right approach because >>> its doesn't scale. >>> >>> You have changed a single high performing rpmdb >>> access that applies patterns to keys only, and added >>> a hack-o-round that then goes and loads multiple >>> headers repeatedly to try and adjust the set >>> returned by the original access to fit some desired >>> semantic goal. >>> >>> You need to figure a better *RE pattern, not whack in >>> lots of gunky code to "fix it somehow". >> Yes, I kinda suspected this certainly wasn't the most optimal >> way to solve this.. :| >> >> The problem basically is that it's doing comparision of RPMTAG_NVRA >> between the installed packaged and the package to be installed, which >> will give us problems when only distepoch differs since RPMTAG_NVRA >> still isn't consistent with %___NVRA. >> > > There's a fundamental confusion here between "identification" > and versioning (as used in assertion checking). > > The %___NVRA is there purely for "identification". Whatever > elements you wish to add/delete in a chosen "identification" > string can be added at will. One can also undertake encoding > conversions, and attaching other data, from sources not > just derived from *.rpm metadata contents if you wish to > go to the trouble of adding a header tag/format extension > (which can be done without changing one line of RPM code > if necessary). > > OTOH, versioning is hierarchical, and depends on a sequence > of comparison operations applied to well defined data, done > strictly in the same order, with choices for results when > missing (as in not present or empty, different meanings for > "missing"). > >> ie. for: >> foo-1-1-mdv2011.0.x86_64 vs foo-1-1-mdv2012.0.x86_64, >> NVRA will be 'foo-1-1.x86_64' for both. >> >> So any good suggestions on performing the check on distepoch in addition >> without heavy drawbacks? > > The very simplest solution is > Call rpmtsRun() with RPMPROB_FILTER_REPLACEPACKAGE set. > That is what the flag is implemented and intended for. > > The next most simple fix starts to address a design flaw: > A sanity check on the elements in a transaction set > needs to be done somewhere else instead. Checking > in rpmtsRun() is far far far too late todo anything > but "best effort" fudging or bizarre FULLSTOP termination, > All of the checks, not just the *_REPLACEPKG check we happen to > be discussing, are total bullshit: if the check finds something > wrong, well, its some programmer's brain fart choosing what > packages to add to a transaction, not anything else. > > But if you simply MUST fix *_REPLACEPG, then the right fix is to > change rpmdbMireApply() to not use the "identification" RPMTAG_NVRA > string but rather construct whatever tag tests one wishes however > one wants. Post processing fiddle ups (like you just checked in) > to "correct" a call that should have been done differently are silly > band-aids. > >> Checking distepoch of the package to be installed is easy and fast enough >> with rpmteD(p), but any chance of providing distepoch with the keys returned >> by rpmdbMireApply on RPMTAG_NVRA in some way..? >> > > Um, not true: rpmteD is a simple getter, does no checking whatsoever, > so I have no idea how easy/fast applies to something that isn't being done. > > Passing keys Somewhere Else Instead isn't needed either: rpmdbMireApply() > is perfectly capable of being used intelligently, to perform a bullshit > test that isn't necessary at all, however you wish.
Would this be more acceptable? :) --- transaction.c 2011-07-12 11:50:34.229520174 +0200 +++ /home/peroyvind/RPM/rpm/BUILD/rpm-5.3.12/lib/transaction.c 2011-07-13 19:52:43.668223410 +0200 @@ -1165,32 +1165,10 @@ rpmlog(RPMLOG_DEBUG, D_("sanity checking if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG)) { ARGV_t keys = NULL; int nkeys; - xx = rpmdbMireApply(rpmtsGetRdb(ts), RPMTAG_NVRA, - RPMMIRE_STRCMP, rpmteNEVRA(p), &keys); + xx = rpmdbMireApply(rpmtsGetRdb(ts), RPMTAG_HDRID, + RPMMIRE_STRCMP, rpmteHdrid(p), &keys); nkeys = argvCount(keys); -#if defined(RPM_VENDOR_MANDRIVA) - /* mdvbz: #63711 - * workaround for distepoch never being added to RPMTAG_NVRA yet, - * leading to packages of same EVRA but with different distepoch - * being treated as the same package */ - if (nkeys > 0) { - int i; - for (i = 0; i < nkeys; i++) { - rpmmi mi = rpmtsInitIterator(ts, RPMTAG_NVRA, keys[i], 0); - Header h; - while ((h = rpmmiNext(mi)) != NULL) { - HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); - he->tag = RPMTAG_DISTEPOCH; - xx = headerGet(h, he, 0); - if (strcmp(he->p.str ? he->p.str : "", rpmteD(p) ? rpmteD(p) : "")) - nkeys--; - he->p.ptr = _free(he->p.ptr); - } - mi = rpmmiFree(mi); - } - } -#endif if (nkeys > 0) rpmpsAppend(ps, RPMPROB_PKG_INSTALLED, rpmteNEVR(p), rpmteKey(p), ______________________________________________________________________ RPM Package Manager http://rpm5.org Developer Communication List rpm-devel@rpm5.org