Handle obsolete matches (more) correctly in rpmal
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 5 Apr 2012 08:32:38 +0000 (11:32 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 5 Apr 2012 08:43:58 +0000 (11:43 +0300)
- Similar to commit 9fb81eac0bcd239e46459f72916099f1adfc5cb9 but
  on the to-be-installed set: obsoletes should only be matched against
  package names, not any provide or file names. Hasn't really mattered
  previously due to the way its called, but since commit
  05487d9a3f763cfed5f5ca75b4fbadb62f38dfd6 I guess it started to matter.
  It's more correct this way anyhow, and should fix RhBug:810077.
- Since rpmal only knows about provides, we need to handle obsoletes
  as a special case and filter out matches on provide names different
  than the matching package name.

lib/rpmal.c

index bbf0abb..8d5446d 100644 (file)
@@ -324,6 +324,7 @@ static rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds)
     const char * name;
     availableIndexEntry result;
     int resultCnt;
+    int obsolete;
 
     availablePackage alp;
     int rc;
@@ -334,7 +335,8 @@ static rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds)
     if (al->providesHash == NULL && al->fileHash == NULL)
        rpmalMakeIndex(al);
 
-    if (*name == '/') {
+    obsolete = (rpmdsTagN(ds) == RPMTAG_OBSOLETENAME);
+    if (!obsolete && *name == '/') {
        /* First, look for files "contained" in package ... */
        ret = rpmalAllFileSatisfiesDepend(al, ds);
        if (ret != NULL && *ret != NULL)
@@ -355,6 +357,11 @@ static rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds)
        if (alp->p == NULL) // deleted
            continue;
        (void) rpmdsSetIx(alp->provides, result[i].entryIx);
+
+       /* Obsoletes are on package name, filter out other provide matches */
+       if (obsolete && !rstreq(rpmdsN(alp->provides), rpmteN(alp->p)))
+           continue;
+
        rc = 0;
        if (rpmdsIx(alp->provides) >= 0)
            rc = rpmdsCompare(alp->provides, ds);