def getObsoletes(self, channel, msgCallback = None, progressCallback = None): # well, we've got the headers, might as well create a proper # obslist at this point filePath = "%s/%s-obsoletes.%s" % (self.cfg["storageDir"], channel['label'], channel['version']) globPattern = "%s/%s-obsoletes.*" % (self.cfg["storageDir"], channel['label']) if msgCallback: msgCallback("Fetching obsoletes list for %s" % channel['url']) try: pkgList = self.pkglists[channel['label']] except KeyError: # we just hit the getObsoletes path, with no package info known # figure it out ourselves rd = repoDirector.initRepoDirector() pkgList = rd.listPackages(channel, msgCallback, progressCallback) self.pkglists[channel['label']] = pkgList obsList = [] total = len(pkgList) count = 0 for pkg in pkgList: baseFileName = "%s-%s-%s.%s.hdr" % (pkg[0], pkg[1], pkg[2], pkg[4]) fileName = "%s/%s" % (self.cfg["storageDir"], baseFileName) if os.access(fileName, os.R_OK): fd = open(fileName, "r") try: hdr = rpmUtils.readHeaderBlob(fd.read()) except: continue fd.close() if not hdr['obsoletes']: continue obs = up2dateUtils.genObsoleteTupleFromHdr(hdr) if obs: # print obs obsList = obsList + obs if progressCallback: progressCallback(count, total) count = count + 1 # now we have the package list, convert it to xmlrpc style # presentation and dump it obsList.sort(lambda a, b: cmp(a[0], b[0])) rpmSourceUtils.saveListToDisk(obsList, filePath,globPattern) # print obsList return obsList
def getObsoletes(self, channel, msgCallback=None, progressCallback=None): # well, we've got the headers, might as well create a proper # obslist at this point filePath = "%s/%s-obsoletes.%s" % ( self.cfg["storageDir"], channel['label'], channel['version']) globPattern = "%s/%s-obsoletes.*" % (self.cfg["storageDir"], channel['label']) if msgCallback: msgCallback("Fetching obsoletes list for %s" % channel['url']) try: pkgList = self.pkglists[channel['label']] except KeyError: # we just hit the getObsoletes path, with no package info known # figure it out ourselves rd = repoDirector.initRepoDirector() pkgList = rd.listPackages(channel, msgCallback, progressCallback) self.pkglists[channel['label']] = pkgList obsList = [] total = len(pkgList) count = 0 for pkg in pkgList: baseFileName = "%s-%s-%s.%s.hdr" % (pkg[0], pkg[1], pkg[2], pkg[4]) fileName = "%s/%s" % (self.cfg["storageDir"], baseFileName) if os.access(fileName, os.R_OK): fd = open(fileName, "r") try: hdr = rpmUtils.readHeaderBlob(fd.read()) except: continue fd.close() if not hdr['obsoletes']: continue obs = up2dateUtils.genObsoleteTupleFromHdr(hdr) if obs: # print obs obsList = obsList + obs if progressCallback: progressCallback(count, total) count = count + 1 # now we have the package list, convert it to xmlrpc style # presentation and dump it obsList.sort(lambda a, b: cmp(a[0], b[0])) rpmSourceUtils.saveListToDisk(obsList, filePath, globPattern) # print obsList return obsList
def listPackages(self, channel, msgCallback = None, progressCallback = None): pkgsDict = self._get_all_packages_dict(channel['path'], channel['label']) latestPkgsDict = {} for pkgNvre in pkgsDict.keys(): # first version of this package, continue pkgName = pkgNvre[0] tupNvre = tuple(pkgNvre) if not latestPkgsDict.has_key(pkgName): latestPkgsDict[pkgName] = pkgsDict[tupNvre] continue ret = up2dateUtils.comparePackages(latestPkgsDict[pkgName][0], list(pkgNvre)) if ret > 0: # don't care, we already have a better version continue if ret < 0: # Better version latestPkgsDict[pkgName] = pkgsDict[pkgNvre] continue # if it's 0, we already have it pkgList = self._package_list_from_dict(latestPkgsDict, self.cfg["storageDir"], channel['label'], "", channel['version']) # since were talking local file, and we are already # loading them up and poking at the headers, lets figure # out the obsoletes stuff now too while were at it self.obsList = [] for pkg in pkgList: rpmpath = pkg[7] hdrBuf = self.__getHeader(rpmpath) hdr = rpmUtils.readHeaderBlob(hdrBuf.unload()) # look for header info if not hdr['obsoletes']: continue obs = up2dateUtils.genObsoleteTupleFromHdr(hdr) if obs: self.obsList = self.obsList + obs return pkgList
def listPackages(self, channel, msgCallback=None, progressCallback=None): pkgsDict = self._get_all_packages_dict(channel['path'], channel['label']) latestPkgsDict = {} for pkgNvre in pkgsDict.keys(): # first version of this package, continue pkgName = pkgNvre[0] tupNvre = tuple(pkgNvre) if not latestPkgsDict.has_key(pkgName): latestPkgsDict[pkgName] = pkgsDict[tupNvre] continue ret = up2dateUtils.comparePackages(latestPkgsDict[pkgName][0], list(pkgNvre)) if ret > 0: # don't care, we already have a better version continue if ret < 0: # Better version latestPkgsDict[pkgName] = pkgsDict[pkgNvre] continue # if it's 0, we already have it pkgList = self._package_list_from_dict(latestPkgsDict, self.cfg["storageDir"], channel['label'], "", channel['version']) # since were talking local file, and we are already # loading them up and poking at the headers, lets figure # out the obsoletes stuff now too while were at it self.obsList = [] for pkg in pkgList: rpmpath = pkg[7] hdrBuf = self.__getHeader(rpmpath) hdr = rpmUtils.readHeaderBlob(hdrBuf.unload()) # look for header info if not hdr['obsoletes']: continue obs = up2dateUtils.genObsoleteTupleFromHdr(hdr) if obs: self.obsList = self.obsList + obs return pkgList
def getObsoletes(self, channel, msgCallback=None, progressCallback=None): filePath = "%s/%s-obsoletes.%s" % ( self.cfg["storageDir"], channel['label'], channel['version']) globPattern = "%s/%s-obsoletes.*" % (self.cfg["storageDir"], channel['label']) if msgCallback: msgCallback("Fetching obsoletes list for %s" % channel['url']) fileHdrList = "%s/link-%s" % (self.cfg['storageDir'], channel['label']) #print "fhl: %s" % fileHdrList hdrList = rpm.readHeaderListFromFile(fileHdrList) # FIXME: since we have the package list, and the headers, we dont # have to reload the headerlist... obsList = [] total = len(hdrList) count = 0 for hdr in hdrList: if progressCallback: progressCallback(count, total) count = count + 1 # FIXME: we should share this logic somewhere... # up2dateUtils maybe? if not hdr['obsoletes']: continue obs = up2dateUtils.genObsoleteTupleFromHdr(hdr) if obs: obsList = obsList + obs # now we have the package list, convert it to xmlrpc style # presentation and dump it obsList.sort(lambda a, b: cmp(a[0], b[0])) rpmSourceUtils.saveListToDisk(obsList, filePath, globPattern) return obsList
def getObsoletes(self, channel, msgCallback=None, progressCallback=None): filePath = "%s/%s-obsoletes.%s" % (self.cfg["storageDir"], channel["label"], channel["version"]) globPattern = "%s/%s-obsoletes.*" % (self.cfg["storageDir"], channel["label"]) if msgCallback: msgCallback("Fetching obsoletes list for %s" % channel["url"]) fileHdrList = "%s/link-%s" % (self.cfg["storageDir"], channel["label"]) # print "fhl: %s" % fileHdrList hdrList = rpm.readHeaderListFromFile(fileHdrList) # FIXME: since we have the package list, and the headers, we dont # have to reload the headerlist... obsList = [] total = len(hdrList) count = 0 for hdr in hdrList: if progressCallback: progressCallback(count, total) count = count + 1 # FIXME: we should share this logic somewhere... # up2dateUtils maybe? if not hdr["obsoletes"]: continue obs = up2dateUtils.genObsoleteTupleFromHdr(hdr) if obs: obsList = obsList + obs # now we have the package list, convert it to xmlrpc style # presentation and dump it obsList.sort(lambda a, b: cmp(a[0], b[0])) rpmSourceUtils.saveListToDisk(obsList, filePath, globPattern) return obsList