Merged from trunk 5981:5990
authorFabian Groffen <grobian@gentoo.org>
Mon, 26 Feb 2007 21:20:23 +0000 (21:20 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 26 Feb 2007 21:20:23 +0000 (21:20 -0000)
For bug #166939, make --nodeps work like a normal package for new-style
virtuals.

Remove unnecessary import that triggers DEPRECATION NOTICE.

Fix package.provided breakage from the fix for bug #166939.

For bug #166785, check for invalid categories in the world file.

For bug #163990, warn about ebuilds with invalid categories and do not
allow them to be installed.

For bug #163990, warn about binary packages with invalid categories and
do not allow them to be installed.

svn path=/main/branches/prefix/; revision=6078

bin/emaint
pym/emerge/__init__.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py

index 41f9b27b256a3524c588d7a491bdb2aac7ea7379..1b8593459a305e4e82867b3567d9a4ff12576d32 100755 (executable)
@@ -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
@@ -21,16 +22,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):
@@ -38,6 +50,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
index c2d617d3a1fb554127980d80ca502e12f7e4593a..9709765050707c0fc4f97abd3ce9d8decec7c89c 100644 (file)
@@ -35,7 +35,6 @@ from portage.const import NEWS_LIB_PATH
 
 import emerge.help
 import portage.xpak, commands, errno, re, socket, time, types
-import portage.output
 from portage.output import blue, bold, colorize, darkblue, darkgreen, darkred, green, \
        havecolor, nc_len, nocolor, red, teal, turquoise, white, xtermTitle, \
        xtermTitleReset, yellow
@@ -1522,23 +1521,31 @@ class depgraph:
                #processing dependencies
                """ Call portage.dep_check to evaluate the use? conditionals and make sure all
                dependencies are satisfiable. """
-               try:
-                       if myparent and p_status == "nomerge":
-                               portage.dep._dep_check_strict = False
-                       mycheck = portage.dep_check(depstring, None,
-                               pkgsettings, myuse=myuse,
-                               use_binaries=("--usepkgonly" in self.myopts),
-                               myroot=myroot, trees=self.trees)
-               finally:
-                       portage.dep._dep_check_strict = True
-
-               if not mycheck[0]:
-                       if myparent:
-                               show_invalid_depstring_notice(myparent, depstring, mycheck[1])
-                       else:
-                               sys.stderr.write("\n%s\n%s\n" % (depstring, mycheck[1]))
-                       return 0
-               mymerge = mycheck[1]
+               if arg:
+                       mymerge = [depstring]
+                       pprovided = pkgsettings.pprovideddict.get(
+                               portage.dep_getkey(depstring))
+                       if pprovided and portage.match_from_list(depstring, pprovided):
+                               mymerge = []
+               else:
+                       try:
+                               if myparent and p_status == "nomerge":
+                                       portage.dep._dep_check_strict = False
+                               mycheck = portage.dep_check(depstring, None,
+                                       pkgsettings, myuse=myuse,
+                                       use_binaries=("--usepkgonly" in self.myopts),
+                                       myroot=myroot, trees=self.trees)
+                       finally:
+                               portage.dep._dep_check_strict = True
+       
+                       if not mycheck[0]:
+                               if myparent:
+                                       show_invalid_depstring_notice(
+                                               myparent, depstring, mycheck[1])
+                               else:
+                                       sys.stderr.write("\n%s\n%s\n" % (depstring, mycheck[1]))
+                               return 0
+                       mymerge = mycheck[1]
 
                if not mymerge and arg and \
                        portage.best_match_to_list(depstring, self.args_keys):
index a03fb124c8a699968b3be4986bc644baea8829a1..a833f033c09a6753e9877af58a5fb42b2956e334 100644 (file)
@@ -349,6 +349,8 @@ class binarytree(object):
                if (not os.path.isdir(self.pkgdir+"/All") and not getbinpkgs):
                        return 0
 
+               categories = set(self.settings.categories)
+
                if not getbinpkgsonly:
                        pkg_paths = {}
                        dirs = listdir(self.pkgdir, dirsonly=True, EmptyOnError=True)
@@ -387,6 +389,14 @@ class binarytree(object):
                                        if mycpv in pkg_paths:
                                                # All is first, so it's preferred.
                                                continue
+                                       if mycat not in categories:
+                                               writemsg(("!!! Binary package has an " + \
+                                                       "unrecognized category: '%s'\n") % full_path,
+                                                       noiselevel=-1)
+                                               writemsg(("!!! '%s' has a category that is not" + \
+                                                       " listed in /etc/portage/categories\n") % mycpv,
+                                                       noiselevel=-1)
+                                               continue
                                        pkg_paths[mycpv] = mypath
                                        self.dbapi.cpv_inject(mycpv)
                        self._pkg_paths = pkg_paths
@@ -418,6 +428,14 @@ class binarytree(object):
                                        continue
                                mycat = self.remotepkgs[mypkg]["CATEGORY"].strip()
                                fullpkg = mycat+"/"+mypkg[:-5]
+                               if mycat not in categories:
+                                       writemsg(("!!! Remote binary package has an " + \
+                                               "unrecognized category: '%s'\n") % fullpkg,
+                                               noiselevel=-1)
+                                       writemsg(("!!! '%s' has a category that is not" + \
+                                               " listed in /etc/portage/categories\n") % fullpkg,
+                                               noiselevel=-1)
+                                       continue
                                mykey = dep_getkey(fullpkg)
                                try:
                                        # invalid tbz2's can hurt things.
index 7293b2e43bd00a9c0cf32321a7f608e284b006a8..953ffdcff349f19063447697f8c506b1d472ffb2 100644 (file)
@@ -32,7 +32,7 @@ class portdbapi(dbapi):
                else:
                        from portage import settings
                        self.mysettings = config(clone=settings)
-
+               self._categories = set(self.mysettings.categories)
                # This is strictly for use in aux_get() doebuild calls when metadata
                # is generated by the depend phase.  It's safest to use a clone for
                # this purpose because doebuild makes many changes to the config
@@ -478,6 +478,7 @@ class portdbapi(dbapi):
 
        def cp_list(self, mycp, use_cache=1, mytree=None):
                mysplit = mycp.split("/")
+               invalid_category = mysplit[0] not in self._categories
                d={}
                if mytree:
                        mytrees = [mytree]
@@ -493,6 +494,10 @@ class portdbapi(dbapi):
                                                        os.path.join(oroot, mycp, x), noiselevel=-1)
                                                continue
                                        d[mysplit[0]+"/"+pf] = None
+               if invalid_category and d:
+                       writemsg(("\n!!! '%s' has a category that is not listed in " + \
+                               "/etc/portage/categories\n") % mycp, noiselevel=-1)
+                       return []
                return d.keys()
 
        def freeze(self):