allow escaping in elog_base() to fix bug 131913
authorSimon Stelling <blubb@gentoo.org>
Mon, 1 May 2006 18:34:37 +0000 (18:34 -0000)
committerSimon Stelling <blubb@gentoo.org>
Mon, 1 May 2006 18:34:37 +0000 (18:34 -0000)
svn path=/main/trunk/; revision=3294

bin/emaint
bin/isolated-functions.sh
bin/repoman

index 472656bc78c6d3fc69153db349fee97363898e12..8411bf267e4051a549a167103e1a1e9b2dd8c65d 100755 (executable)
@@ -104,10 +104,156 @@ class VdbKeyHandler(object):
                
                return errors
 
+           
+
+def checkDict(dict):
+    noneInstalled = []
+    noneAffected  = []
+
+    # iterate over all entries in the dict
+    for entry_cp in dict.keys():
+        # find installed packages of type entry
+        iPkgs = portage.vardbapi(portage.root).match(entry_cp)
+
+       # check if packages are installed
+        if not len(iPkgs):
+            noneInstalled.append(", ".join(dict[entry_cp]))
+            continue
+
+        count = 0
+        # now check for every installed package, if it is hit by the entry
+        for i in iPkgs:
+            count += len(portage.match_to_list(i, dict[entry_cp]))
+            if count > 0:
+                break;
+        if count == 0:
+            noneAffected.append(", ".join(dict[entry_cp]))
+            continue
+
+        #check if there are entries in the file, that didn't match
+        #ie: package.keywords contains "=kde-base/kde-3.0.0 ... and =kde-base/kde-2.0.0 ..."
+        # now if kde-4.0.0 is installed, kde-3.0.0 is still not recognized as redundant, as it
+        # gives a match and count > 0.
+        #solution: do the check again for single entries like "=*" and "~*"
+        if len(dict[entry_cp]) > 1:
+            for x in dict[entry_cp]:
+               if x[0] == "=" or x[0] == "~":
+                    count = 0
+                    # now check for every installed package, if it is hit by the entry
+                    for i in iPkgs:
+                        count += len(portage.match_to_list(i, [x]))
+                       if count > 0:
+                           break
+                    if count == 0:        
+                       noneAffected.append(x)
+
+    return (noneInstalled, noneAffected)
+
+def fixFile(fileName, noneInstalled, noneAffected):
+    errors = []
+    strNoneInstalled = "NONE INSTALLED"
+    strNoneAffected = "NONE AFFECTED"
+    try:
+       ifile = open(fileName)
+       lines = ifile.readlines()
+       ifile.close()
+       
+       ofile = open(fileName, "w")
+       
+       # now check every line if it contains a problematic entry
+       for line in lines:
+           prefix = ""
+           for x in noneInstalled:
+               if line.find(x) >= 0:
+                   prefix += strNoneInstalled
+           for x in noneAffected:
+               if line.find(x) >= 0:
+                   prefix += strNoneAffected
+
+           if prefix:
+               prefix = "# "+prefix+" "
+               errors.append("fixed: " + prefix + line.strip()) #remove \n
+               
+           ofile.write(prefix+line)
+
+       ofile.close()
+
+    except OSError:
+       errors.append(fileName + " could not be opened for reading or writing")
+
+    return errors
+
+
+class PackageKeywordsHandler(object):
+
+    def name():
+        return "p.keywords"
+    name = staticmethod(name)
+
+
+    def __init__(self):
+        print "init"
+        self.noneInstalled = []
+        self.noneAffected  = []
+
+        # cache the config object
+        cfg = portage.config(config_profile_path=portage.root, config_incrementals=portage_const.INCREMENTALS)
+
+        #transforming the format of pkeywordsdict into something like punmaskdict i.e. key : [entry1, entry2, ...], key : [...
+        dict = {}
+        for k, v in cfg.pkeywordsdict.items():
+            t = []
+            for k2, v2 in v.items():
+                t.append(k2)
+            dict[k] = t
+
+        (self.noneInstalled , self.noneAffected) = checkDict( dict )
+
+    def check(self):
+        errors = []
+        errors += map(lambda x: "'%s' has no installed packages" % x, self.noneInstalled)
+        errors += map(lambda x: "'%s' affects no installed package(-version)" % x, self.noneAffected)
+        return errors
+
+    def fix(self):
+       return fixFile("/etc/portage/package.keywords", self.noneInstalled, self.noneAffected)
+
+
+class PackageUnmaskHandler(object):
+
+    def name():
+        return "p.unmask"
+    name = staticmethod(name)
+
+    def __init__(self):
+        print "init"
+        self.noneInstalled = []
+        self.noneAffected  = []
+
+        # cache the config object
+        cfg = portage.config(config_profile_path=portage.root, config_incrementals=portage_const.INCREMENTALS)
+
+        (self.noneInstalled , self.noneAffected) = checkDict( cfg.punmaskdict )
+
+    def check(self):
+        errors = []
+        errors += map(lambda x: "'%s' has no installed packages" % x, self.noneInstalled)
+        errors += map(lambda x: "'%s' affects no installed package(-version)" % x, self.noneAffected)
+        return errors
+
+    def fix(self):
+       return fixFile("/etc/portage/package.unmask", self.noneInstalled, self.noneAffected)
+
+    
+           
+
 # this sucks, should track this in a different manner.
-#modules = {"world" : WorldHandler,
-#                 "vdbkeys": VdbKeyHandler}
-modules = {"world" : WorldHandler}
+modules = {"world" : WorldHandler,
+                  "vdbkeys": VdbKeyHandler,
+                  "p.keywords" : PackageKeywordsHandler, 
+                  "p.unmask" : PackageUnmaskHandler}
+                  
+#modules = {"world" : WorldHandler}
 
 module_names = modules.keys()
 module_names.sort()
index 40b846eb0289da63f821eb40c6ace33bbf5517b5..3d3b93741232939edcfe61c141560b7b92f5a356 100644 (file)
@@ -16,7 +16,7 @@ elog_base() {
                        return 1
                        ;;
        esac
-       echo "$*" >> ${T}/logging/${EBUILD_PHASE:-other}.${messagetype}
+       echo -e "$*" >> ${T}/logging/${EBUILD_PHASE:-other}.${messagetype}
        return 0
 }
 
index a6bbd8fa2abaf67557a28522c6e42b7f9d67d416..e91169f293b827923039b647cdd8cf7a691ce62a 100755 (executable)
@@ -1074,10 +1074,10 @@ for x in scanlist:
                badlicsyntax = badlicsyntax > 0
                badprovsyntax = badprovsyntax > 0
 
-               if not baddepsyntax:
-                       if x11_deprecation_check(" ".join([myaux["DEPEND"], myaux["RDEPEND"], myaux["PDEPEND"]])):
-                               stats["usage.obsolete"] += 1
-                               fails["usage.obsolete"].append("%s/%s.ebuild: not migrated to modular X" % (x, y))
+#              if not baddepsyntax:
+#                      if x11_deprecation_check(" ".join([myaux["DEPEND"], myaux["RDEPEND"], myaux["PDEPEND"]])):
+#                              stats["usage.obsolete"] += 1
+#                              fails["usage.obsolete"].append("%s/%s.ebuild: not migrated to modular X" % (x, y))
 
                for keyword,arch,groups in arches: