I wrote a quick python hack to look for any current packages that obsolete any 
other current package. I've included it at the end of this email. 
Unfortunately, I think it would take just about forever for me to run it 
(~5000 urpmf calls). Anyone who can run it faster, I'll be your best friend 
and love you forever and ever and all that stuff....

You'll probably have to change line 6 (where I set urpmflags to select the 
right media), but that's about it. Oh, and ignore the tmpnam warnings; 
there's no other good alternative without python-expect or -pexpect. Just 
don't run two copies at once.

Also, I have a few questions:

1. Is there a faster way to do this than running urpmf ~5000 times?

2. Does running urpmf ~5000 times go out to the internet ~5000 times?

3. Would it help if I did this in perl (because we have a perl-URPM but not a 
python-URPM)?

4. Would anyone besides me want a python-URPM? (This would obviously take some 
time, but I'd be happy to look into it.)

5. Is there actually no python-expect or python-pexpect? Would anyone besides 
me want it? (This would take a few minutes.) 

6. While I'm at it, does anyone want any other python packages? For my own 
use, I've packaged up 
python-{rational,cRat,fpconst,indices,xoltar,xzip,Itpl,logging} and would be 
happy to share them (or, for that matter, describe them) if there's any 
potential interest. I'd be happy to similarly package up any common python 
modules....

--- CUT HERE ---
#!/usr/bin/env python

import sys
import os

urpmflags = "--media main-cooker,contrib-cooker"

def readfile(fname):
    return file(fname).readlines()

print "Getting list of packages...",
pkgsfname = os.tmpnam()
os.system("urpmq %s --list >%s" % (urpmflags, pkgsfname))
pkgs = readfile(pkgsfname)
pkgcount = len(pkgs)
print pkgcount

obsoletes = []
provides = {}
print "This may take a while..."
pkgfname = os.tmpnam()
for i in range(pkgcount):
    pkg = pkgs[i]
    print "\rprocessing #%4d/%4d: %s..." % (i, pkgcount, pkg),
    os.system("urpmf %s --provides --obsoletes %s > %s" % (urpmflags, 
pkg.strip(), pkgfname))
    provobs = readfile(pkgfname)
    for line in provobs:
        ptv = line.strip().split(':')
        if len(ptv) == 3:
            package, tag, virtual = ptv
            if tag == 'obsoletes':
                obsoletes.append([virtual, package])
            elif tag == 'provides':
                if not provides.has_key(virtual):
                    provides[virtual] = []
                    provides[virtual].append(package)

print "\r",
for obsolete in obsoletes:
    virtual, pkgo = obsolete
    if provides.has_key(virtual):
        for pkgp in provides[virtual]:
            if pkgp != pkgo:
                print "%s obsoletes %s, provided by %s" % (pkgo, virtual, 
pkgp)
print "And there you go...."


Reply via email to