diff options
author | Michael Schroeder <mls@suse.de> | 2012-04-23 11:04:02 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-04-23 11:04:02 +0300 |
commit | db28221a4a48f6ee3c804c92314330637c808638 (patch) | |
tree | 46fd4d1866729a65ba419c74668276551e27e96d /lib/rpmvercmp.c | |
parent | 4935f4853227d3981ba86d5557ae36704a1f67f2 (diff) | |
download | rpm-db28221a4a48f6ee3c804c92314330637c808638.tar.gz rpm-db28221a4a48f6ee3c804c92314330637c808638.tar.bz2 rpm-db28221a4a48f6ee3c804c92314330637c808638.zip |
Add support for dpkg-style sorting of tilde in version/release
- This allows much nicer handling some common scenarios such as
upstream pre-releases where the pre-release version would normally
appear newer than final release, eg 1.0-rc1 vs 1.0. Previously this
required mapping the pre-release tag into the release tag to achieve
desired sorting, with tild this becomes simply 1.0~rc1 < 1.0.
- Add a rpmlib() tracking dependency to prevent older rpm versions
from getting confused with packages relying on the new behavior.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Diffstat (limited to 'lib/rpmvercmp.c')
-rw-r--r-- | lib/rpmvercmp.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/rpmvercmp.c b/lib/rpmvercmp.c index f5ae09290..a6b707583 100644 --- a/lib/rpmvercmp.c +++ b/lib/rpmvercmp.c @@ -32,9 +32,18 @@ int rpmvercmp(const char * a, const char * b) two = str2; /* loop through each version segment of str1 and str2 and compare them */ - while (*one && *two) { - while (*one && !risalnum(*one)) one++; - while (*two && !risalnum(*two)) two++; + while (*one || *two) { + while (*one && !risalnum(*one) && *one != '~') one++; + while (*two && !risalnum(*two) && *two != '~') two++; + + /* handle the tilde separator, it sorts before everthing else */ + if (*one == '~' || *two == '~') { + if (*one != '~') return 1; + if (*two != '~') return -1; + one++; + two++; + continue; + } /* If we ran to the end of either, we are finished with the loop */ if (!(*one && *two)) break; |