From 066f29899b076c59a2675bf440d492da86780767 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Mon, 18 Dec 2006 20:27:05 +0000 Subject: [PATCH] Merged from trunk 5305:5318 remove pointless redirects to /dev/null when using hasq() (SpankMan) force environment.bz2 to be clobbered if it already exists (SpankMan) In depgraph.altlist(), pop as many leaf nodes as possible when no relationship has been ignored. This can halve the time taken for a large merge order calculation. Don't optimize depgraph.altlist() in reversed mode since the optimization destroys --tree ouput. Add --debug support for --depclean. Do some minor cleanup of the --depclean code. Make depclean skip empty depstrings. Disable the spinner when --debug is enabled so that it doesn't interfere. Catch PortageException from portdbapi.aux_get since it can happen when gpg is in FEATURES. For bug #158354, make "No" the default response for unmerge actions. svn path=/main/branches/prefix/; revision=5320 --- bin/ebuild.sh | 6 ++--- bin/emerge | 61 +++++++++++++++++++++++++++++++++----------------- pym/portage.py | 48 +++++++++++++++++++++------------------ 3 files changed, 69 insertions(+), 46 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 944eb83d4..e9ffea3dd 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1056,7 +1056,7 @@ dyn_compile() { fi unset LIBDIR_VAR - if hasq noauto $FEATURES &>/dev/null && [ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]; then + if hasq noauto $FEATURES && [ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]; then echo echo "!!! We apparently haven't unpacked... This is probably not what you" echo "!!! want to be doing... You are using FEATURES=noauto so I'll assume" @@ -1117,7 +1117,7 @@ dyn_compile() { set +f set > environment export -p | sed 's:declare -rx:declare -x:' >> environment - bzip2 -9 environment + bzip2 -f9 environment cp "${EBUILD}" "${PF}.ebuild" if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT} @@ -1522,7 +1522,7 @@ if [[ ${EBUILD_SH_ARGS} != "depend" ]] && [[ ${EBUILD_SH_ARGS} != "clean" ]] && export USER=portage fi - if hasq distcc ${FEATURES} &>/dev/null; then + if hasq distcc ${FEATURES} ; then if [ -d "${EPREFIX}"/usr/lib/distcc/bin ]; then #We can enable distributed compile support if [ -z "${PATH/*distcc*/}" ]; then diff --git a/bin/emerge b/bin/emerge index 6f9cb449f..f309b4efd 100755 --- a/bin/emerge +++ b/bin/emerge @@ -751,7 +751,7 @@ class FakeVartree(portage.vartree): live_metadata = dict(izip(portdb_keys, portdb.aux_get(cpv, portdb_keys))) self.dbapi.aux_update(cpv, live_metadata) - except KeyError: + except KeyError, portage_exception.PortageException: if global_updates is None: global_updates = \ grab_global_updates(portdb.porttree_root) @@ -1746,7 +1746,14 @@ class depgraph: selected_nodes = None if nodes: if ignore_priority <= DepPriority.SOFT: - selected_nodes = [nodes[0]] + if ignore_priority is None and not reversed: + # Greedily pop all of these nodes since no relationship + # has been ignored. This optimization destroys --tree + # output, so it's disabled in reversed mode. + selected_nodes = nodes + else: + # Only pop one node for optimal merge order. + selected_nodes = [nodes[0]] else: """Recursively gather a group of nodes that RDEPEND on eachother. This ensures that they are merged as a group @@ -3127,7 +3134,8 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files, #we're done... return return 0 if "--ask" in myopts: - if userquery("Would you like to unmerge these packages?")=="No": + if userquery("Would you like to unmerge these packages?", + responses=["No", "Yes"], colours=[red, green]) == "No": # enter pretend mode for correct formatting of results myopts["--pretend"] = True print @@ -4094,11 +4102,14 @@ def action_depclean(settings, trees, ldpath_mtimes, print warn_prefix + good("`emerge --update --newuse --deep world`") + " prior to depclean." xterm_titles = "notitles" not in settings.features - portdb = trees[settings["ROOT"]]["porttree"].dbapi - real_vartree = trees[settings["ROOT"]]["vartree"] - vartree = FakeVartree(real_vartree, portdb) - trees[settings["ROOT"]]["vartree"] = vartree - vardb = vartree.dbapi + myroot = settings["ROOT"] + dep_check_trees = {} + dep_check_trees[myroot] = {} + dep_check_trees[myroot]["vartree"] = \ + FakeVartree(trees[myroot]["vartree"], trees[myroot]["porttree"].dbapi) + vardb = dep_check_trees[myroot]["vartree"].dbapi + # Constrain dependency selection to the installed packages. + dep_check_trees[myroot]["porttree"] = dep_check_trees[myroot]["vartree"] syslist = getlist(settings, "system") worldlist = getlist(settings, "world") fakedb = portage.fakedbapi(settings=settings) @@ -4130,13 +4141,6 @@ def action_depclean(settings, trees, ldpath_mtimes, unresolveable = {} aux_keys = ["DEPEND", "RDEPEND", "PDEPEND"] - # Now that FakeVartree pulls metadata from the portdb and performs global - # updates when necessary, fake_vardb and vardb are equivalent. - fake_vardb = vardb - - # HACK: Ensure that installed packages are preferenced by dep_check(). - trees[settings["ROOT"]]["porttree"].dbapi = fake_vardb - while remaining_atoms: atom, parent, priority = remaining_atoms.pop() pkgs = vardb.match(atom) @@ -4151,7 +4155,7 @@ def action_depclean(settings, trees, ldpath_mtimes, continue spinner.update() fakedb.cpv_inject(pkg) - myaux = dict(izip(aux_keys, fake_vardb.aux_get(pkg, aux_keys))) + myaux = dict(izip(aux_keys, vardb.aux_get(pkg, aux_keys))) mydeps = [] if myopts.get("--with-bdeps", "y") == "y": mydeps.append((myaux["DEPEND"], soft)) @@ -4159,20 +4163,34 @@ def action_depclean(settings, trees, ldpath_mtimes, mydeps.append((" ".join(myaux.values()), hard)) usedef = vardb.aux_get(pkg, ["USE"])[0].split() for depstr, priority in mydeps: + + if not depstr: + continue + + if "--debug" in myopts: + print + print "Parent: ", pkg + print "Depstring:", depstr + print "Priority:", + if priority == soft: + print "soft" + else: + print "hard" + success, atoms = portage.dep_check(depstr, None, settings, - myuse=usedef, trees=trees, myroot=settings["ROOT"]) + myuse=usedef, trees=dep_check_trees, myroot=myroot) if not success: print "\n\n" print "Error occurred while processing",pkg print str(atoms) return + + if "--debug" in myopts: + print "Candidates:", atoms + for atom in atoms: remaining_atoms.append((atom, pkg, priority)) - # Restore the portdb back to normal (see fake_vardb above). - trees[settings["ROOT"]]["porttree"].dbapi = portdb - trees[settings["ROOT"]]["vartree"] = real_vartree - if "--quiet" not in myopts: print "\b\b... done!\n" @@ -4795,6 +4813,7 @@ def emerge_main(): sys.exit(1) if settings.get("PORTAGE_DEBUG", "") == "1": + spinner.update = spinner.update_quiet portage.debug=1 if "python-trace" in settings.features: import portage_debug diff --git a/pym/portage.py b/pym/portage.py index 4326c715f..5fa1c47f7 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -5174,7 +5174,9 @@ class portdbapi(dbapi): for x in self.porttrees: # location, label, auxdbkeys self.auxdb[x] = self.auxdbmodule(self.depcachedir, x, filtered_auxdbkeys, gid=portage_gid) - self._gvisible_aux_cache = {} + # Selectively cache metadata in order to optimize dep matching. + self._aux_cache_keys = set(["EAPI", "KEYWORDS", "SLOT"]) + self._aux_cache = {} def _init_cache_dirs(self): """Create /var/cache/edb/dep and adjust permissions for the portage @@ -5253,6 +5255,12 @@ class portdbapi(dbapi): "stub code for returning auxilliary db information, such as SLOT, DEPEND, etc." 'input: "sys-apps/foo-1.0",["SLOT","DEPEND","HOMEPAGE"]' 'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com"] or raise KeyError if error' + cache_me = False + if not mytree and not set(mylist).difference(self._aux_cache_keys): + aux_cache = self._aux_cache.get(mycpv) + if aux_cache is not None: + return [aux_cache[x] for x in mylist] + cache_me = True global auxdbkeys,auxdbkeylen cat,pkg = string.split(mycpv, "/", 1) @@ -5415,6 +5423,14 @@ class portdbapi(dbapi): if not returnme[idx]: returnme[idx] = "0" + if cache_me: + aux_cache = {} + for x in self._aux_cache_keys: + aux_cache[x] = mydata[x] + if not aux_cache["EAPI"]: + aux_cache["EAPI"] = "0" + self._aux_cache[mycpv] = aux_cache + return returnme def getfetchlist(self, mypkg, useflags=None, mysettings=None, all=0, mytree=None): @@ -5692,27 +5708,15 @@ class portdbapi(dbapi): accept_keywords = self.mysettings["ACCEPT_KEYWORDS"].split() pkgdict = self.mysettings.pkeywordsdict for mycpv in mylist: - #we need to update this next line when we have fully integrated the new db api - auxerr=0 - keys = None - eapi = None - aux_cache = self._gvisible_aux_cache.get(mycpv) - if aux_cache is not None: - keys, eapi = aux_cache - else: - try: - keys, eapi = self.aux_get(mycpv, ["KEYWORDS", "EAPI"]) - except KeyError: - pass - except portage_exception.PortageException, e: - writemsg("!!! Error: aux_get('%s', ['KEYWORDS', 'EAPI'])\n" % mycpv, - noiselevel=-1) - writemsg("!!! %s\n" % str(e), - noiselevel=-1) - self._gvisible_aux_cache[mycpv] = (keys, eapi) - if not keys: - # KEYWORDS="" - #print "!!! No KEYWORDS for "+str(mycpv)+" -- Untested Status" + try: + keys, eapi = self.aux_get(mycpv, ["KEYWORDS", "EAPI"]) + except KeyError: + continue + except portage_exception.PortageException, e: + writemsg("!!! Error: aux_get('%s', ['KEYWORDS', 'EAPI'])\n" % \ + mycpv, noiselevel=-1) + writemsg("!!! %s\n" % str(e), noiselevel=-1) + del e continue mygroups=keys.split() # Repoman may modify this attribute as necessary. -- 2.26.2