Re: rpm processing using rpm.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23 Mar 2004 20:31:14 +0530
root [GP] wrote:

GP> Hello Friends,
GP>  I am in immediate need of some help and suggestions. I want to read all
GP> the rpms currently installed in my system and then process the
GP> information. I adopted some weired method to do this but its slow. 
GP> 
GP> #Generate the rpm list and store in the temporary file
GP> os.system("rpm -qa >> /tmp/rpm.tmp")
GP> 
GP> I want to latter process this data. I want information about all that
GP> contents in a particular rpm. If someone has seen the rpm-analyser
GP> (http://www.maisondubonheur.com/rpm-analyzer/#about) is would be clear.
GP> I would like to have all the info for a particular rpm is its verion,
GP> Provider, Packager, Summary etc. 
GP> 
GP> Now i want to know what is rpm.py module and whether i can use in for
GP> this purpose or any other suggestions would be appreciated.
GP> 

I did not understand what you were exactly looking for but
if you have any questions about rpm-analyzer I'll be glad to
answer.

The following example may help, though.

rpmtest.py
------------------------------------------------------------------
#!/usr/bin/python

import rpm, sys, os

if len(sys.argv) != 2:
        sys.stderr.write("Usage: %s <rpmfile>\n" % sys.argv[0])
        sys.exit(1)

file=sys.argv[1]

ts = rpm.TransactionSet("", rpm._RPMVSF_NOSIGNATURES)
fd = os.open(file, os.O_RDONLY)
hdr = ts.hdrFromFdno(fd)
print "package name   : ", hdr[rpm.RPMTAG_NAME]
print "package version: ", hdr[rpm.RPMTAG_VERSION]
os.close(fd)
------------------------------------------------------------------

you may find all RPMTAG_ values into the 'maximum rpm' document.

-- 
Alain 



[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux