Mike Fleetwood <mike.fleetwood@xxxxxxxxxxxxxx> writes: > Hi, > > I always upgrade my Fedora OS and this seems to have lead to a lot of > old entries in my yumdb for old packages from previous versions of > Fedora, which take quite a bit of space. Is there anything special I > need to do to delete them or do I just use rm? > > Commands below suggest at about 3/4 of the entries are for old > packages from previous versions of Fedora. That's a lot, as this should only happen when transactions are aborted before yum runs the cleanup on delete ... try this: diff --git a/yumdb.py b/yumdb.py index 8a4888e..ac683bf 100755 --- a/yumdb.py +++ b/yumdb.py @@ -7,8 +7,24 @@ import fnmatch import yum import shlex +import os +import glob + parser = None +# FIXME: Internal knowledge +def _load_all_package_paths(db_path): + # glob the path and get a dict of pkgs to their subdir + glb = '%s/*/*/' % db_path + pkgdirs = glob.glob(glb) + _packages = {} + for d in pkgdirs: + if d[-1] == '/': + d = d[:-1] + pkgid = os.path.basename(d).split('-')[0] + _packages[pkgid] = d + return _packages + def setup_opts(): version = "0.0.1" vers_txt = "Manage yum groups metadata version %s" % version @@ -183,6 +199,14 @@ def run_cmd(yb, args, inshell=False): if ykey not in ndata: continue print " " * 4, ykey, '=', getattr(pkg.yumdb_info, ykey) + elif args[0] == 'extra': + yumdb_packages = _load_all_package_paths(yb.rpmdb.yumdb.conf.db_path) + for pkg in sorted(yb.rpmdb.returnPackages()): + if pkg.pkgid in yumdb_packages: + del yumdb_packages[pkg.pkgid] + for pkgid in yumdb_packages: + print "%s: %s" % (pkgid, yumdb_packages[pkgid]) + elif args[0] == 'shell' and not inshell: args.pop(0) if args: ...those dirs. should be safe to just delete (rm -rf), we can look at doing something to make it a bit easier. -- James Antill -- james@xxxxxxx _______________________________________________ Yum mailing list Yum@xxxxxxxxxxxxxxxxx http://lists.baseurl.org/mailman/listinfo/yum