Shell Script - Compare packages. rpm

Geofrey Rainey Geofrey.Rainey at tvnz.co.nz
Mon Jan 26 22:04:04 UTC 2009


I would do something like this:

Use the rpm queryformat functionality of rpm to print out the version
of the package:

 rpm -q --queryformat '%{VERSION}' glibc-devel-2.3.4-2.39

This will print out the version, something like:

2.3.4-2.39

Which can then be compared against a newer version (for this part you
Would need to get update.out filename list into a similar format).


Geofrey Rainey
Systems Engineer
D. 64 9 916 7178
M. 64 21 563 106
geofrey.rainey at tvnz.co.nz


-----Original Message-----
From: redhat-list-bounces at redhat.com [mailto:redhat-list-bounces at redhat.com] On Behalf Of Tiago Dias
Sent: Monday, 26 January 2009 11:37 p.m.
To: redhat-list at redhat.com
Subject: Shell Script - Compare packages. rpm

Hi,

         I need a script which makes the package compação rpm's through two text files ...

         Since a file is the output of the command *rpm-qa > pkg.out *

         And the second file is a list of several packages rpm's, multiple versions and architectures.

         My idea is to compare a package *x* file pkg.out with several packages *y* of the file update.out and know whether a package and has a larger version of the package *x* installed and with that I return I have a package to be updated.

        Does anyone can help me do this comparison?

        OBS.: The servers do not have access to internet.

        Here's an example of the packages described in the files:

[root at rpm tiago]# tail -n12 pkg.out
glibc-devel-2.3.4-2.39
libuser-devel-0.52.5-1.el4.1
libmudflap-4.1.2-14.EL4
iiimf-libs-devel-12.1-13.EL.6
xorg-x11-devel-6.8.2-1.EL.33
lam-libs-7.1.2-8
libdbi-0.6.5-10.RHEL4.1
unixODBC-kde-2.2.11-1.RHEL4.1
perl-Compress-Zlib-1.42-1.el4
MySQL-python-1.2.1_p2-1.el4.1
nmap-3.70-1
sysstat-5.0.5-16.rhel4
[root at rpm tiago]#

--

[root at rpm tiago]# cat update.out
glibc-devel-2.3.4-2.41.i386.rpm
glibc-devel-2.3.4-2.39.i386.rpm
glibc-devel-2.3.4-2.36.i386.rpm
glibc-devel-2.3.4-2.25.i386.rpm
glibc-devel-2.3.4-2.19.i386.rpm
glibc-devel-2.3.4-2.13.i386.rpm
glibc-devel-2.3.4-2.9.i386.rpm
glibc-devel-2.3.4-2.i386.rpm
libuser-devel-0.52.5-1.el4.3.i386.rpm
libuser-devel-0.52.5-1.el4.1.i386.rpm
libuser-devel-0.52.5-1.i386.rpm
libmudflap-4.1.2-42.EL4.i386.rpm
libmudflap-4.1.2-14.EL4.i386.rpm
libmudflap-4.1.1-53.EL4.i386.rpm
libmudflap-4.1.0-18.EL4.3.i386.rpm
libmudflap-4.1.0-18.EL4.i386.rpm
libmudflap-4.0.2-14.EL4.i386.rpm
libmudflap-4.0.1-4.EL4.2.i386.rpm
libmudflap-4.0.0-0.14.EL4.i386.rpm
xorg-x11-devel-6.8.2-1.EL.52.i386.rpm
xorg-x11-devel-6.8.2-1.EL.33.0.4.i386.rpm
xorg-x11-devel-6.8.2-1.EL.33.0.2.i386.rpm
xorg-x11-devel-6.8.2-1.EL.33.0.1.i386.rpm
xorg-x11-devel-6.8.2-1.EL.33.i386.rpm
xorg-x11-devel-6.8.2-1.EL.31.i386.rpm
xorg-x11-devel-6.8.2-1.EL.19.i386.rpm
xorg-x11-devel-6.8.2-1.EL.18.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.37.7.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.37.5.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.37.2.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.37.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.36.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.25.1.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.25.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.20.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.16.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.6.i386.rpm
xorg-x11-devel-6.8.1-23.EL.i386.rpm
lam-libs-7.1.2-15.el4:2.i386.rpm
lam-libs-7.1.2-8:2.i386.rpm
MySQL-python-1.2.1_p2-1.el4.1.i386.rpm
MySQL-python-1.0.0-1.RHEL4.1.i386.rpm
sysstat-5.0.5-19.el4.i386.rpm
sysstat-5.0.5-16.rhel4.i386.rpm
sysstat-5.0.5-15.0.1.el4.i386.rpm
sysstat-5.0.5-14.rhel4.i386.rpm
sysstat-5.0.5-11.rhel4.i386.rpm
sysstat-5.0.5-7.rhel4.i386.rpm
sysstat-5.0.5-1.i386.rpm
nmap-3.70-1:2.i386.rpm
[root at rpm tiago]#

Att,


--
Tiago Dias da Silva
Administrador de Sistemas GNU/Linux
HomePage: www.dias.eti.br
Email: tiago at dias.eti.br

"A mente que se abre a uma nova idéia jamais voltará ao seu tamanho original"

(Albert Einstein)
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request at redhat.com?subject=subscribe
https://www.redhat.com/mailman/listinfo/redhat-list
==========================================================
For more information on the Television New Zealand Group, visit us
online at tvnz.co.nz 
==========================================================
CAUTION:  This e-mail and any attachment(s) contain information that
is intended to be read only by the named recipient(s).  This information
is not to be used or stored by any other person and/or organisation.





More information about the redhat-list mailing list