From: Frank Brehm Date: Thu, 5 Mar 2015 06:58:54 +0000 (+0100) Subject: First checks of package.keywords against packages. X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=4ed75f9b1fe71380d99f944fbfcac02eb54bf98d;p=scripts%2Froot-bin.git First checks of package.keywords against packages. --- diff --git a/cleanup-pkg-keywords b/cleanup-pkg-keywords index 85007c8..0f994b3 100755 --- a/cleanup-pkg-keywords +++ b/cleanup-pkg-keywords @@ -14,6 +14,7 @@ import sys import os import re import logging +import glob from distutils.version import LooseVersion @@ -26,7 +27,7 @@ from portage.dep import isjustname from pb_base.app import PbApplicationError from pb_base.app import PbApplication -__version__ = LooseVersion('0.3.0') +__version__ = LooseVersion('0.4.0') appname = os.path.basename(sys.argv[0]) log = logging.getLogger(appname) @@ -211,15 +212,22 @@ class CleanupPkgKeywordsApp(PbApplication): 'Invalid Package name %r in %r (%d) found.', mypkg, filename, line_nr) continue + valid = None if isjustname(my_cpv): - self.check_package(my_cpv, my_slot, None, None, my_operator) + valid = self.check_package(my_cpv, my_slot, None, None, my_operator) else: splitted = pkgsplit(my_cpv) if self.verbose > 2: log.debug("Splitted CPV: %r", splitted) - self.check_package( + valid = self.check_package( splitted[0], my_slot, splitted[1], splitted[2], my_operator) + if valid: + log.info("Atom %r in %r (%d) seems to be valid.", mypkg, + filename, line_nr) + else: + log.warning("Atom %r in %r (%d) seems to be invalid.", mypkg, + filename, line_nr) # ------------------------------------------------------------------------- def check_package(self, package, slot, version, release, operator): @@ -228,6 +236,14 @@ class CleanupPkgKeywordsApp(PbApplication): "Checking package %r, slot %r, version %r, release: %r, operator %r ...", package, slot, version, release, operator) + pkg_dirs_glob = os.path.join(self.pkg_dir, package + '-[0-9]*') + pkg_dirs = glob.glob(pkg_dirs_glob) + if not pkg_dirs: + log.info("Package %r seems not to be installed.", package) + return False + + return True + # ============================================================================= if __name__ == "__main__":