http://fedora.linuxsir.org/fedoradocs/rpm-guide/en/ch16s06.html
#!/usr/bin/python
# Adds all package files on command line to a transaction
# and prints out the transaction elements.
# Usage:
# python te.py rpm_file1.rpm rpm_file2.rpm ...
#
import rpm, os, sys
def readRpmHeader(ts, filename):
""" Read an rpm header. """
fd = os.open(filename, os.O_RDONLY)
h = ts.hdrFromFdno(fd)
os.close(fd)
return h
ts = rpm.TransactionSet()
# Set to not verify DSA signatures.
ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
for filename in sys.argv[1:]:
h = readRpmHeader(ts, filename)
print "Installing %s-%s-%s" % (h['name'], h['version'], h['release'])
ts.addInstall(h, filename, 'i')
print "This will install:"
for te in ts:
print "%s-%s-%s" % (te.N(), te.V(), te.R() )
ts.check()
ts.order()
print "\n"
print "This will install:"
for te in ts:
print "%s-%s-%s" % (te.N(), te.V(), te.R() )
No comments:
Post a Comment