[rpm] we need correctly process tilde in rpm package versioning

Bug #1586981 reported by Sergey Kulanov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
packetary
Fix Released
Critical
Sergey Kulanov

Bug Description

RPM package comparation doesn't take into account tilde "~", as the result we have wrong dep resolution:

1) Run:
$ python packetary/cli/commands/unresolved.py -t rpm -r centos_mirror.yaml

centos_mirror.yaml:
- name: "mos-repos"
  uri: "http://localhost:8000/centos//x86_64"
  priority: 1
  path: "/tmp/mirrors/mos-centos"

2) Result:
openstack-neutron; >= 1:8.0.0~b3; -
python-neutron; >= 1:8.0.0~b3; -

At the same time, no issue with yum usage:

yum deplist openstack-neutron
Loaded plugins: fastestmirror, ovl
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
mos | 3.6 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/6): extras/7/x86_64/primary_db | 132 kB 00:00:00
(2/6): base/7/x86_64/group_gz | 155 kB 00:00:00
(3/6): mos/group_gz | 220 kB 00:00:00
(4/6): mos/primary_db | 755 kB 00:00:00
(5/6): base/7/x86_64/primary_db | 5.3 MB 00:00:00
(6/6): updates/7/x86_64/primary_db | 4.9 MB 00:00:08
Determining fastest mirrors
 * base: mirror.tversu.ru
 * extras: mirror.tversu.ru
 * updates: mirror.tversu.ru
package: openstack-neutron.noarch 1:8.0.0-1.el7~mos179
  dependency: /bin/bash
   provider: bash.x86_64 4.2.46-19.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-19.el7
  dependency: /usr/bin/python2
   provider: python.x86_64 2.7.5-34.el7
  dependency: conntrack-tools
   provider: conntrack-tools.x86_64 1.4.2-9.el7
  dependency: dnsmasq
   provider: dnsmasq.x86_64 2.66-14.el7_1
  dependency: dnsmasq-utils
   provider: dnsmasq-utils.x86_64 2.66-14.el7_1
  dependency: ipset
   provider: ipset.x86_64 6.19-4.el7
  dependency: iptables
   provider: iptables-services.x86_64 1.4.21-16.el7
   provider: iptables.x86_64 1.4.21-16.el7
   provider: iptables.i686 1.4.21-16.el7
  dependency: keepalived
   provider: keepalived.x86_64 1.2.13-7.el7
  dependency: openstack-neutron-common = 1:8.0.0-1.el7~mos179
   provider: openstack-neutron-common.noarch 1:8.0.0-1.el7~mos179
  dependency: radvd
   provider: radvd.x86_64 1.9.2-9.el7
  dependency: shadow-utils
   provider: shadow-utils.x86_64 2:4.1.5.1-18.el7
  dependency: systemd
   provider: systemd.x86_64 219-19.el7_2.9

The thing is that we don't take into account tilde usage in version, please check the algorithm [1]:
***
- If both strings start with a tilde, discard it and move on to the next character.
- If string a starts with a tilde and string b does not, return -1 (string a is older); and the inverse if string b starts with a tilde and string a does not.
***

and the implementation from rpm tool itself:

    /* loop through each version segment of str1 and str2 and compare them */
    while (*one || *two) {
 while (*one && !risalnum(*one) && *one != '~') one++;
 while (*two && !risalnum(*two) && *two != '~') two++;

 /* handle the tilde separator, it sorts before everything else */
 if (*one == '~' || *two == '~') {
     if (*one != '~') return 1;
     if (*two != '~') return -1;
     one++;
     two++;
     continue;
 }

So we need to align packetary.

[1]. http://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to packetary (master)

Fix proposed to branch: master
Review: https://review.openstack.org/322744

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to packetary (master)

Reviewed: https://review.openstack.org/322744
Committed: https://git.openstack.org/cgit/openstack/packetary/commit/?id=2bd9a9415d70d4ddb5abdda8c595b316010aa3ef
Submitter: Jenkins
Branch: master

commit 2bd9a9415d70d4ddb5abdda8c595b316010aa3ef
Author: Sergey Kulanov <email address hidden>
Date: Mon May 30 12:53:24 2016 +0300

    [rpm] Handle the tilde separator in versioning

    We need correctly handle the tidle separator in RPM versioning [1]:
    eg:
       rpmdev-vercmp 1:8.0.0~b3 1:8.0.0
           1:8.0.0~b3 < 1:8.0.0
           1:8.0.1~b3 > 1:8.0.0
           1:8.0.0~b3 < 1:8.0.1~c1
           1:8.0.0~b3 > 1:8.0.0~a1

    [1]. http://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/

    Change-Id: I4a3c867a603a595515e76ee6f4415177a407a0b8
    Closes-bug: #1586981

Changed in packetary:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.