diff options
author | Chris Lumens <clumens@redhat.com> | 2007-02-08 16:03:02 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2007-02-08 16:03:02 +0000 |
commit | e3d02f6d3ae5d6ec1fb3844f16b00c076884e048 (patch) | |
tree | 83d4a8467ca6e6edf7580b9e18e73c96884c7001 | |
parent | 134fa2991c66b32945bb20700666cce236a5bc36 (diff) | |
download | anaconda-e3d02f6d3ae5d6ec1fb3844f16b00c076884e048.tar.gz anaconda-e3d02f6d3ae5d6ec1fb3844f16b00c076884e048.tar.xz anaconda-e3d02f6d3ae5d6ec1fb3844f16b00c076884e048.zip |
Remove unused files.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | findpackageset.py | 223 | ||||
-rw-r--r-- | genheader.py | 150 |
3 files changed, 6 insertions, 373 deletions
@@ -1,3 +1,9 @@ +2007-02-08 Chris Lumens <clumens@redhat.com> + + * findpackageset.py, genheader.py: Removed. + + * po/*: Update translation files (#227775). + 2007-02-07 Chris Lumens <clumens@redhat.com> * anaconda.spec: Static glib libraries have moved. diff --git a/findpackageset.py b/findpackageset.py deleted file mode 100644 index bb21691a4..000000000 --- a/findpackageset.py +++ /dev/null @@ -1,223 +0,0 @@ -import rpm -import rhpl.arch -import string -import types -from constants import * - -# set DB_PRIVATE to make rpm happy -rpm.addMacro("__dbi_cdb", "create private mpool mp_mmapsize=16Mb mp_size=1Mb") - - -def dEBUG(str): - print str - -def addNewPackageToUpgSet(pkgDict, pkg): - """Check to see if there's already a pkg by the name of pkg already - in our dictionary. If not, add this one. If there is, see if - this one is 'newer' or has a 'better' arch.""" - name = pkg[rpm.RPMTAG_NAME] - arch = pkg[rpm.RPMTAG_ARCH] - if not pkgDict.has_key((name, arch)): - # nope - pkgDict[(name,arch)] = pkg - else: - # first check version - val = rpm.versionCompare(pkgDict[(name,arch)], pkg) - if val < 0: - # we're newer, add this one - pkgDict[(name,arch)] = pkg - -def comparePackageForUpgrade(updDict, h, pkg): - val = rpm.versionCompare(h, pkg) - if (val > 0): -# dEBUG("found older version of %(name)s %(arch)s" % h) - pass - elif (val < 0): -# dEBUG("found newer version of %(name)s %(arch)s" % h) - # check if we already have this package in our dictionary - addNewPackageToUpgSet(updDict, pkg) - else: -# dEBUG("found same verison of %(name)s %(arch)s" % h) - pass - -def findBestArch(archlist): - bestarch = None - for availarch in archlist: - newscore = rhpl.arch.score(availarch) - # unsupported - if newscore <= 0: - continue - # If old arch is better or same - if bestarch and rhpl.arch.score(bestarch) <= newscore: - continue - - # If we get here we're better - bestarch = availarch - return bestarch - -def getAvailPackages(hdrlist): - # go through and figure out which packages in the header list are - # actually applicable for our architecture - pkgDict = {} - nameDict = {} - for h in hdrlist: - score1 = rhpl.arch.score(h[rpm.RPMTAG_ARCH]) - if (score1): - name = h[rpm.RPMTAG_NAME] - arch = h[rpm.RPMTAG_ARCH] - pkgDict[(name,arch)] = h - if nameDict.has_key(name): - nameDict[name].append(arch) - else: - nameDict[name] = [ arch ] - return (pkgDict, nameDict) - -def getInstalledPackages(dbPath='/'): - pkgDict = {} - nameDict = {} - ts = rpm.TransactionSet(dbPath) - ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA|rpm.RPMVSF_NOMD5)) - mi = ts.dbMatch() - for h in mi: - name = h[rpm.RPMTAG_NAME] - arch = h[rpm.RPMTAG_ARCH] - pkgDict[(name,arch)] = h - if nameDict.has_key(name): - nameDict[name].append(arch) - else: - nameDict[name] = [ arch ] - return (pkgDict, nameDict) - -def findpackageset(hdrlist, dbPath='/'): - instDict = {} - availDict = {} - updDict = {} - - # dicts for name : [archlist] - availNames = {} - instNames = {} - - ts = rpm.TransactionSet(dbPath) - ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA|rpm.RPMVSF_NOMD5)) - - (availDict, availNames) = getAvailPackages(hdrlist) - (instDict, instNames) = getInstalledPackages(dbPath=dbPath) - - hdlist = availDict.values() - - # loop through packages and find ones which are a newer - # version than what we have - for ( name, arch ) in instDict.keys(): - if ( name, arch ) in availDict.keys(): - # Exact arch upgrade - h = instDict[(name, arch)] - pkg = availDict[(name,arch)] - comparePackageForUpgrade(updDict, h, pkg) - else: - # See if we have a better arch than that installed - if name in availNames.keys(): - bestarch = findBestArch(availNames[name]) - if not bestarch: - continue - if availDict.has_key((name,bestarch)): - h = instDict[(name,arch)] - pkg = availDict[(name,bestarch)] - comparePackageForUpgrade(updDict, h, pkg) - - # handle obsoletes - for pkg in hdlist: - if (pkg[rpm.RPMTAG_NAME],pkg[rpm.RPMTAG_ARCH]) in updDict.keys(): -# dEBUG("%(name)s %(arch)s is already selected" % pkg) - continue - - if pkg[rpm.RPMTAG_OBSOLETENAME] is not None: - name = pkg[rpm.RPMTAG_NAME] - arch = pkg[rpm.RPMTAG_ARCH] - for obs,obsver in zip(pkg[rpm.RPMTAG_OBSOLETENAME],pkg[rpm.RPMTAG_OBSOLETEVERSION]): - mi = ts.dbMatch('name', obs) - oevr = strToVersion(obsver) - for h in mi: - if not obsver: -# unversioned obsoletes win - addNewPackageToUpgSet(updDict, pkg) -# dEBUG("adding %(name)s to the upgrade set for obsoletes" % pkg) - break - else: - if h[rpm.RPMTAG_EPOCH] is None: - epoch = '0' - else: - epoch = str(h[rpm.RPMTAG_EPOCH]) - val = compareEVR(oevr,(epoch,h[rpm.RPMTAG_VERSION],h[rpm.RPMTAG_RELEASE])) - if val > 0: -# dEBUG("adding %(name)s %(version)s to the upgrade set for obsoletes" % pkg) - updDict[(name,arch)] = pkg - break - - return updDict.values() - -def rpmOutToStr(arg): - if type(arg) != types.StringType: - # and arg is not None: - arg = str(arg) - - return arg - -def compareEVR((e1, v1, r1), (e2, v2, r2)): - # return 1: a is newer than b - # 0: a and b are the same version - # -1: b is newer than a - e1 = rpmOutToStr(e1) - v1 = rpmOutToStr(v1) - r1 = rpmOutToStr(r1) - e2 = rpmOutToStr(e2) - v2 = rpmOutToStr(v2) - r2 = rpmOutToStr(r2) - rc = rpm.labelCompare((e1, v1, r1), (e2, v2, r2)) - return rc - -def strToVersion(str): - """Parse a string such as in obsoleteversion into evr. - Gratuitously borrowed from yum str_to_version - FIXME: should be implemented in and use rpmUtils""" - i = string.find(str, ':') - if i != -1: - epoch = string.atol(str[:i]) - else: - epoch = '0' - j = string.find(str, '-') - if j != -1: - if str[i + 1:j] == '': - version = None - else: version = str[i + 1:j] - 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] - diff --git a/genheader.py b/genheader.py deleted file mode 100644 index 128f526da..000000000 --- a/genheader.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/python - -import os -from struct import * -import rpm -import copy - -# Types -RPM_NULL = 0 -RPM_CHAR = 1 -RPM_INT8 = 2 -RPM_INT16 = 3 -RPM_INT32 = 4 -RPM_INT64 = 5 # Unused currently -RPM_STRING = 6 -RPM_BIN = 7 -RPM_STRING_ARRAY = 8 -RPM_I18NSTRING = 9 - -stringTypes = [ RPM_STRING, RPM_STRING_ARRAY, RPM_I18NSTRING ] - -formatTable = { - RPM_CHAR : "!c", - RPM_INT8 : "!B", - RPM_INT16 : "!H", - RPM_INT32 : "!I", - RPM_INT64 : "!Q", - RPM_STRING : "s", - RPM_BIN : "s", - RPM_STRING_ARRAY : "s", - RPM_I18NSTRING : "s" -} - -senseTable = { - "EQ": rpm.RPMSENSE_EQUAL, - "LT": rpm.RPMSENSE_LESS, - "GT": rpm.RPMSENSE_GREATER, - "LE": rpm.RPMSENSE_EQUAL | rpm.RPMSENSE_LESS, - "GE": rpm.RPMSENSE_EQUAL | rpm.RPMSENSE_GREATER -} - -class YumHeader: - def __init__(self,po): - """Partial and dumbed down header generation for cd installation - @param po - @type po: PackageObject""" - self.po = po - self.store = "" - self.offset = 0 - self.indexes = [] - self.tagtbl = { - 'os': (rpm.RPMTAG_OS, RPM_STRING), - 'name': (rpm.RPMTAG_NAME, RPM_STRING), - 'epoch': (rpm.RPMTAG_EPOCH, RPM_INT32), - 'version': (rpm.RPMTAG_VERSION, RPM_STRING), - 'release': (rpm.RPMTAG_RELEASE, RPM_STRING), - 'arch': (rpm.RPMTAG_ARCH, RPM_STRING), - 'summary': (1004, RPM_STRING), - 'description': (1005, RPM_STRING), - 'providename': (rpm.RPMTAG_PROVIDENAME, RPM_STRING_ARRAY), - 'provideversion': (rpm.RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY), - 'provideflags': (rpm.RPMTAG_PROVIDEFLAGS, RPM_STRING_ARRAY) - } - if 'epoch' in self.po.simpleItems(): - self.po.simple['epoch'] = int(self.po.simple['epoch']) - - def __format(self, tag, tagtype, value): - if not isinstance(value, (tuple, list)): - return self.__formatSingle(tag, tagtype, value) - else: - count = len(value) - data = "" - for entry in value: - (entrycount, entrydata) = self.__formatSingle(tag, tagtype, value) - data += entrydata - return (count, data) - - def __formatSingle(self, tag, tagtype, value): - format = formatTable[tagtype] - count = 1 - if tagtype == RPM_BIN: - format = "%%d%s" % format - count = len(value) - data = pack(format % (count, value)) - elif tagtype in stringTypes: - # Null terminate - data = pack("%ds" % (len(value) + 1), value) - else: - data = pack(format, value) - return (count, data) - - def __alignTag(self, tagtype): - """Return alignment data for aligning for ttype from offset - self.offset.""" - if tagtype == RPM_INT16: - align = (2 - (self.offset % 2)) % 2 - elif tagtype == RPM_INT32: - align = (4 - (self.offset % 4)) % 4 - elif tagtype == RPM_INT64: - align = (8 - (self.offset % 8)) % 8 - else: - align = 0 - return '\x00' * align - - def convertTag(self, tag): - if self.tagtbl.has_key(tag): - (rpmtag, tagtype) = self.tagtbl[tag] - self.addTag(rpmtag, tagtype, self.po.returnSimple(tag)) - - def addTag(self, rpmtag, tagtype, value): - (count, data) = self.__format(rpmtag, tagtype, value) - pad = self.__alignTag(tagtype) - self.offset += len(pad) - self.indexes.append((rpmtag, tagtype,self.offset, count)) - self.store += pad + data - self.offset += len(data) - - def mungEpoch(self): - epoch = self.po.returnSimple('epoch') - (rpmtag, tagtype) = self.tagtbl['epoch'] - if epoch is not None: - self.addTag(rpmtag, tagtype, int(epoch)) - - def generateProvides(self): - self.po.simple['provideversion'] = [ "%s-%s" % (self.po.returnSimple('version'), self.po.returnSimple('release')) ] - self.po.simple['providename'] = [self.po.returnSimple['name']] - self.po.simple['provideversion'] = [ "%s-%s" % (self.po.returnSimple('version'), self.po.returnSimple('release')) ] - self.po.returnSimple['provideflags'] = [senseTable["EQ"]] - self.convertTag('providename') - self.convertTag('provideversion') - self.convertTag('provideflags') - self.convertTag('provideflags') - - def str(self): - self.po.simple['os'] = 'linux' - self.convertTag('os') - for tag in ['name','version', 'release', 'arch', 'summary', 'description']: - if tag in self.po.simpleItems(): - self.convertTag(tag) - self.mungEpoch() - - magic = '\x8e\xad\xe8' - hdr_start_fmt= '!3sB4xii' - index_fmt = '!4I' - version = 1 - hdr = pack(hdr_start_fmt, magic, version, len(self.indexes), len(self.store)) - for (tag, tagtype, offset, count) in self.indexes: - hdr += pack(index_fmt, tag, tagtype, offset, count) - hdr += self.store - return hdr |