From: Michael Schroeder Date: Tue, 15 Feb 2011 12:55:55 +0000 (+0200) Subject: Fix corner-case behavior on dependency matching when release not present X-Git-Tag: tznext/4.11.0.1.tizen20130304~1324 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82347dc881c68107dd81e1789761e7514b429000;p=tools%2Flibrpm-tizen.git Fix corner-case behavior on dependency matching when release not present - 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 --- diff --git a/lib/rpmds.c b/lib/rpmds.c index 9b112dc..c9c3b5d 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -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); diff --git a/tests/rpmdepmatch.at b/tests/rpmdepmatch.at index 01191ec..3cef104 100644 --- a/tests/rpmdepmatch.at +++ b/tests/rpmdepmatch.at @@ -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),