#!/usr/bin/env python # # Search for packages that have become # stable since their installation as unstable ones. # # Copyright (c) 2006 Johannes Weiner # # This program is free software; you can modify and redistribute it # under the terms of the GNU General Public License version 2. # import sys sys.path.insert(0, "/usr/lib/portage/pym") from portage import catpkgsplit, settings, portdb, best, \ vartree, getmaskingstatus, flatten from output import green, bold def notice(text): print green(" *"), text def first(obj): """ Extract the first scalar out of a nested list""" if type(obj) == list: return first(obj.pop(0)) return obj # Get a list of all installed packages and # a list of all overrides in package.keywords. vtree = vartree() all_installed = vtree.getallnodes() all_overrides = settings.pkeywordsdict # Get list of all possible unstable keywords unstable_keywords = flatten([['~' + arch] \ for arch in settings["PORTAGE_ARCHLIST"].split()]) # Construct a list of potential stabs by collecting all that are # a) installed and # b) unstabled via /etc/portage/package.keywords checklist = [] for tuple in all_overrides.values(): package = first(tuple.keys()) if package in all_installed: keyword = first(tuple.values()) if keyword in unstable_keywords: checklist.append(vtree.dep_bestmatch(package)) # We clear all keywords from this instance of portage and check # if the package version has a masking status. If not, the package # should have stabilized. settings.pkeywordsdict.clear() stabs = [] for pkg in checklist: if getmaskingstatus(pkg) == []: stabs.append(pkg) if len(stabs) > 0: print "" notice("I found packages that have been stabilized since your") notice("installation of them as unstable ones. If you want to") notice("switch to the stable branch of an affected package, you") notice("have to remove its entry in package.keywords.") print "" notice("If you want to keep track of the unstable branch, just") notice("ignore this warning and update your world.") print "" print " The following package have been stabilized:" print "" for pkg in stabs: notice(bold(pkg)) print "" else: notice(bold("No packages have been stabilized"))