]> Frank Brehm's Git Trees - scripts/root-bin.git/commitdiff
First checks of package.keywords against packages.
authorFrank Brehm <frank@brehm-online.com>
Thu, 5 Mar 2015 06:58:54 +0000 (07:58 +0100)
committerFrank Brehm <frank@brehm-online.com>
Thu, 5 Mar 2015 06:58:54 +0000 (07:58 +0100)
cleanup-pkg-keywords

index 85007c87d8d015205d9c30345df1973bf1953a30..0f994b37f695269a1eea3c089c3ab03b5f4a4a41 100755 (executable)
@@ -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__":