summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Stelling <blubb@gentoo.org>2006-05-01 18:34:37 +0000
committerSimon Stelling <blubb@gentoo.org>2006-05-01 18:34:37 +0000
commitcf4a8d3da43c1f2bd5986bedcf22c76b1ad7fb9b (patch)
treefcc31dde27d8fa323d448a4f790a261620c027cf /bin/emaint
parentDon't skip regenerate() because leads to 'Problem resolving dependencies' fro... (diff)
downloadportage-multirepo-cf4a8d3da43c1f2bd5986bedcf22c76b1ad7fb9b.tar.gz
portage-multirepo-cf4a8d3da43c1f2bd5986bedcf22c76b1ad7fb9b.tar.bz2
portage-multirepo-cf4a8d3da43c1f2bd5986bedcf22c76b1ad7fb9b.zip
allow escaping in elog_base() to fix bug 131913
svn path=/main/trunk/; revision=3294
Diffstat (limited to 'bin/emaint')
-rwxr-xr-xbin/emaint152
1 files changed, 149 insertions, 3 deletions
diff --git a/bin/emaint b/bin/emaint
index 472656bc..8411bf26 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -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()