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

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

list1 = ["binutils-2.23.52.0.1-12.el7.x86_64","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-2.23.52.0.1-12.el7.x86_64'
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 .
Reply


Messages In This Thread
rpm version comparison in python - by asad - Jul-26-2018, 02:08 PM
RE: rpm version comparison in python - by buran - Jul-26-2018, 02:18 PM
RE: rpm version comparison in python - by asad - Jul-27-2018, 12:59 PM
RE: rpm version comparison in python - by buran - Jul-27-2018, 01:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  run part of a script with a different version of Python jdog 2 445 Jan-09-2024, 08:49 PM
Last Post: jdog
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 737 Oct-04-2023, 10:01 AM
Last Post: snippsat
  How to resolve version conflicts in Python? taeefnajib 0 909 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  Python venv and PIP version issue JanOlvegg 2 1,254 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Python Version upgrade nitinkukreja 1 897 Feb-04-2023, 10:27 PM
Last Post: Larz60+
Photo String comparison in a csv file in Python Pandas fleafy 2 1,158 Nov-18-2022, 09:38 PM
Last Post: fleafy
  Can't update new python version on Pycharm GOKUUUU 6 3,803 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU
  Building python (3.9.5) with different libexpat version (2.4.6) raghupcr 0 1,306 Feb-25-2022, 11:29 AM
Last Post: raghupcr
  Python keeps running the old version of the code quest 2 3,752 Jan-20-2022, 07:34 AM
Last Post: ThiefOfTime
  db migration(db version control) for python lubaz 2 2,758 May-30-2021, 01:36 PM
Last Post: lubaz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020