mirror of
https://abf.rosa.ru/djam/urpm-tools.git
synced 2025-02-23 17:32:46 +00:00
Take versions and flags into account when calculating obsoleted packages
This commit is contained in:
parent
e2cab254a9
commit
f30470260e
1 changed files with 43 additions and 5 deletions
|
@ -127,6 +127,8 @@ def main(args):
|
|||
verfile = {}
|
||||
pkgdict = {} # hold all of them - put them in (n,a) = [(e,v,r),(e1,v1,r1)]
|
||||
obsolete = {}
|
||||
obsolete_vers = {}
|
||||
obsolete_flags = {}
|
||||
|
||||
keepnum = int(options.keep)*(-1) # the number of items to keep
|
||||
|
||||
|
@ -154,12 +156,20 @@ def main(args):
|
|||
|
||||
if options.obsolete:
|
||||
obsolete_by_pkg = hdr[rpm.RPMTAG_OBSOLETENAME]
|
||||
obsolete_by_pkg_flags = hdr[rpm.RPMTAG_OBSOLETEFLAGS]
|
||||
obsolete_by_pkg_vers = hdr[rpm.RPMTAG_OBSOLETEVERSION]
|
||||
idx=0;
|
||||
for obs in obsolete_by_pkg:
|
||||
# Do not count packages obsoleted by themselves - let's leave this for rpmlint
|
||||
if hdr['name'] != obs:
|
||||
if obs not in obsolete:
|
||||
obsolete[obs] = []
|
||||
obsolete_flags[obs] = []
|
||||
obsolete_vers[obs] = []
|
||||
obsolete[obs].append(hdr['name'])
|
||||
obsolete_vers[obs].append(obsolete_by_pkg_vers[idx])
|
||||
obsolete_flags[obs].append(obsolete_by_pkg_flags[idx])
|
||||
idx+=1
|
||||
|
||||
pkgtuple = miscutils.pkgDistTupleFromHeader(hdr)
|
||||
(n,a,e,v,r,d) = pkgtuple
|
||||
|
@ -192,14 +202,42 @@ def main(args):
|
|||
if options.obsolete:
|
||||
for (n,a) in pkgdict.keys():
|
||||
evrlist = pkgdict[(n,a)]
|
||||
idx=0
|
||||
if n in obsolete:
|
||||
for pkg in evrlist:
|
||||
(e,v,r,d) = pkg
|
||||
|
||||
# Check OBSOLETEFLAGS and OBSOLETEVERSION - do we really satisfy them?
|
||||
really_obsoleted = 0;
|
||||
oef = obsolete_flags[n][idx]
|
||||
|
||||
if obsolete_vers[n][idx].find("-") >= 0:
|
||||
(over,orel) = obsolete_vers[n][idx].split("-");
|
||||
else:
|
||||
over = obsolete_vers[n][idx]
|
||||
orel = None
|
||||
|
||||
if over.find(":") >= 0:
|
||||
(oep,over) = over.split(":");
|
||||
else:
|
||||
oep = None
|
||||
|
||||
rc = miscutils.compareEVR((e, v, r), (oep, over, orel))
|
||||
|
||||
if rc >= 1 and ((oef & rpm.RPMSENSE_GREATER) or (oef & rpm.RPMSENSE_EQUAL)):
|
||||
really_obsoleted = 1;
|
||||
if rc == 0 and (oef & rpm.RPMSENSE_EQUAL):
|
||||
really_obsoleted = 1;
|
||||
if rc <= -1 and ((oef & rpm.RPMSENSE_LESS) or (oef & rpm.RPMSENSE_EQUAL)):
|
||||
really_obsoleted = 1;
|
||||
|
||||
if really_obsoleted == 1:
|
||||
print str(verfile[(n,a,e,v,r,d)]).replace("['","").replace("']","")
|
||||
if options.verbose:
|
||||
print >> sys.stderr, str(verfile[(n,a,e,v,r,d)]).replace("['","").replace("']","") + " is obsoleted by:"
|
||||
for replacement in obsolete[n]:
|
||||
print >> sys.stderr, " " + replacement
|
||||
idx+=1
|
||||
|
||||
#if new
|
||||
if options.new:
|
||||
|
|
Loading…
Add table
Reference in a new issue