def files(self): self.baseDir= self.baseDirTemplate % self if hasattr (self, 'hdlistTemplate'): self.hdlist= self.hdlistTemplate % self hdlist= "%(tempDir)s/%(repoDir)s/%(baseDir)s/%(hdlist)s" % self logger.debug ("opening %s" % hdlist) pipe= popen ('zcat %s' % hdlist) try: self.rpmList= listdir ("%(repoDir)s/%(baseDir)s/%(rpmDir)s" % self) except OSError: self.rpmList= [] headerList= rpm.readHeaderListFromFD (pipe.fileno()) for header in headerList: rpmArch= header[rpm.RPMTAG_ARCH] # logger.debug ("rpm %s arch: %s" % (header[1000000], rpmArch)) if rpmArch==self.arch or rpmArch=='noarch': # 1000000-> rpm file name, 1000001-> rpm file size size= header[1000001] if size==[]: # f**k mandriva, first giving the wrong sizes and now simply removing it. size= None filedata= (("%(baseDir)s/%(rpmDir)s/" % self)+header[1000000], size) logger.debug ("yielding %s [%s, %s]" % (filedata[0], self.baseDir, self.rpmDir)) yield (filedata) pipe.close ()
def __init__(self, fd): hdlist = rpm.readHeaderListFromFD (fd) HeaderList.__init__(self, hdlist)
release = str[j + 1:] else: if str[i + 1:] == '': version = None else: version = str[i + 1:] release = None return (epoch, version, release) if __name__ == "__main__": import sys, os if len(sys.argv) < 2: print "Usage: %s /path/to/tree [rootpath]" % (sys.argv[0], ) sys.exit(0) tree = sys.argv[1] if len(sys.argv) >= 3: instPath = sys.argv[2] else: instPath = "/" fd = os.open("%s/%s/base/hdlist" % (tree, productPath), os.O_RDONLY) hdlist = rpm.readHeaderListFromFD(fd) os.close(fd) packages = findpackageset(hdlist, instPath) for pkg in packages: print pkg[rpm.RPMTAG_NAME]
release = str[j + 1 :] else: if str[i + 1 :] == "": version = None else: version = str[i + 1 :] release = None return (epoch, version, release) if __name__ == "__main__": import sys, os if len(sys.argv) < 2: print "Usage: %s /path/to/tree [rootpath]" % (sys.argv[0],) sys.exit(0) tree = sys.argv[1] if len(sys.argv) >= 3: instPath = sys.argv[2] else: instPath = "/" fd = os.open("%s/%s/base/hdlist" % (tree, productPath), os.O_RDONLY) hdlist = rpm.readHeaderListFromFD(fd) os.close(fd) packages = findpackageset(hdlist, instPath) for pkg in packages: print pkg[rpm.RPMTAG_NAME]
sys.exit(0) else: pass def packageSort(first, second): one = first[1000002] two = second[1000002] if one < two: return -1 elif one > two: return 1 return 0 fd = os.open("%s/%s/base/hdlist" % (tree, productPath), os.O_RDONLY) hdrs = rpm.readHeaderListFromFD(fd) os.close(fd) showMem() # fd = os.open(tree + "/RedHat/base/hdlist2", os.O_RDONLY) # rpm.mergeHeaderListFromFD(hdrs, fd, 1000004) # os.close(fd) showMem() f = open("%s/%s/base/comps.xml" % (tree, productPath), "r") comps = rhpl.comps.Comps(f) f.close() showMem() hdrlist = HeaderList(hdrs) hdrlist.mergeFullHeaders("%s/%s/base/hdlist2" % (tree, productPath)) showMem() groups = GroupSet(comps, hdrlist) showMem()