From: Fabian Groffen Date: Mon, 26 Feb 2007 21:20:23 +0000 (-0000) Subject: Merged from trunk 5981:5990 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=a21be164c431656d77fcf735565835f1dded8491;p=portage.git Merged from trunk 5981:5990 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 --- diff --git a/bin/emaint b/bin/emaint index 41f9b27b2..1b8593459 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 @@ -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 diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index c2d617d3a..970976505 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -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): diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index a03fb124c..a833f033c 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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. diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 7293b2e43..953ffdcff 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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):