Fix corner-case behavior on dependency matching when release not present
authorMichael Schroeder <mls@suse.de>
Tue, 15 Feb 2011 12:55:55 +0000 (14:55 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 15 Feb 2011 12:55:55 +0000 (14:55 +0200)
- The idea behind the patch is that a missing release is handled
  as "all/any release". Nothing changes for "foo < 1.2" or
  "foo > 1.2", it still just compares the version. But "foo = 1.2"
  means "everything with version 1.2". Thus, any match against
  a package with version "1.2" a any non-empty release must
  return true.
- Update test-suite expectations to the new behavior.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
lib/rpmds.c
tests/rpmdepmatch.at

index 9b112dc..c9c3b5d 100644 (file)
@@ -740,8 +740,20 @@ int rpmdsCompare(const rpmds A, const rpmds B)
 
     if (sense == 0) {
        sense = rpmvercmp(aV, bV);
-       if (sense == 0 && aR && *aR && bR && *bR)
-           sense = rpmvercmp(aR, bR);
+       if (sense == 0) {
+           if (aR && *aR && bR && *bR) {
+               sense = rpmvercmp(aR, bR);
+           } else {
+               /* always matches if the side with no release has SENSE_EQUAL */
+               if ((aR && *aR && (B->Flags[B->i] & RPMSENSE_EQUAL)) ||
+                   (bR && *bR && (A->Flags[A->i] & RPMSENSE_EQUAL))) {
+                   aEVR = _free(aEVR);
+                   bEVR = _free(bEVR);
+                   result = 1;
+                   goto exit;
+               }
+           }
+       }
     }
     aEVR = _free(aEVR);
     bEVR = _free(bEVR);
index 01191ec..3cef104 100644 (file)
@@ -149,15 +149,15 @@ tests = [
     (('a', '=', '1.2-1'),      ('a', '>', '1.2'),      0),
     (('a', '=', '1.2-1'),      ('a', '<>', '1.2'),     0),
 
-    (('a', '>', '1.2-1'),      ('a', '=', '1.2'),      0), # ???
+    (('a', '>', '1.2-1'),      ('a', '=', '1.2'),      1),
     (('a', '>', '1.2-1'),      ('a', '>=', '1.2'),     1),
-    (('a', '>', '1.2-1'),      ('a', '<=', '1.2'),     0), # ???
+    (('a', '>', '1.2-1'),      ('a', '<=', '1.2'),     1),
     (('a', '>', '1.2-1'),      ('a', '<', '1.2'),      0),
     (('a', '>', '1.2-1'),      ('a', '>', '1.2'),      1),
     (('a', '>', '1.2-1'),      ('a', '<>', '1.2'),     1),
 
-    (('a', '<', '1.2-1'),      ('a', '=', '1.2'),      0), # ???
-    (('a', '<', '1.2-1'),      ('a', '>=', '1.2'),     0), # ???
+    (('a', '<', '1.2-1'),      ('a', '=', '1.2'),      1),
+    (('a', '<', '1.2-1'),      ('a', '>=', '1.2'),     1),
     (('a', '<', '1.2-1'),      ('a', '<=', '1.2'),     1),
     (('a', '<', '1.2-1'),      ('a', '<', '1.2'),      1),
     (('a', '<', '1.2-1'),      ('a', '>', '1.2'),      0),
@@ -177,7 +177,7 @@ tests = [
     (('a', '<=', '1.2-1'),     ('a', '>', '1.2'),      0),
     (('a', '<=', '1.2-1'),     ('a', '<>', '1.2'),     1),
 
-    (('a', '<>', '1.2-1'),     ('a', '=', '1.2'),      0), # ???
+    (('a', '<>', '1.2-1'),     ('a', '=', '1.2'),      1),
     (('a', '<>', '1.2-1'),     ('a', '>=', '1.2'),     1),
     (('a', '<>', '1.2-1'),     ('a', '<=', '1.2'),     1),
     (('a', '<>', '1.2-1'),     ('a', '<', '1.2'),      1),
@@ -187,9 +187,9 @@ tests = [
     (('a', '=', '1.2'),                ('a', '=', '1.2-1'),    1),
     (('a', '=', '1.2'),                ('a', '>=', '1.2-1'),   1),
     (('a', '=', '1.2'),                ('a', '<=', '1.2-1'),   1),
-    (('a', '=', '1.2'),                ('a', '<', '1.2-1'),    0), # ???
-    (('a', '=', '1.2'),                ('a', '>', '1.2-1'),    0), # ???
-    (('a', '=', '1.2'),                ('a', '<>', '1.2-1'),   0), # ???
+    (('a', '=', '1.2'),                ('a', '<', '1.2-1'),    1),
+    (('a', '=', '1.2'),                ('a', '>', '1.2-1'),    1),
+    (('a', '=', '1.2'),                ('a', '<>', '1.2-1'),   1),
 
     (('a', '>', '1.2'),                ('a', '=', '1.2-1'),    0),
     (('a', '>', '1.2'),                ('a', '>=', '1.2-1'),   1),
@@ -208,7 +208,7 @@ tests = [
     (('a', '>=', '1.2'),       ('a', '=', '1.2-1'),    1),
     (('a', '>=', '1.2'),       ('a', '>=', '1.2-1'),   1),
     (('a', '>=', '1.2'),       ('a', '<=', '1.2-1'),   1),
-    (('a', '>=', '1.2'),       ('a', '<', '1.2-1'),    0), # ???
+    (('a', '>=', '1.2'),       ('a', '<', '1.2-1'),    1),
     (('a', '>=', '1.2'),       ('a', '>', '1.2-1'),    1),
     (('a', '>=', '1.2'),       ('a', '<>', '1.2-1'),   1),
 
@@ -216,7 +216,7 @@ tests = [
     (('a', '<=', '1.2'),       ('a', '>=', '1.2-1'),   1),
     (('a', '<=', '1.2'),       ('a', '<=', '1.2-1'),   1),
     (('a', '<=', '1.2'),       ('a', '<', '1.2-1'),    1),
-    (('a', '<=', '1.2'),       ('a', '>', '1.2-1'),    0), # ???
+    (('a', '<=', '1.2'),       ('a', '>', '1.2-1'),    1),
     (('a', '<=', '1.2'),       ('a', '<>', '1.2-1'),   1),
 
     (('a', '<>', '1.2'),       ('a', '=', '1.2-1'),    0),