|
|
672c60 |
From c7e711bba58374f03347c795a567441cbef3de58 Mon Sep 17 00:00:00 2001
|
|
|
672c60 |
Message-Id: <c7e711bba58374f03347c795a567441cbef3de58.1574338784.git.pmatilai@redhat.com>
|
|
|
672c60 |
In-Reply-To: <871065ddd493c76d80345d2e80b38b9ce4c7acdd.1574338784.git.pmatilai@redhat.com>
|
|
|
672c60 |
References: <871065ddd493c76d80345d2e80b38b9ce4c7acdd.1574338784.git.pmatilai@redhat.com>
|
|
|
672c60 |
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
|
672c60 |
Date: Sat, 10 Sep 2016 11:39:23 +0200
|
|
|
672c60 |
Subject: [PATCH 3/3] Add support for sorting caret ('^') higher than base
|
|
|
672c60 |
version
|
|
|
672c60 |
|
|
|
672c60 |
1.1^20160101 means 1.1 version (base) and patches which were applied at
|
|
|
672c60 |
that date on top of it.
|
|
|
672c60 |
|
|
|
672c60 |
* 1.1^201601 > 1.1
|
|
|
672c60 |
* 1.1^201601 < 1.1.1
|
|
|
672c60 |
|
|
|
672c60 |
Having symmetry is also good.
|
|
|
672c60 |
|
|
|
672c60 |
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
|
672c60 |
---
|
|
|
672c60 |
build/pack.c | 4 ++++
|
|
|
672c60 |
lib/rpmds.c | 3 +++
|
|
|
672c60 |
lib/rpmvercmp.c | 19 +++++++++++++++++--
|
|
|
672c60 |
tests/rpmvercmp.at | 26 ++++++++++++++++++++++++++
|
|
|
672c60 |
4 files changed, 50 insertions(+), 2 deletions(-)
|
|
|
672c60 |
|
|
|
672c60 |
diff --git a/build/pack.c b/build/pack.c
|
|
|
672c60 |
index c94964be2..d7adcb0e2 100644
|
|
|
672c60 |
--- a/build/pack.c
|
|
|
672c60 |
+++ b/build/pack.c
|
|
|
672c60 |
@@ -354,6 +354,10 @@ static void finalizeDeps(Package pkg)
|
|
|
672c60 |
if (haveCharInDep(pkg, '~'))
|
|
|
672c60 |
(void) rpmlibNeedsFeature(pkg, "TildeInVersions", "4.10.0-1");
|
|
|
672c60 |
|
|
|
672c60 |
+ /* check if the package has a dependency with a '^' */
|
|
|
672c60 |
+ if (haveCharInDep(pkg, '^'))
|
|
|
672c60 |
+ (void) rpmlibNeedsFeature(pkg, "CaretInVersions", "4.15.0-1");
|
|
|
672c60 |
+
|
|
|
672c60 |
/* check if the package has a rich dependency */
|
|
|
672c60 |
if (haveRichDep(pkg))
|
|
|
672c60 |
(void) rpmlibNeedsFeature(pkg, "RichDependencies", "4.12.0-1");
|
|
|
672c60 |
diff --git a/lib/rpmds.c b/lib/rpmds.c
|
|
|
672c60 |
index 01aa1022b..730a58c35 100644
|
|
|
672c60 |
--- a/lib/rpmds.c
|
|
|
672c60 |
+++ b/lib/rpmds.c
|
|
|
672c60 |
@@ -1240,6 +1240,9 @@ static const struct rpmlibProvides_s rpmlibProvides[] = {
|
|
|
672c60 |
{ "rpmlib(TildeInVersions)", "4.10.0-1",
|
|
|
672c60 |
( RPMSENSE_EQUAL),
|
|
|
672c60 |
N_("dependency comparison supports versions with tilde.") },
|
|
|
672c60 |
+ { "rpmlib(CaretInVersions)", "4.15.0-1",
|
|
|
672c60 |
+ ( RPMSENSE_EQUAL),
|
|
|
672c60 |
+ N_("dependency comparison supports versions with caret.") },
|
|
|
672c60 |
{ "rpmlib(LargeFiles)", "4.12.0-1",
|
|
|
672c60 |
( RPMSENSE_EQUAL),
|
|
|
672c60 |
N_("support files larger than 4GB") },
|
|
|
672c60 |
diff --git a/lib/rpmvercmp.c b/lib/rpmvercmp.c
|
|
|
672c60 |
index b3d08faa4..13857e151 100644
|
|
|
672c60 |
--- a/lib/rpmvercmp.c
|
|
|
672c60 |
+++ b/lib/rpmvercmp.c
|
|
|
672c60 |
@@ -33,8 +33,8 @@ int rpmvercmp(const char * a, const char * b)
|
|
|
672c60 |
|
|
|
672c60 |
/* loop through each version segment of str1 and str2 and compare them */
|
|
|
672c60 |
while (*one || *two) {
|
|
|
672c60 |
- while (*one && !risalnum(*one) && *one != '~') one++;
|
|
|
672c60 |
- while (*two && !risalnum(*two) && *two != '~') two++;
|
|
|
672c60 |
+ while (*one && !risalnum(*one) && *one != '~' && *one != '^') one++;
|
|
|
672c60 |
+ while (*two && !risalnum(*two) && *two != '~' && *two != '^') two++;
|
|
|
672c60 |
|
|
|
672c60 |
/* handle the tilde separator, it sorts before everything else */
|
|
|
672c60 |
if (*one == '~' || *two == '~') {
|
|
|
672c60 |
@@ -45,6 +45,21 @@ int rpmvercmp(const char * a, const char * b)
|
|
|
672c60 |
continue;
|
|
|
672c60 |
}
|
|
|
672c60 |
|
|
|
672c60 |
+ /*
|
|
|
672c60 |
+ * Handle caret separator. Concept is the same as tilde,
|
|
|
672c60 |
+ * except that if one of the strings ends (base version),
|
|
|
672c60 |
+ * the other is considered as higher version.
|
|
|
672c60 |
+ */
|
|
|
672c60 |
+ if (*one == '^' || *two == '^') {
|
|
|
672c60 |
+ if (!*one) return -1;
|
|
|
672c60 |
+ if (!*two) return 1;
|
|
|
672c60 |
+ if (*one != '^') return 1;
|
|
|
672c60 |
+ if (*two != '^') return -1;
|
|
|
672c60 |
+ one++;
|
|
|
672c60 |
+ two++;
|
|
|
672c60 |
+ continue;
|
|
|
672c60 |
+ }
|
|
|
672c60 |
+
|
|
|
672c60 |
/* If we ran to the end of either, we are finished with the loop */
|
|
|
672c60 |
if (!(*one && *two)) break;
|
|
|
672c60 |
|
|
|
672c60 |
diff --git a/tests/rpmvercmp.at b/tests/rpmvercmp.at
|
|
|
672c60 |
index 8b32209aa..1e7c960ea 100644
|
|
|
672c60 |
--- a/tests/rpmvercmp.at
|
|
|
672c60 |
+++ b/tests/rpmvercmp.at
|
|
|
672c60 |
@@ -102,6 +102,32 @@ RPMVERCMP(1.0~rc1~git123, 1.0~rc1~git123, 0)
|
|
|
672c60 |
RPMVERCMP(1.0~rc1~git123, 1.0~rc1, -1)
|
|
|
672c60 |
RPMVERCMP(1.0~rc1, 1.0~rc1~git123, 1)
|
|
|
672c60 |
|
|
|
672c60 |
+dnl Basic testcases for caret sorting
|
|
|
672c60 |
+RPMVERCMP(1.0^, 1.0^, 0)
|
|
|
672c60 |
+RPMVERCMP(1.0^, 1.0, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0, 1.0^, -1)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1, 1.0^git1, 0)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1, 1.0, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0, 1.0^git1, -1)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1, 1.0^git2, -1)
|
|
|
672c60 |
+RPMVERCMP(1.0^git2, 1.0^git1, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1, 1.01, -1)
|
|
|
672c60 |
+RPMVERCMP(1.01, 1.0^git1, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0^20160101, 1.0^20160101, 0)
|
|
|
672c60 |
+RPMVERCMP(1.0^20160101, 1.0.1, -1)
|
|
|
672c60 |
+RPMVERCMP(1.0.1, 1.0^20160101, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0^20160101^git1, 1.0^20160101^git1, 0)
|
|
|
672c60 |
+RPMVERCMP(1.0^20160102, 1.0^20160101^git1, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0^20160101^git1, 1.0^20160102, -1)
|
|
|
672c60 |
+
|
|
|
672c60 |
+dnl Basic testcases for tilde and caret sorting
|
|
|
672c60 |
+RPMVERCMP(1.0~rc1^git1, 1.0~rc1^git1, 0)
|
|
|
672c60 |
+RPMVERCMP(1.0~rc1^git1, 1.0~rc1, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0~rc1, 1.0~rc1^git1, -1)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1~pre, 1.0^git1~pre, 0)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1, 1.0^git1~pre, 1)
|
|
|
672c60 |
+RPMVERCMP(1.0^git1~pre, 1.0^git1, -1)
|
|
|
672c60 |
+
|
|
|
672c60 |
dnl These are included here to document current, arguably buggy behaviors
|
|
|
672c60 |
dnl for reference purposes and for easy checking against unintended
|
|
|
672c60 |
dnl behavior changes.
|
|
|
672c60 |
--
|
|
|
672c60 |
2.23.0
|
|
|
672c60 |
|