#!/usr/bin/python -t # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import os import sys import yum import yum.Errors from yum.misc import getCacheDir from optparse import OptionParser from rpmUtils.miscutils import compareEVR def parseArgs(): usage = "usage: %s [-c ] [-a ] [-r ] [-r ]" % sys.argv[0] parser = OptionParser(usage=usage) parser.add_option("-c", "--config", default='/etc/yum.conf', help='config file to use (defaults to /etc/yum.conf)') parser.add_option("-t", "--tempcache", default=False, action="store_true", help="Use a temp dir for storing/accessing yum-cache") parser.add_option("-d", "--cachedir", default='', help="specify a custom directory for storing/accessing yum-cache") parser.add_option("-q", "--quiet", default=0, action="store_true", help="quiet (no output to stderr)") (opts, args) = parser.parse_args() return (opts, args) class MySolver(yum.YumBase): def __init__(self, arch = None, config = "/etc/yum.conf"): yum.YumBase.__init__(self) self.arch = arch self.doConfigSetup(fn = config) if hasattr(self.repos, 'sqlite'): self.repos.sqlite = False self.repos._selectSackType() def readMetadata(self): self.doRepoSetup() self.doSackSetup(("src", )) for repo in self.repos.listEnabled(): self.repos.populateSack(which=[repo.id], with='filelists') def log(self, value, msg): pass def evrstr(evr): return evr and "%s:%s-%s" % evr or "(missing)" def main(): (opts, cruft) = parseArgs() dists = ('3', '4', '5', '6') solvers = {} for dist in dists: solver = MySolver(config = opts.config) for repo in solver.repos.repos.values(): if repo.id not in ("extras-%s-source" % dist, ): repo.disable() else: repo.enable() solvers[dist] = solver if os.geteuid() != 0 or opts.tempcache or opts.cachedir != '': if opts.cachedir != '': cachedir = opts.cachedir else: cachedir = getCacheDir() if cachedir is None: print "Error: Could not make cachedir, exiting" sys.exit(50) for repo in solvers.values(): repo.repos.setCacheDir(cachedir) if not opts.quiet: print 'Reading in repository metadata - please wait....' try: for repo in solvers.values(): repo.readMetadata() except yum.Errors.RepoError, e: print 'Filelists not available for repo: %s' % repo print 'Some dependencies may not be complete for this repository' print 'Run as root to get all dependencies or use -t to enable a user temp cache' pkgdict = {'3':{}, '4':{}, '5':{}, '6':{}, } allnames = [] for dist in dists: for l in solvers[dist].pkgSack.returnNewestByName(): for pkg in l: allnames.append(pkg.name) pkgdict[dist][pkg.name] = (pkg.epoch, pkg.version, pkg.release) allnames = sorted(set(allnames)) for name in allnames: evrs = map(lambda x: pkgdict[x].get(name), dists) last = None # last seen EVR bork = None # index of first repo w/ problem ix = 0 for evr in evrs: if not evr: # missing pass # TODO: detect holes in continuum elif last is None: # first one seen last = evr elif compareEVR(last, evr) > 0: # versioning problem bork = ix - 1 break ix = ix + 1 if bork is not None: ix = bork print name + ":" for evr in evrs[ix:]: # onwards from the problem spot print " %s: %s" % (dists[ix], evrstr(evr)) ix = ix + 1 print if __name__ == "__main__": main()