From 878f4f52332bec8afdf595435f166e32b270cc60 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 24 Oct 2007 14:01:48 +0000 Subject: [PATCH] Merged from trunk 8259:8265 | 8260 | Fix logic for the "selective" depgraph parameter so that it | | zmedico | behaves correctly in cases where installed packages provide | | | old-style virtuals but none of the available packages do. | | 8261 | Match packages against arguments earlier in | | zmedico | depgraph._select_package() so that corrupt PROVIDE is | | | detected sooner. | | 8262 | Fix selective logic to work properly with masked packages. | | zmedico | | | 8263 | remove 'system' and 'world' as actions, and remove most of | | genone | the special case code as well | | 8264 | Make world atoms non-greedy for SLOTs in action_depclean() | | zmedico | since users can simply add SLOT atoms to world for any | | | specific SLOTs that they want to keep. | | 8265 | Remove --update greedy SLOTs code from | | zmedico | depgraph.select_files() so that any desired SLOTs have to be | | | pulled in explicitly. Any SLOTs that are not explicitly | | | pulled in will be removed by --depclean. | svn path=/main/branches/prefix/; revision=8274 --- pym/_emerge/__init__.py | 261 +++++++++------------------------------- 1 file changed, 57 insertions(+), 204 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 3dfc39606..a51935d59 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -165,7 +165,7 @@ actions=[ "clean", "config", "depclean", "info", "metadata", "prune", "regen", "search", -"sync", "system", "unmerge", "world", +"sync", "unmerge", ] options=[ "--ask", "--alphabetical", @@ -1639,40 +1639,6 @@ class depgraph(object): print return False, myfavorites - if "--update" in self.myopts: - """Make sure all installed slots are updated when possible. Do this - with --emptytree also, to ensure that all slots are remerged.""" - greedy_atoms = [] - for myarg, atom in arg_atoms: - greedy_atoms.append((myarg, atom)) - mykey = portage.dep_getkey(atom) - myslots = set() - for cpv in vardb.match(mykey): - myslots.add(vardb.aux_get(cpv, ["SLOT"])[0]) - if myslots: - self._populate_filtered_repo(myroot, atom, - exclude_installed=True) - mymatches = filtered_db.match(atom) - best_pkg = portage.best(mymatches) - if best_pkg: - best_slot = filtered_db.aux_get(best_pkg, ["SLOT"])[0] - myslots.add(best_slot) - if len(myslots) > 1: - for myslot in myslots: - myslot_atom = "%s:%s" % (mykey, myslot) - self._populate_filtered_repo( - myroot, myslot_atom, - exclude_installed=True) - if filtered_db.match(myslot_atom): - greedy_atoms.append((myarg, myslot_atom)) - arg_atoms = greedy_atoms - - # Since populate_filtered_repo() was called with the - # exclude_installed flag, these atoms will need to be processed - # again in case installed packages are required to satisfy - # dependencies. - self._filtered_trees[myroot]["atoms"].clear() - oneshot = "--oneshot" in self.myopts or \ "--onlydeps" in self.myopts """ These are used inside self.create() in order to ensure packages @@ -1978,6 +1944,18 @@ class depgraph(object): usepkgonly = "--usepkgonly" in self.myopts empty = "empty" in self.myparams selective = "selective" in self.myparams + # Behavior of the "selective" parameter depends on + # whether or not a package matches an argument atom. + # If an installed package provides an old-style + # virtual that is no longer provided by an available + # package, the installed package may match an argument + # atom even though none of the available packages do. + # Therefore, "selective" logic does not consider + # whether or not an installed package matches an + # argument atom. It only considers whether or not + # available packages match argument atoms, which is + # represented by the found_available_arg flag. + found_available_arg = False for find_existing_node in True, False: if existing_node: break @@ -2007,7 +1985,18 @@ class depgraph(object): metadata["USE"] = pkgsettings.get("USE","") else: metadata["USE"] = "" + myarg = None + if root == self.target_root: + try: + myarg = self._set_atoms.findAtomForPackage( + cpv, metadata) + except portage.exception.InvalidDependString: + if not installed: + # masked by corruption + continue if not installed: + if myarg: + found_available_arg = True try: if not visible(pkgsettings, cpv, metadata, built=built, installed=installed): @@ -2090,24 +2079,18 @@ class depgraph(object): self._reinstall_for_flags( forced_flags, old_use, old_iuse, cur_use, cur_iuse) - myarg = None - if root == self.target_root: - try: - myarg = self._set_atoms.findAtomForPackage( - cpv, metadata) - except portage.exception.InvalidDependString: - # If relevant this error will be shown - # in the masked package display. - if not installed: - break - if not installed and not reinstall_for_flags and \ - ("selective" in self.myparams or \ - not myarg) and \ - not empty and \ - vardb.cpv_exists(cpv): - break - if installed and not (selective or not myarg): - break + if not installed: + must_reinstall = empty or \ + (myarg and not selective) + if not reinstall_for_flags and \ + not must_reinstall and \ + vardb.cpv_exists(cpv): + break + if installed: + must_reinstall = empty or \ + (found_available_arg and not selective) + if must_reinstall: + break # Metadata accessed above is cached internally by # each db in order to optimize visibility checks. # Now that all possible checks visibility checks @@ -2672,98 +2655,6 @@ class depgraph(object): self._altlist_cache[reversed] = retlist[:] return retlist - def xcreate(self,mode="system"): - vardb = self.trees[self.target_root]["vartree"].dbapi - filtered_db = self._filtered_trees[self.target_root]["porttree"].dbapi - world_problems = False - - root_config = self.roots[self.target_root] - world_set = root_config.settings.sets["world"] - system_set = root_config.settings.sets["system"] - mylist = list(system_set) - self._sets["system"] = system_set - if mode == "world": - self._sets["world"] = world_set - for x in world_set: - if not portage.isvalidatom(x): - world_problems = True - continue - elif not vardb.match(x): - world_problems = True - self._populate_filtered_repo(self.target_root, x, - exclude_installed=True) - if not filtered_db.match(x): - continue - mylist.append(x) - - newlist = [] - missing_atoms = [] - empty = "empty" in self.myparams - for atom in mylist: - self._populate_filtered_repo(self.target_root, atom, - exclude_installed=True) - if not filtered_db.match(atom): - if empty or not vardb.match(atom): - missing_atoms.append(atom) - continue - mykey = portage.dep_getkey(atom) - if True: - newlist.append(atom) - if mode == "system" or atom not in world_set: - # only world is greedy for slots, not system - continue - # Make sure all installed slots are updated when possible. - # Do this with --emptytree also, to ensure that all slots are - # remerged. - myslots = set() - for cpv in vardb.match(mykey): - myslots.add(vardb.aux_get(cpv, ["SLOT"])[0]) - if myslots: - self._populate_filtered_repo(self.target_root, atom, - exclude_installed=True) - mymatches = filtered_db.match(atom) - best_pkg = portage.best(mymatches) - if best_pkg: - best_slot = filtered_db.aux_get(best_pkg, ["SLOT"])[0] - myslots.add(best_slot) - if len(myslots) > 1: - for myslot in myslots: - myslot_atom = "%s:%s" % (mykey, myslot) - self._populate_filtered_repo( - self.target_root, myslot_atom, - exclude_installed=True) - if filtered_db.match(myslot_atom): - newlist.append(myslot_atom) - mylist = newlist - - for myatom in mylist: - self._set_atoms.add(myatom) - - # Since populate_filtered_repo() was called with the exclude_installed - # flag, these atoms will need to be processed again in case installed - # packages are required to satisfy dependencies. - self._filtered_trees[self.target_root]["atoms"].clear() - addme = "--onlydeps" not in self.myopts - for mydep in mylist: - if not self._select_arg(self.target_root, mydep, mydep, addme): - print >> sys.stderr, "\n\n!!! Problem resolving dependencies for", mydep - return 0 - - if not self.validate_blockers(): - return False - - if world_problems: - print >> sys.stderr, "\n!!! Problems have been detected with your world file" - print >> sys.stderr, "!!! Please run "+green("emaint --check world")+"\n" - - if missing_atoms: - print >> sys.stderr, "\n" + colorize("BAD", "!!!") + \ - " Ebuilds for the following packages are either all" - print >> sys.stderr, colorize("BAD", "!!!") + " masked or don't exist:" - print >> sys.stderr, " ".join(missing_atoms) + "\n" - - return 1 - def display(self, mylist, favorites=[], verbosity=None): if verbosity is None: verbosity = ("--quiet" in self.myopts and 1 or \ @@ -4181,13 +4072,10 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files, mysettings = portage.config(clone=settings) - if not unmerge_files or "world" in unmerge_files or \ - "system" in unmerge_files: + if not unmerge_files: if "unmerge"==unmerge_action: print - print bold("emerge unmerge") + " can only be used with " + \ - "specific package names, not with "+bold("world")+" or" - print bold("system")+" targets." + print bold("emerge unmerge") + " can only be used with specific package names" print return 0 else: @@ -4197,10 +4085,8 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files, # process all arguments and add all # valid db entries to candidate_catpkgs if global_unmerge: - if not unmerge_files or "world" in unmerge_files: + if not unmerge_files: candidate_catpkgs.extend(vartree.dbapi.cp_all()) - elif "system" in unmerge_files: - candidate_catpkgs.extend(settings.sets["system"].getAtoms()) else: #we've got command-line arguments if not unmerge_files: @@ -5402,7 +5288,7 @@ def action_regen(settings, portdb): print "done!" def action_config(settings, trees, myopts, myfiles): - if len(myfiles) != 1 or "system" in myfiles or "world" in myfiles: + if len(myfiles) != 1: print red("!!! config can only take a single package atom at this time\n") sys.exit(1) if not is_valid_package_atom(myfiles[0]): @@ -5803,25 +5689,7 @@ def action_depclean(settings, trees, ldpath_mtimes, if not arg_atom: filtered_pkgs.append(pkg) pkgs = filtered_pkgs - prune_this = False - if action == "prune": - for pkg in pkgs: - metadata = dict(izip(metadata_keys, - vardb.aux_get(pkg, metadata_keys))) - try: - arg_atom = args_set.findAtomForPackage(pkg, metadata) - except portage.exception.InvalidDependString, e: - file_path = os.path.join(myroot, VDB_PATH, pkg, "PROVIDE") - portage.writemsg("\n\nInvalid PROVIDE: %s\n" % str(s), - noiselevel=-1) - portage.writemsg("See '%s'\n" % file_path, - noiselevel=-1) - del e - continue - if arg_atom: - prune_this = True - break - if len(pkgs) > 1 and (parent != "world" or prune_this): + if len(pkgs) > 1: # Prune all but the best matching slot, since that's all that a # deep world update would pull in. Don't prune if this atom comes # directly from world though, since world atoms are greedy when @@ -6072,33 +5940,22 @@ def action_build(settings, trees, mtimedb, return os.EX_OK myparams = create_depgraph_params(myopts, myaction) - if myaction in ["system","world"]: - if "--quiet" not in myopts and "--nodeps" not in myopts: - print "Calculating",myaction,"dependencies ", - sys.stdout.flush() - mydepgraph = depgraph(settings, trees, myopts, myparams, spinner) - if not mydepgraph.xcreate(myaction): - print "!!! Depgraph creation failed." - return 1 - if "--quiet" not in myopts and "--nodeps" not in myopts: - print "\b\b... done!" - else: - if "--quiet" not in myopts and "--nodeps" not in myopts: - print "Calculating dependencies ", - sys.stdout.flush() - mydepgraph = depgraph(settings, trees, myopts, myparams, spinner) - try: - retval, favorites = mydepgraph.select_files(myfiles) - except portage.exception.PackageNotFound, e: - portage.writemsg("\n!!! %s\n" % str(e), noiselevel=-1) - return 1 - if not retval: - return 1 - if "--quiet" not in myopts and "--nodeps" not in myopts: - print "\b\b... done!" + if "--quiet" not in myopts and "--nodeps" not in myopts: + print "Calculating dependencies ", + sys.stdout.flush() + mydepgraph = depgraph(settings, trees, myopts, myparams, spinner) + try: + retval, favorites = mydepgraph.select_files(myfiles) + except portage.exception.PackageNotFound, e: + portage.writemsg("\n!!! %s\n" % str(e), noiselevel=-1) + return 1 + if not retval: + return 1 + if "--quiet" not in myopts and "--nodeps" not in myopts: + print "\b\b... done!" - if ("--usepkgonly" in myopts) and mydepgraph.missingbins: - sys.stderr.write(red("The following binaries are not available for merging...\n")) + if ("--usepkgonly" in myopts) and mydepgraph.missingbins: + sys.stderr.write(red("The following binaries are not available for merging...\n")) if mydepgraph.missingbins: for x in mydepgraph.missingbins: @@ -6341,7 +6198,7 @@ def parse_opts(tmpcmdline, silent=False): for x in myargs: if x in actions and myaction != "search": - if not silent and x not in ["system", "world"]: + if not silent: print red("*** Deprecated use of action '%s', use '--%s' instead" % (x,x)) # special case "search" so people can search for action terms, e.g. emerge -s sync if myaction: @@ -6564,10 +6421,6 @@ def emerge_main(): """ - if (myaction in ["world", "system"]) and myfiles: - print "emerge: please specify a package class (\"world\" or \"system\") or individual packages, but not both." - sys.exit(1) - for x in myfiles: ext = os.path.splitext(x)[1] if (ext == ".ebuild" or ext == ".tbz2") and os.path.exists(os.path.abspath(x)): -- 2.26.2