Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 rpm version comparison in python
Hi All ,

I have just read python and I was checking to code rpm version comparion .

list1 = ["binutils-","compat-libcap1-1.10-3.el7.x86_64","gcc-4.8.2-3.el7.x86_64","gcc-c++-4.8.2-3.el7.x86_64", 
         "glibc-2.17-36.el7.i686","glibc-2.17-36.el7.x86_64","glibc-devel-2.17-36.el7.i686"  ] 

list2 = [
basesystem-10.0-7.0.1.el7 (noarch)
bash-4.2.46-29.el7_4 (x86_64)
bc-1.06.95-13.el7 (x86_64)
bind-libs-9.9.4-51.el7_4.2 (x86_64)
bind-libs-lite-9.9.4-51.el7_4.2 (x86_64)
bind-license-9.9.4-51.el7_4.2 (noarch)
bind-utils-9.9.4-51.el7_4.2 (x86_64)
binutils-2.25.1-32.base.el7_4.2 (x86_64)
biosdevname-0.7.2-2.el7 (x86_64)
btrfs-progs-4.9.1-1.0.2.el7 (x86_64)
bzip2-1.0.6-13.el7 (x86_64)
bzip2-libs-1.0.6-13.el7 (i686)
bzip2-libs-1.0.6-13.el7 (x86_64)
ca-certificates-2017.2.14-71.el7 (noarch)
c-ares-1.10.0-3.el7 (x86_64)
checkpolicy-2.5-4.el7 (x86_64)
chkconfig-1.7.4-1.el7 (x86_64)
compat-libcap1-1.10-7.el7 (x86_64)
compat-libstdc++-33-3.2.3-72.el7 (i686)
compat-libstdc++-33-3.2.3-72.el7 (x86_64) ]
Is there any was we can perform a comparison with list1 and list2 and print all the new versions of rpm present in list2 and if certain rpm's which are present in list 1 but not in list 2 it should say missing rpm's and print the rpm name.

I tried this :

sys_pkg = 'binutils-'
repo_pkg = 'binutils-2.25.1-32.base.el7_4.2 (x86_64)'

result = rpm.compare_packages(repo_pkg, sys_pkg)
print result

if result > 0:  # repo_pkg is newer
    print('Repo package is newer')

It works well for single rpm's for not for the list .

If anyone is a aware of a code please share it with me I am unable to progress on this code .
buran wrote Jul-26-2018, 02:15 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Your second list is not defined correctly, add quotes to make elements sting, as well as commas.
Hi Plan to create 2 dictionary's data set there for need a regular expression get the package name and version name seperate:

I want to get a regex to actually get the rpm name and version for comparison :



First part of the regular expression is ^[a-zA-Z0-9\-]
which means search for anything that begins with a letter
(lower or upper) or a number up until you reach an
hyphen sign (‘-‘).

but it fails to match :compat-libstdc++-33-3.2.3-71.el7.i686

Please let me know what regex should i use to extract all 3
rpms names.

Also let me know if there are web tools to build regex
Good websites for regex tutorials.

Is there any module in python which acheives this

(Jul-27-2018, 12:57 PM)asad Wrote: let me know if there are web tools to build regex
Good websites for regex tutorials.

nice to test your regex, has explanations and can generate python code

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python version on Linux whois1230 5 252 Apr-10-2020, 07:12 PM
Last Post: buran
  Error while trying to see Python version with "sys.executable" karkas 5 385 Feb-09-2020, 01:55 AM
Last Post: karkas
  Comparison Operator "is" idle vs python command spisatus 3 451 Oct-29-2019, 10:00 PM
Last Post: DeaD_EyE
  update certbot's python version metulburr 0 644 Sep-19-2019, 11:51 AM
Last Post: metulburr
  Im using python crash course version 2 james_newbie 3 306 Sep-07-2019, 09:21 PM
Last Post: ichabod801
  [split] Using this Python version of text2pdf jonsnow1221 1 467 May-07-2019, 07:48 PM
Last Post: micseydel
  Using this Python version of text2pdf Pedroski55 1 565 Apr-15-2019, 08:12 AM
Last Post: Pedroski55
  can't install package web in version python 3.7 a21250450 1 597 Mar-29-2019, 11:28 AM
Last Post: Larz60+
  Python Version on Mac OSX Sparkstorm 5 700 Feb-06-2019, 10:32 AM
Last Post: Sparkstorm
  Python version 3 that seems to be ignored by the system on a Raspberry Pi Discret68 3 808 Dec-28-2018, 06:42 PM
Last Post: Gribouillis

Forum Jump:

Users browsing this thread: 1 Guest(s)