Convert our dependency checking code to use the new rpmdsMatches()
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 13 Sep 2012 10:12:59 +0000 (13:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 13 Sep 2012 10:12:59 +0000 (13:12 +0300)
- Instead of adding three more pool-aware versions of the old API's,
  convert the main callers to the newew more flexible API. As a
  "minor side-effect" these now use the transaction string-pool as well,
  so ALL our pre-transaction dependency sets are now using the global
  pool.

lib/depends.c
lib/transaction.c

index c100451..45f1e84 100644 (file)
@@ -180,6 +180,7 @@ static int addUpgradeErasures(rpmts ts, rpm_color_t tscolor,
 /* Add erase elements for obsoleted packages of same color (if any). */
 static int addObsoleteErasures(rpmts ts, rpm_color_t tscolor, rpmte p)
 {
+    rpmstrPool tspool = rpmtsPool(ts);
     rpmds obsoletes = rpmdsInit(rpmteDS(p, RPMTAG_OBSOLETENAME));
     Header oh;
     int rc = 0;
@@ -195,6 +196,7 @@ static int addObsoleteErasures(rpmts ts, rpm_color_t tscolor, rpmte p)
 
        while((oh = rpmdbNextIterator(mi)) != NULL) {
            const char *oarch = headerGetString(oh, RPMTAG_ARCH);
+           int match;
 
            /* avoid self-obsoleting packages */
            if (rstreq(rpmteN(p), Name) && rstreq(rpmteA(p), oarch)) {
@@ -208,8 +210,12 @@ static int addObsoleteErasures(rpmts ts, rpm_color_t tscolor, rpmte p)
             * Rpm prior to 3.0.3 does not have versioned obsoletes.
             * If no obsoletes version info is available, match all names.
             */
-           if (rpmdsEVR(obsoletes) == NULL
-               || rpmdsNVRMatchesDep(oh, obsoletes, _rpmds_nopromote)) {
+           match = (rpmdsEVR(obsoletes) == NULL);
+           if (!match)
+               match = rpmdsMatches(tspool, oh, -1, obsoletes, 1,
+                                        _rpmds_nopromote);
+
+           if (match) {
                char * ohNEVRA = headerGetAsString(oh, RPMTAG_NEVRA);
                rpmlog(RPMLOG_DEBUG, "  Obsoletes: %s\t\terases %s\n",
                        rpmdsDNEVR(obsoletes)+2, ohNEVRA);
@@ -478,20 +484,21 @@ static int rpmdbProvides(rpmts ts, depCache dcache, rpmds dep)
 
     /* Otherwise look in provides no matter what the dependency looks like */
     if (h == NULL) {
+       rpmstrPool tspool = rpmtsPool(ts);
        /* Obsoletes use just name alone, everything else uses provides */
        rpmTagVal dbtag = RPMDBI_PROVIDENAME;
-       if (deptag == RPMTAG_OBSOLETENAME)
+       int selfevr = 0;
+       if (deptag == RPMTAG_OBSOLETENAME) {
            dbtag = RPMDBI_NAME;
+           selfevr = 1;
+       }
 
        mi = rpmtsPrunedIterator(ts, dbtag, Name, prune);
        while ((h = rpmdbNextIterator(mi)) != NULL) {
-           int match;
-           if (deptag == RPMTAG_OBSOLETENAME) {
-               match = rpmdsNVRMatchesDep(h, dep, _rpmds_nopromote);
-           } else {
-               match = rpmdsMatchesDep(h, rpmdbGetIteratorFileNum(mi), dep,
+           /* Provide-indexes can't be used with nevr-only matching */
+           int prix = (selfevr) ? -1 : rpmdbGetIteratorFileNum(mi);
+           int match = rpmdsMatches(tspool, h, prix, dep, selfevr,
                                        _rpmds_nopromote);
-           }
            if (match) {
                rpmdsNotify(dep, "(db provides)", rc);
                break;
index bfc863d..aae5096 100644 (file)
@@ -633,7 +633,7 @@ static void ensureOlder(rpmstrPool tspool, const rpmte p, const Header h)
 
     req = rpmdsSinglePool(tspool, RPMTAG_REQUIRENAME,
                          rpmteN(p), rpmteEVR(p), reqFlags);
-    if (rpmdsNVRMatchesDep(h, req, _rpmds_nopromote) == 0) {
+    if (rpmdsMatches(tspool, h, -1, req, 1, _rpmds_nopromote) == 0) {
        char * altNEVR = headerGetAsString(h, RPMTAG_NEVRA);
        rpmteAddProblem(p, RPMPROB_OLDPACKAGE, altNEVR, NULL,
                        headerGetInstance(h));