On Wed, 2002-05-15 at 18:51, barjunk wrote: > I was thinking that I would be able to read the hdlist files so that I > could find out which CD a particular rpm is on. The attached script I wrote a few weeks back for some random reason does it. Need to remember to throw this into the anaconda-runtime package since it could be moderately useful for the general case. Usage is simple enough -- 'dumphdrlist.py /path/to/hdlist' and it will then print the NEVRA of all of the packages as well as the disc it's on in the format E:N-V-R.A disc Cheers, Jeremy
#!/usr/bin/python # # dumphdrlist.py - dump the header list and give the discs that each # package is on # # Copyright 2002 Red Hat, Inc. # Author: Jeremy Katz <katzj@xxxxxxxxxx> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # import rpm import os import sys def usage(): print "%s <headerlist>" % (sys.argv[0]) def compareHeaders(first, second): name1 = first[rpm.RPMTAG_NAME] name2 = second[rpm.RPMTAG_NAME] if (name1 < name2): return -1 elif (name1 > name2): return 1 return 0 if len(sys.argv) < 2: usage() sys.exit(0) hdlist = rpm.readHeaderListFromFile(sys.argv[1]) hdlist.sort(compareHeaders) for hdr in hdlist: if hdr[rpm.RPMTAG_EPOCH] == None: epoch = "0" else: epoch = hdr[rpm.RPMTAG_EPOCH] print "%s:%s-%s-%s.%s %s" %(epoch, hdr[rpm.RPMTAG_NAME], hdr[rpm.RPMTAG_VERSION], hdr[rpm.RPMTAG_RELEASE], hdr[rpm.RPMTAG_ARCH], hdr[1000002])