summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Stelling <blubb@gentoo.org>2006-05-01 18:51:48 +0000
committerSimon Stelling <blubb@gentoo.org>2006-05-01 18:51:48 +0000
commitd0325c25afa83e66310108a0a0fe74926051a83d (patch)
treefc04419144d4e4a628a5ef8cb4769840b8dfe071 /bin/emaint
parentallow escaping in elog_base() to fix bug 131913 (diff)
downloadportage-multirepo-d0325c25afa83e66310108a0a0fe74926051a83d.tar.gz
portage-multirepo-d0325c25afa83e66310108a0a0fe74926051a83d.tar.bz2
portage-multirepo-d0325c25afa83e66310108a0a0fe74926051a83d.zip
revert my last commit except for the parts i really wanted to commit
svn path=/main/trunk/; revision=3295
Diffstat (limited to 'bin/emaint')
-rwxr-xr-xbin/emaint152
1 files changed, 3 insertions, 149 deletions
diff --git a/bin/emaint b/bin/emaint
index 8411bf26..472656bc 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -104,156 +104,10 @@ 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,
- "p.keywords" : PackageKeywordsHandler,
- "p.unmask" : PackageUnmaskHandler}
-
-#modules = {"world" : WorldHandler}
+#modules = {"world" : WorldHandler,
+# "vdbkeys": VdbKeyHandler}
+modules = {"world" : WorldHandler}
module_names = modules.keys()
module_names.sort()