summaryrefslogtreecommitdiffstats
path: root/bin/emaint
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-02-18 07:50:48 +0000
committerZac Medico <zmedico@gentoo.org>2007-02-18 07:50:48 +0000
commit8edcd65bff3611da80b35e13538a70620d6469e6 (patch)
tree0b835449e26665e3e5a6dcb2636d956c4c81f418 /bin/emaint
parentf9b7fbbee875834f13893f1683e7a146436f5a2a (diff)
downloadportage-8edcd65bff3611da80b35e13538a70620d6469e6.tar.gz
portage-8edcd65bff3611da80b35e13538a70620d6469e6.tar.bz2
portage-8edcd65bff3611da80b35e13538a70620d6469e6.zip
For bug #166785, check for invalid categories in the world file. (trunk r5985:5986)
svn path=/main/branches/2.1.2/; revision=5987
Diffstat (limited to 'bin/emaint')
-rwxr-xr-xbin/emaint19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/emaint b/bin/emaint
index bff6856f8..187ff773a 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -2,7 +2,8 @@
import sys, os
from optparse import OptionParser, OptionValueError
-
+if not hasattr(__builtins__, "set"):
+ from sets import Set as set
import re
try:
import portage
@@ -20,16 +21,27 @@ class WorldHandler(object):
def __init__(self):
self.invalid = []
self.not_installed = []
+ self.invalid_category = []
self.okay = []
self.world_file = os.path.join("/", portage_const.WORLD_FILE)
self.found = os.access(self.world_file, os.R_OK)
+ categories = set(portage.settings.categories)
+ myroot = portage.settings["ROOT"]
+ vardb = portage.db[myroot]["vartree"].dbapi
+
for atom in open(self.world_file).read().split():
if not portage.isvalidatom(atom):
self.invalid.append(atom)
- elif not portage.db["/"]["vartree"].dbapi.match(atom):
+ continue
+ okay = True
+ if not vardb.match(atom):
self.not_installed.append(atom)
- else:
+ okay = False
+ if portage.catsplit(atom)[0] not in categories:
+ self.invalid_category.append(atom)
+ okay = False
+ if okay:
self.okay.append(atom)
def check(self):
@@ -37,6 +49,7 @@ class WorldHandler(object):
if self.found:
errors += map(lambda x: "'%s' is not a valid atom" % x, self.invalid)
errors += map(lambda x: "'%s' is not installed" % x, self.not_installed)
+ errors += map(lambda x: "'%s' has a category that is not listed in /etc/portage/categories" % x, self.invalid_category)
else:
errors.append(self.world_file + " could not be opened for reading")
return errors