diff options
author | 2008-06-02 21:24:20 +0530 | |
---|---|---|
committer | 2008-06-02 21:25:21 +0530 | |
commit | 4388b6b29c50eef740551c069998cda6e89f1b8b (patch) | |
tree | ccf9ffd78306a2556870b661c2c3d83a604a3199 | |
parent | gnome2-user-docs has been renamed to gnome-user-docs in-tree to match upstream (diff) | |
download | gentoo-bumpchecker-4388b6b29c50eef740551c069998cda6e89f1b8b.tar.gz gentoo-bumpchecker-4388b6b29c50eef740551c069998cda6e89f1b8b.tar.bz2 gentoo-bumpchecker-4388b6b29c50eef740551c069998cda6e89f1b8b.zip |
Provide finer-grained control over scanning of overlays
* By default, no overlay is scanned
* --all-overlays can be used to scan all overlays in addition to PORTDIR
(current behaviour)
* -a/--overlay can be used to specify one overlay (or more than one if
specified multiple times)
-rwxr-xr-x | gentoo-bumpchecker.py | 5 | ||||
-rw-r--r-- | modules/clioptions_module.py | 7 | ||||
-rw-r--r-- | modules/portage_module.py | 36 |
3 files changed, 38 insertions, 10 deletions
diff --git a/gentoo-bumpchecker.py b/gentoo-bumpchecker.py index 19c307b..609e677 100755 --- a/gentoo-bumpchecker.py +++ b/gentoo-bumpchecker.py @@ -33,7 +33,10 @@ if __name__ == '__main__': # we need a list of package names to check for, so we choose # to use the release_packages list. import portage_module - packages_in_portage = portage_module.find_packages_in_tree(release_packages) + packages_in_portage = \ + portage_module.find_packages_in_tree(release_packages, \ + options.get_arguments().all_overlays, \ + options.get_arguments().overlays) # compare the versions in order to check if we are up to date. comparison_result_packages = gnome_module.compare_packages(release_packages, \ diff --git a/modules/clioptions_module.py b/modules/clioptions_module.py index 4602c20..4f3046b 100644 --- a/modules/clioptions_module.py +++ b/modules/clioptions_module.py @@ -27,6 +27,13 @@ class Options: self.parser.add_option("-n", "--nextrev", action="store_true", dest="nextrev", default=False, help="Check for a minor revision newer than the given one") + self.parser.add_option("--all-overlays", + action="store_true", dest="all_overlays", + default=False, + help="Scan all available overlays in addition to PORTDIR.") + self.parser.add_option("-a", "--overlay", metavar="OVERLAY", + action="append", dest="overlays", default=None, + help="Overlay to scan in addition to PORTDIR. Specify multiple times to scan more than one overlay.") def get_arguments(self): if (self.options.release_number == None): diff --git a/modules/portage_module.py b/modules/portage_module.py index 40f134b..dcd44e2 100644 --- a/modules/portage_module.py +++ b/modules/portage_module.py @@ -53,30 +53,48 @@ def best_version_test(package1,package2): # grabbing this from portageq, best to put it in here instead of # having the overhead of calling it each time and getting the output. -def find_latest_package_in_tree(package_name): +def find_latest_package_in_tree(package_name, portdb=None): try: - mylist=portage.db["/"][get_dbtree()].dbapi.match(package_name) + if portdb is None: + portdb = portage.db['/'][get_dbtree()] + + mylist = portdb.dbapi.match(package_name) + return portage.best(mylist) except KeyError: return None -# finds the latest available version of a package using all available overlays -def find_packages_in_tree(package_list): +# finds the latest available version of a package +def find_packages_in_tree(package_list, all_overlays=False, overlay_list=None): # this value needs to be configurable from cl #overlays = ["/home/allanon/cvs/gnome"] portage_versions = [] - #for overlay in overlays: - #os.environ["PORTDIR_OVERLAY"]=overlay - #reload(portage) + portdb = portage.db['/'][get_dbtree()] + + if all_overlays is False: + # Prune list of trees to be scanned + oldporttrees = portdb.dbapi.porttrees + portdb.dbapi.porttrees = [os.path.realpath(portdb.settings['PORTDIR'])] + + # Now append the overlays we want. First resolve to absolute paths. + if overlay_list is not None: + portdb.dbapi.porttrees += \ + [ os.path.realpath(overlay) for overlay in overlay_list ] + for package in package_list: - best_package = find_latest_package_in_tree(package.name) - + best_package = find_latest_package_in_tree(package.name, portdb) + # if it returns a package, hardcode to first result. # cover the case where it doesn't exist in the tree. if None != best_package and "" != best_package: + # Need to account for slotted packages here portage_versions.append(package_module.Package(best_package)) + # Restore portdb trees list + if all_overlays is False: + portdb.dbapi.porttrees = oldporttrees + return portage_versions def tests(): |