From 44aa9f5ff29f85898f0083fff969d874409d767e Mon Sep 17 00:00:00 2001 From: Samuel BAUER Date: Thu, 14 Apr 2011 15:09:15 +0700 Subject: [PATCH] Added misspell-suggestion command line option --- pym/_emerge/depgraph.py | 537 +++++++++++++++++++---------------------------- pym/_emerge/help.py | 13 +- pym/_emerge/main.py | 99 +++------ 3 files changed, 246 insertions(+), 403 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 391c845..5b37a42 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -16,7 +16,7 @@ from portage import os, OrderedDict from portage import _unicode_decode from portage.const import PORTAGE_PACKAGE_ATOM from portage.dbapi import dbapi -from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use, _repo_separator +from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use from portage.exception import InvalidAtom, InvalidDependString from portage.output import colorize, create_color_func, \ @@ -54,10 +54,9 @@ from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice from _emerge.UnmergeDepPriority import UnmergeDepPriority from _emerge.UseFlagDisplay import pkg_use_display -from _emerge.resolver.backtracking import Backtracker, BacktrackParameter from _emerge.resolver.slot_collision import slot_conflict_handler from _emerge.resolver.circular_dependency import circular_dependency_handler -from _emerge.resolver.output import Display +from _emerge.resolver.output import display if sys.hexversion >= 0x3000000: basestring = str @@ -122,15 +121,16 @@ class _depgraph_sets(object): # contains all sets added to the graph self.sets = {} # contains non-set atoms given as arguments - self.sets['__non_set_args__'] = InternalPackageSet(allow_repo=True) + self.sets['__non_set_args__'] = InternalPackageSet() # contains all atoms from all sets added to the graph, including # atoms given as arguments - self.atoms = InternalPackageSet(allow_repo=True) + self.atoms = InternalPackageSet() self.atom_arg_map = {} class _dynamic_depgraph_config(object): - def __init__(self, depgraph, myparams, allow_backtracking, backtrack_parameters): + def __init__(self, depgraph, myparams, allow_backtracking, + runtime_pkg_mask, needed_unstable_keywords, needed_use_config_changes, needed_license_changes): self.myparams = myparams.copy() self._vdb_loaded = False self._allow_backtracking = allow_backtracking @@ -198,18 +198,36 @@ class _dynamic_depgraph_config(object): self._ignored_deps = [] self._highest_pkg_cache = {} - self._needed_unstable_keywords = backtrack_parameters.needed_unstable_keywords - self._needed_license_changes = backtrack_parameters.needed_license_changes - self._needed_use_config_changes = backtrack_parameters.needed_use_config_changes - self._runtime_pkg_mask = backtrack_parameters.runtime_pkg_mask + if runtime_pkg_mask is None: + runtime_pkg_mask = {} + else: + runtime_pkg_mask = dict((k, v.copy()) for (k, v) in \ + runtime_pkg_mask.items()) + + if needed_unstable_keywords is None: + self._needed_unstable_keywords = set() + else: + self._needed_unstable_keywords = needed_unstable_keywords.copy() + + if needed_license_changes is None: + self._needed_license_changes = {} + else: + self._needed_license_changes = needed_license_changes.copy() + + if needed_use_config_changes is None: + self._needed_use_config_changes = {} + else: + self._needed_use_config_changes = \ + dict((k.copy(), (v[0].copy(), v[1].copy())) for (k, v) in \ + needed_use_config_changes.items()) + + self._autounmask = depgraph._frozen_config.myopts.get('--autounmask', 'n') == True + + self._runtime_pkg_mask = runtime_pkg_mask self._need_restart = False # For conditions that always require user intervention, such as # unsatisfied REQUIRED_USE (currently has no autounmask support). self._skip_restart = False - self._backtrack_infos = {} - - self._autounmask = depgraph._frozen_config.myopts.get('--autounmask', 'n') == True - self._success_without_autounmask = False for myroot in depgraph._frozen_config.trees: self.sets[myroot] = _depgraph_sets() @@ -288,13 +306,15 @@ class depgraph(object): _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"] def __init__(self, settings, trees, myopts, myparams, spinner, - frozen_config=None, backtrack_parameters=BacktrackParameter(), allow_backtracking=False): + frozen_config=None, runtime_pkg_mask=None, needed_unstable_keywords=None, \ + needed_use_config_changes=None, needed_license_changes=None, allow_backtracking=False): if frozen_config is None: frozen_config = _frozen_depgraph_config(settings, trees, myopts, spinner) self._frozen_config = frozen_config self._dynamic_config = _dynamic_depgraph_config(self, myparams, - allow_backtracking, backtrack_parameters) + allow_backtracking, runtime_pkg_mask, needed_unstable_keywords, \ + needed_use_config_changes, needed_license_changes) self._select_atoms = self._select_atoms_highest_available self._select_package = self._select_pkg_highest_available @@ -555,7 +575,7 @@ class depgraph(object): # PROVIDE when necessary, while match_from_list does not. parent, atom = parent_atom atom_set = InternalPackageSet( - initial_atoms=(atom,), allow_repo=True) + initial_atoms=(atom,)) if atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)): parent_atoms.add(parent_atom) else: @@ -705,14 +725,16 @@ class depgraph(object): (dep.parent, self._dynamic_config._runtime_pkg_mask[ dep.parent]), noiselevel=-1) - elif not self.need_restart(): + else: # Do not backtrack if only USE have to be changed in # order to satisfy the dependency. dep_pkg, existing_node = \ self._select_package(dep.root, dep.atom.without_use, onlydeps=dep.onlydeps) if dep_pkg is None: - self._dynamic_config._backtrack_infos["missing dependency"] = dep + self._dynamic_config._runtime_pkg_mask.setdefault( + dep.parent, {})["missing dependency"] = \ + set([(dep.parent, dep.root, dep.atom)]) self._dynamic_config._need_restart = True if "--debug" in self._frozen_config.myopts: msg = [] @@ -743,7 +765,7 @@ class depgraph(object): # Use package set for matching since it will match via # PROVIDE when necessary, while match_from_list does not. matches = bool(InternalPackageSet(initial_atoms=(atom,), - allow_repo=True).findAtomForPackage(existing_node, + ).findAtomForPackage(existing_node, modified_use=self._pkg_use_enabled(existing_node))) return (existing_node, matches) @@ -869,13 +891,10 @@ class depgraph(object): self._dynamic_config._runtime_pkg_mask[ existing_node]), noiselevel=-1) elif self._dynamic_config._allow_backtracking and \ - not self._accept_blocker_conflicts() and \ - not self.need_restart(): - + not self._accept_blocker_conflicts(): self._add_slot_conflict(pkg) if dep.atom is not None and dep.parent is not None: self._add_parent_atom(pkg, (dep.parent, dep.atom)) - if arg_atoms: for parent_atom in arg_atoms: parent, atom = parent_atom @@ -909,8 +928,7 @@ class depgraph(object): all_match = True for parent, atom in parent_atoms: - i = InternalPackageSet(initial_atoms=(atom,), - allow_repo=True) + i = InternalPackageSet(initial_atoms=(atom,)) if not i.findAtomForPackage(to_be_masked): all_match = False break @@ -947,9 +965,10 @@ class depgraph(object): elif pkg > existing_node: backtrack_data.reverse() - to_be_masked = backtrack_data[-1][0] + to_be_masked, parent_atoms = backtrack_data[-1] - self._dynamic_config._backtrack_infos["slot conflict"] = backtrack_data + self._dynamic_config._runtime_pkg_mask.setdefault( + to_be_masked, {})["slot conflict"] = parent_atoms self._dynamic_config._need_restart = True if "--debug" in self._frozen_config.myopts: msg = [] @@ -1027,10 +1046,10 @@ class depgraph(object): self._add_parent_atom(pkg, parent_atom) """ This section determines whether we go deeper into dependencies or not. - We want to go deeper on a few occasions: - Installing package A, we need to make sure package A's deps are met. - emerge --deep ; we need to recursively check dependencies of pkgspec - If we are in --nodeps (no recursion) mode, we obviously only check 1 level of dependencies. + We want to go deeper on a few occasions: + Installing package A, we need to make sure package A's deps are met. + emerge --deep ; we need to recursively check dependencies of pkgspec + If we are in --nodeps (no recursion) mode, we obviously only check 1 level of dependencies. """ if arg_atoms: depth = 0 @@ -1445,8 +1464,7 @@ class depgraph(object): for atom in pkg_atom_map[pkg1]: cp_atoms.add(atom) atom_pkg_graph.add(pkg1, atom) - atom_set = InternalPackageSet(initial_atoms=(atom,), - allow_repo=True) + atom_set = InternalPackageSet(initial_atoms=(atom,)) for pkg2 in pkgs: if pkg2 is pkg1: continue @@ -1570,7 +1588,7 @@ class depgraph(object): deps = [] for cat in categories: deps.append(Atom(insert_category_into_atom( - atom_without_category, cat), allow_repo=True)) + atom_without_category, cat))) return deps def _have_new_virt(self, root, atom_cp): @@ -1690,8 +1708,7 @@ class depgraph(object): raise portage.exception.PackageNotFound( "%s is not in a valid portage tree hierarchy or does not exist" % x) pkg = self._pkg(mykey, "ebuild", root_config, - onlydeps=onlydeps, myrepo=portdb.getRepositoryName( - os.path.dirname(os.path.dirname(os.path.dirname(ebuild_path))))) + onlydeps=onlydeps) args.append(PackageArg(arg=x, package=pkg, root_config=root_config)) elif x.startswith(os.path.sep): @@ -1726,7 +1743,7 @@ class depgraph(object): args.append(SetArg(arg=x, pset=pset, root_config=root_config)) continue - if not is_valid_package_atom(x, allow_repo=True): + if not is_valid_package_atom(x): portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x, noiselevel=-1) portage.writemsg("!!! Please check ebuild(5) for full details.\n") @@ -1741,7 +1758,7 @@ class depgraph(object): # 2) It takes away freedom from the resolver to choose other # possible expansions when necessary. if "/" in x: - args.append(AtomArg(arg=x, atom=Atom(x, allow_repo=True), + args.append(AtomArg(arg=x, atom=Atom(x), root_config=root_config)) continue expanded_atoms = self._dep_expand(root_config, x) @@ -1794,14 +1811,12 @@ class depgraph(object): if expanded_atoms: atom = expanded_atoms[0] else: - null_atom = Atom(insert_category_into_atom(x, "null"), - allow_repo=True) + null_atom = Atom(insert_category_into_atom(x, "null")) cat, atom_pn = portage.catsplit(null_atom.cp) virts_p = root_config.settings.get_virts_p().get(atom_pn) if virts_p: # Allow the depgraph to choose which virtual. - atom = Atom(null_atom.replace('null/', 'virtual/', 1), - allow_repo=True) + atom = Atom(null_atom.replace('null/', 'virtual/', 1)) else: atom = null_atom @@ -2030,7 +2045,6 @@ class depgraph(object): set(self._dynamic_config.digraph).intersection( \ self._dynamic_config._needed_license_changes) : #We failed if the user needs to change the configuration - self._dynamic_config._success_without_autounmask = True return False, myfavorites # We're true here unless we are missing binaries. @@ -2049,7 +2063,7 @@ class depgraph(object): for root in self._dynamic_config.sets: depgraph_sets = self._dynamic_config.sets[root] depgraph_sets.sets.setdefault('__non_set_args__', - InternalPackageSet(allow_repo=True)).clear() + InternalPackageSet()).clear() depgraph_sets.atoms.clear() depgraph_sets.atom_arg_map.clear() set_atoms[root] = [] @@ -2294,12 +2308,8 @@ class depgraph(object): if target_atom is not None and isinstance(node, Package): affecting_use = set() for dep_str in "DEPEND", "RDEPEND", "PDEPEND": - try: - affecting_use.update(extract_affecting_use( - node.metadata[dep_str], target_atom)) - except InvalidDependString: - if not node.installed: - raise + affecting_use.update(extract_affecting_use( + node.metadata[dep_str], target_atom)) affecting_use.difference_update(node.use.mask, node.use.force) pkg_name = _unicode_decode("%s") % (node.cpv,) if affecting_use: @@ -2430,8 +2440,7 @@ class depgraph(object): a matching package has been masked by backtracking. """ backtrack_mask = False - atom_set = InternalPackageSet(initial_atoms=(atom.without_use,), - allow_repo=True) + atom_set = InternalPackageSet(initial_atoms=(atom.without_use,)) xinfo = '"%s"' % atom.unevaluated_atom if arg: xinfo='"%s"' % arg @@ -2459,73 +2468,65 @@ class depgraph(object): continue match = db.match if hasattr(db, "xmatch"): - cpv_list = db.xmatch("match-all-cpv-only", atom.without_use) + cpv_list = db.xmatch("match-all", atom.without_use) else: cpv_list = db.match(atom.without_use) - - if atom.repo is None and hasattr(db, "getRepositories"): - repo_list = db.getRepositories() - else: - repo_list = [atom.repo] - # descending order cpv_list.reverse() for cpv in cpv_list: - for repo in repo_list: - if not db.cpv_exists(cpv, myrepo=repo): - continue - - metadata, mreasons = get_mask_info(root_config, cpv, pkgsettings, db, pkg_type, \ - built, installed, db_keys, myrepo=repo, _pkg_use_enabled=self._pkg_use_enabled) - - if metadata is not None: - if not repo: - repo = metadata.get('repository') - pkg = self._pkg(cpv, pkg_type, root_config, - installed=installed, myrepo=repo) - if not atom_set.findAtomForPackage(pkg, - modified_use=self._pkg_use_enabled(pkg)): + metadata, mreasons = get_mask_info(root_config, cpv, pkgsettings, db, \ + pkg_type, built, installed, db_keys, _pkg_use_enabled=self._pkg_use_enabled) + + if metadata is not None: + pkg = self._pkg(cpv, pkg_type, root_config, + installed=installed) + # pkg.metadata contains calculated USE for ebuilds, + # required later for getMissingLicenses. + metadata = pkg.metadata + if pkg.cp != atom.cp: + # A cpv can be returned from dbapi.match() as an + # old-style virtual match even in cases when the + # package does not actually PROVIDE the virtual. + # Filter out any such false matches here. + if not atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)): continue - # pkg.metadata contains calculated USE for ebuilds, - # required later for getMissingLicenses. - metadata = pkg.metadata - if pkg in self._dynamic_config._runtime_pkg_mask: - backtrack_reasons = \ - self._dynamic_config._runtime_pkg_mask[pkg] - mreasons.append('backtracking: %s' % \ - ', '.join(sorted(backtrack_reasons))) - backtrack_mask = True - if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \ - modified_use=self._pkg_use_enabled(pkg)): - mreasons = ["exclude option"] - if mreasons: - masked_pkg_instances.add(pkg) - if atom.unevaluated_atom.use: - try: - if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \ - or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use: - missing_use.append(pkg) - if not mreasons: - continue - except InvalidAtom: - writemsg("violated_conditionals raised " + \ - "InvalidAtom: '%s' parent: %s" % \ - (atom, myparent), noiselevel=-1) - raise - if not mreasons and \ - not pkg.built and \ - pkg.metadata["REQUIRED_USE"] and \ - eapi_has_required_use(pkg.metadata["EAPI"]): - if not check_required_use( - pkg.metadata["REQUIRED_USE"], - self._pkg_use_enabled(pkg), - pkg.iuse.is_valid_flag): - required_use_unsatisfied.append(pkg) - continue - if pkg.built and not mreasons: - mreasons = ["use flag configuration mismatch"] - masked_packages.append( - (root_config, pkgsettings, cpv, repo, metadata, mreasons)) + if pkg in self._dynamic_config._runtime_pkg_mask: + backtrack_reasons = \ + self._dynamic_config._runtime_pkg_mask[pkg] + mreasons.append('backtracking: %s' % \ + ', '.join(sorted(backtrack_reasons))) + backtrack_mask = True + if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \ + modified_use=self._pkg_use_enabled(pkg)): + mreasons = ["exclude option"] + if mreasons: + masked_pkg_instances.add(pkg) + if atom.unevaluated_atom.use: + try: + if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \ + or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use: + missing_use.append(pkg) + if not mreasons: + continue + except InvalidAtom: + writemsg("violated_conditionals raised " + \ + "InvalidAtom: '%s' parent: %s" % \ + (atom, myparent), noiselevel=-1) + raise + if not mreasons and \ + not pkg.built and \ + pkg.metadata["REQUIRED_USE"] and \ + eapi_has_required_use(pkg.metadata["EAPI"]): + if not check_required_use( + pkg.metadata["REQUIRED_USE"], + self._pkg_use_enabled(pkg), + pkg.iuse.is_valid_flag): + required_use_unsatisfied.append(pkg) + continue + if pkg.built and not mreasons: + mreasons = ["use flag configuration mismatch"] + masked_packages.append( + (root_config, pkgsettings, cpv, metadata, mreasons)) if check_backtrack: if backtrack_mask: @@ -2688,7 +2689,7 @@ class depgraph(object): # that the user wants the latest version, so only the first # instance is displayed. pkg = required_use_unsatisfied[0] - output_cpv = pkg.cpv + _repo_separator + pkg.repo + output_cpv = pkg.cpv writemsg_stdout("\n!!! " + \ colorize("BAD", "The ebuild selected to satisfy ") + \ colorize("INFORM", xinfo) + \ @@ -2741,7 +2742,9 @@ class depgraph(object): mask_docs = True else: writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1) - if isinstance(myparent, AtomArg): + + if self._frozen_config.myopts.get('--misspell-suggestions', 'y') == 'y' and \ + isinstance(myparent, AtomArg): cp = myparent.atom.cp.lower() cat, pkg = portage.catsplit(cp) if cat == "null": @@ -2827,14 +2830,7 @@ class depgraph(object): db = root_config.trees[self.pkg_tree_map[pkg_type]].dbapi if hasattr(db, "xmatch"): - # For portdbapi we match only against the cpv, in order - # to bypass unnecessary cache access for things like IUSE - # and SLOT. Later, we cache the metadata in a Package - # instance, and use that for further matching. This - # optimization is especially relevant since - # pordbapi.aux_get() does not cache calls that have - # myrepo or mytree arguments. - cpv_list = db.xmatch("match-all-cpv-only", atom) + cpv_list = db.xmatch("match-all", atom) else: cpv_list = db.match(atom) @@ -2861,7 +2857,7 @@ class depgraph(object): if not slot_available: continue inst_pkg = self._pkg(cpv, "installed", - root_config, installed=installed, myrepo = atom.repo) + root_config, installed=installed) # Remove the slot from the atom and verify that # the package matches the resulting atom. if portage.match_from_list( @@ -2870,39 +2866,25 @@ class depgraph(object): return if cpv_list: - atom_set = InternalPackageSet(initial_atoms=(atom,), - allow_repo=True) - if atom.repo is None and hasattr(db, "getRepositories"): - repo_list = db.getRepositories() - else: - repo_list = [atom.repo] # descending order cpv_list.reverse() for cpv in cpv_list: - for repo in repo_list: - - try: - pkg = self._pkg(cpv, pkg_type, root_config, - installed=installed, onlydeps=onlydeps, myrepo=repo) - except portage.exception.PackageNotFound: - pass - else: + try: + pkg = self._pkg(cpv, pkg_type, root_config, + installed=installed, onlydeps=onlydeps) + except portage.exception.PackageNotFound: + pass + else: + if pkg.cp != atom.cp: # A cpv can be returned from dbapi.match() as an # old-style virtual match even in cases when the # package does not actually PROVIDE the virtual. # Filter out any such false matches here. - - # Make sure that cpv from the current repo satisfies the atom. - # This might not be the case if there are several repos with - # the same cpv, but different metadata keys, like SLOT. - # Also, for portdbapi, parts of the match that require - # metadata access are deferred until we have cached the - # metadata in a Package instance. - if not atom_set.findAtomForPackage(pkg, - modified_use=self._pkg_use_enabled(pkg)): + if not InternalPackageSet(initial_atoms=(atom,) + ).findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)): continue - yield pkg + yield pkg def _select_pkg_highest_available(self, root, atom, onlydeps=False): cache_key = (root, atom, onlydeps) @@ -3032,18 +3014,9 @@ class depgraph(object): if masked_by_unstable_keywords: self._dynamic_config._needed_unstable_keywords.add(pkg) - backtrack_infos = self._dynamic_config._backtrack_infos - backtrack_infos.setdefault("config", {}) - backtrack_infos["config"].setdefault("needed_unstable_keywords", set()) - backtrack_infos["config"]["needed_unstable_keywords"].add(pkg) - if missing_licenses: self._dynamic_config._needed_license_changes.setdefault(pkg, set()).update(missing_licenses) - backtrack_infos = self._dynamic_config._backtrack_infos - backtrack_infos.setdefault("config", {}) - backtrack_infos["config"].setdefault("needed_license_changes", set()) - backtrack_infos["config"]["needed_license_changes"].add((pkg, frozenset(missing_licenses))) return True @@ -3119,12 +3092,8 @@ class depgraph(object): if required_use and check_required_use(required_use, old_use, pkg.iuse.is_valid_flag) and \ not check_required_use(required_use, new_use, pkg.iuse.is_valid_flag): return old_use - + self._dynamic_config._needed_use_config_changes[pkg] = (new_use, new_changes) - backtrack_infos = self._dynamic_config._backtrack_infos - backtrack_infos.setdefault("config", {}) - backtrack_infos["config"].setdefault("needed_use_config_changes", []) - backtrack_infos["config"]["needed_use_config_changes"].append((pkg, (new_use, new_changes))) if want_restart_for_use_change(pkg, new_use): self._dynamic_config._need_restart = True return new_use @@ -3143,7 +3112,7 @@ class depgraph(object): if not isinstance(atom, portage.dep.Atom): atom = portage.dep.Atom(atom) atom_cp = atom.cp - atom_set = InternalPackageSet(initial_atoms=(atom,), allow_repo=True) + atom_set = InternalPackageSet(initial_atoms=(atom,)) existing_node = None myeb = None rebuilt_binaries = 'rebuilt_binaries' in self._dynamic_config.myparams @@ -3203,22 +3172,12 @@ class depgraph(object): # list only contains unbuilt ebuilds since USE can't # be changed for built packages. higher_version_rejected = False - repo_priority = pkg.repo_priority for rejected in packages_with_invalid_use_config: if rejected.cp != pkg.cp: continue if rejected > pkg: higher_version_rejected = True break - if portage.dep.cpvequal(rejected.cpv, pkg.cpv): - # If version is identical then compare - # repo priority (see bug #350254). - rej_repo_priority = rejected.repo_priority - if rej_repo_priority is not None and \ - (repo_priority is None or - rej_repo_priority > repo_priority): - higher_version_rejected = True - break if higher_version_rejected: continue @@ -3284,18 +3243,9 @@ class depgraph(object): else: try: pkg_eb = self._pkg( - pkg.cpv, "ebuild", root_config, myrepo=pkg.repo) + pkg.cpv, "ebuild", root_config) except portage.exception.PackageNotFound: - pkg_eb_visible = False - for pkg_eb in self._iter_match_pkgs(pkg.root_config, - "ebuild", Atom("=%s" % (pkg.cpv,))): - if self._pkg_visibility_check(pkg_eb, \ - allow_unstable_keywords=allow_unstable_keywords, - allow_license_changes=allow_license_changes): - pkg_eb_visible = True - break - if not pkg_eb_visible: - continue + continue else: if not self._pkg_visibility_check(pkg_eb, \ allow_unstable_keywords=allow_unstable_keywords, @@ -3732,25 +3682,13 @@ class depgraph(object): return 1 def _pkg(self, cpv, type_name, root_config, installed=False, - onlydeps=False, myrepo = None): + onlydeps=False): """ Get a package instance from the cache, or create a new one if necessary. Raises PackageNotFound from aux_get if it failures for some reason (package does not exist or is corrupt). """ - if type_name != "ebuild": - # For installed (and binary) packages we don't care for the repo - # when it comes to hashing, because there can only be one cpv. - # So overwrite the repo_key with type_name. - repo_key = type_name - myrepo = None - elif myrepo is None: - raise AssertionError( - "depgraph._pkg() called without 'myrepo' argument") - else: - repo_key = myrepo - operation = "merge" if installed or onlydeps: operation = "nomerge" @@ -3758,27 +3696,24 @@ class depgraph(object): # that refers to FakeVartree instead of the real vartree. root_config = self._frozen_config.roots[root_config.root] pkg = self._frozen_config._pkg_cache.get( - (type_name, root_config.root, cpv, operation, repo_key)) + (type_name, root_config.root, cpv, operation)) if pkg is None and onlydeps and not installed: # Maybe it already got pulled in as a "merge" node. pkg = self._dynamic_config.mydbapi[root_config.root].get( - (type_name, root_config.root, cpv, 'merge', repo_key)) + (type_name, root_config.root, cpv, 'merge')) if pkg is None: tree_type = self.pkg_tree_map[type_name] db = root_config.trees[tree_type].dbapi db_keys = list(self._frozen_config._trees_orig[root_config.root][ tree_type].dbapi._aux_cache_keys) - try: - metadata = zip(db_keys, db.aux_get(cpv, db_keys, myrepo=myrepo)) + metadata = zip(db_keys, db.aux_get(cpv, db_keys)) except KeyError: raise portage.exception.PackageNotFound(cpv) - pkg = Package(built=(type_name != "ebuild"), cpv=cpv, installed=installed, metadata=metadata, onlydeps=onlydeps, root_config=root_config, type_name=type_name) - self._frozen_config._pkg_cache[pkg] = pkg if not self._pkg_visibility_check(pkg) and \ @@ -4192,16 +4127,16 @@ class depgraph(object): graph = self._dynamic_config._scheduler_graph trees = self._frozen_config.trees pruned_pkg_cache = {} - for key, pkg in pkg_cache.items(): + for pkg in pkg_cache: if pkg in graph or \ (pkg.installed and pkg in trees[pkg.root]['vartree'].dbapi): - pruned_pkg_cache[key] = pkg + pruned_pkg_cache[pkg] = pkg for root in trees: trees[root]['vartree']._pkg_cache = pruned_pkg_cache self.break_refs(trees[root]['vartree'].dbapi) - self.break_refs(pruned_pkg_cache.values()) + self.break_refs(pruned_pkg_cache) sched_config = \ _scheduler_graph_config(trees, pruned_pkg_cache, graph, mergelist) @@ -5092,7 +5027,6 @@ class depgraph(object): # redundantly displaying this exact same merge list # again via _show_merge_list(). self._dynamic_config._displayed_list = mylist - display = Display() return display(self, mylist, favorites, verbosity) @@ -5272,7 +5206,7 @@ class depgraph(object): pkgsettings = self._frozen_config.pkgsettings[pkg.root] mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled(pkg)) masked_packages.append((root_config, pkgsettings, - pkg.cpv, pkg.repo, pkg.metadata, mreasons)) + pkg.cpv, pkg.metadata, mreasons)) if masked_packages: writemsg("\n" + colorize("BAD", "!!!") + \ " The following updates are masked by LICENSE changes:\n", @@ -5287,7 +5221,7 @@ class depgraph(object): pkgsettings = self._frozen_config.pkgsettings[pkg.root] mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled) masked_packages.append((root_config, pkgsettings, - pkg.cpv, pkg.repo, pkg.metadata, mreasons)) + pkg.cpv, pkg.metadata, mreasons)) if masked_packages: writemsg("\n" + colorize("BAD", "!!!") + \ " The following installed packages are masked:\n", @@ -5378,14 +5312,6 @@ class depgraph(object): if not isinstance(mergelist, list): mergelist = [] - favorites = resume_data.get("favorites") - args_set = self._dynamic_config.sets[ - self._frozen_config.target_root].sets['__non_set_args__'] - if isinstance(favorites, list): - args = self._load_favorites(favorites) - else: - args = [] - fakedb = self._dynamic_config.mydbapi trees = self._frozen_config.trees serialized_tasks = [] @@ -5399,39 +5325,14 @@ class depgraph(object): if action != "merge": continue root_config = self._frozen_config.roots[myroot] - - # Use the resume "favorites" list to see if a repo was specified - # for this package. - depgraph_sets = self._dynamic_config.sets[root_config.root] - repo = None - for atom in depgraph_sets.atoms.getAtoms(): - if atom.repo and portage.dep.match_from_list(atom, [pkg_key]): - repo = atom.repo - break - - atom = "=" + pkg_key - if repo: - atom = atom + _repo_separator + repo - try: - atom = Atom(atom, allow_repo=True) - except InvalidAtom: - continue - - pkg = None - for pkg in self._iter_match_pkgs(root_config, pkg_type, atom): - if not self._pkg_visibility_check(pkg) or \ - self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, - modified_use=self._pkg_use_enabled(pkg)): - continue - break - - if pkg is None: + pkg = self._pkg(pkg_key, pkg_type, root_config) + except portage.exception.PackageNotFound: # It does no exist or it is corrupt. if skip_missing: # TODO: log these somewhere continue - raise portage.exception.PackageNotFound(pkg_key) + raise if "merge" == pkg.operation and \ self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \ @@ -5472,6 +5373,14 @@ class depgraph(object): # recognized, deep traversal of dependencies is required. self._dynamic_config.myparams["deep"] = True + favorites = resume_data.get("favorites") + args_set = self._dynamic_config.sets[ + self._frozen_config.target_root].sets['__non_set_args__'] + if isinstance(favorites, list): + args = self._load_favorites(favorites) + else: + args = [] + for task in serialized_tasks: if isinstance(task, Package) and \ task.operation == "merge": @@ -5571,7 +5480,7 @@ class depgraph(object): root_config=root_config)) else: try: - x = Atom(x, allow_repo=True) + x = Atom(x) except portage.exception.InvalidAtom: continue args.append(AtomArg(arg=x, atom=x, @@ -5621,11 +5530,17 @@ class depgraph(object): return self._dynamic_config._need_restart and \ not self._dynamic_config._skip_restart - def success_without_autounmask(self): - return self._dynamic_config._success_without_autounmask - - def get_backtrack_infos(self): - return self._dynamic_config._backtrack_infos + def get_backtrack_parameters(self): + return { + "needed_unstable_keywords": + self._dynamic_config._needed_unstable_keywords.copy(), \ + "runtime_pkg_mask": + self._dynamic_config._runtime_pkg_mask.copy(), + "needed_use_config_changes": + self._dynamic_config._needed_use_config_changes.copy(), + "needed_license_changes": + self._dynamic_config._needed_license_changes.copy(), + } class _dep_check_composite_db(dbapi): @@ -5722,18 +5637,9 @@ class _dep_check_composite_db(dbapi): else: try: pkg_eb = self._depgraph._pkg( - pkg.cpv, "ebuild", pkg.root_config, - myrepo=pkg.repo) + pkg.cpv, "ebuild", pkg.root_config) except portage.exception.PackageNotFound: - pkg_eb_visible = False - for pkg_eb in self._depgraph._iter_match_pkgs( - pkg.root_config, "ebuild", - Atom("=%s" % (pkg.cpv,))): - if self._depgraph._pkg_visibility_check(pkg_eb): - pkg_eb_visible = True - break - if not pkg_eb_visible: - return False + return False else: if not self._depgraph._pkg_visibility_check(pkg_eb): return False @@ -5784,14 +5690,12 @@ class _dep_check_composite_db(dbapi): if expanded_atoms: atom = expanded_atoms[0] else: - null_atom = Atom(insert_category_into_atom(atom, "null"), - allow_repo=True) + null_atom = Atom(insert_category_into_atom(atom, "null")) cat, atom_pn = portage.catsplit(null_atom.cp) virts_p = root_config.settings.get_virts_p().get(atom_pn) if virts_p: # Allow the resolver to choose which virtual. - atom = Atom(null_atom.replace('null/', 'virtual/', 1), - allow_repo=True) + atom = Atom(null_atom.replace('null/', 'virtual/', 1)) else: atom = null_atom return atom @@ -5870,15 +5774,10 @@ def _spinner_start(spinner, myopts): def _spinner_stop(spinner): if spinner is None or \ - spinner.update == spinner.update_quiet: + spinner.update is spinner.update_quiet: return - if spinner.update != spinner.update_basic: - # update_basic is used for non-tty output, - # so don't output backspaces in that case. - portage.writemsg_stdout("\b\b") - - portage.writemsg_stdout("... done!\n") + portage.writemsg_stdout("\b\b... done!\n") def backtrack_depgraph(settings, trees, myopts, myparams, myaction, myfiles, spinner): @@ -5892,55 +5791,44 @@ def backtrack_depgraph(settings, trees, myopts, myparams, finally: _spinner_stop(spinner) +def _backtrack_depgraph(settings, trees, myopts, myparams, + myaction, myfiles, spinner): -def _backtrack_depgraph(settings, trees, myopts, myparams, myaction, myfiles, spinner): - - max_retries = myopts.get('--backtrack', 10) - max_depth = max(1, (max_retries + 1) / 2) - allow_backtracking = max_retries > 0 - backtracker = Backtracker(max_depth) + backtrack_max = myopts.get('--backtrack', 10) + backtrack_parameters = {} + needed_unstable_keywords = None + allow_backtracking = backtrack_max > 0 backtracked = 0 - frozen_config = _frozen_depgraph_config(settings, trees, myopts, spinner) - - while backtracker: - backtrack_parameters = backtracker.get() - + while True: mydepgraph = depgraph(settings, trees, myopts, myparams, spinner, frozen_config=frozen_config, allow_backtracking=allow_backtracking, - backtrack_parameters=backtrack_parameters) + **backtrack_parameters) success, favorites = mydepgraph.select_files(myfiles) - - if success or mydepgraph.success_without_autounmask(): - break - elif not allow_backtracking: - break - elif backtracked >= max_retries: - break - elif mydepgraph.need_restart(): - backtracked += 1 - backtracker.feedback(mydepgraph.get_backtrack_infos()) + if not success: + if mydepgraph.need_restart() and backtracked < backtrack_max: + backtrack_parameters = mydepgraph.get_backtrack_parameters() + backtracked += 1 + elif backtracked and allow_backtracking: + if "--debug" in myopts: + writemsg_level( + "\n\nbacktracking aborted after %s tries\n\n" % \ + backtracked, noiselevel=-1, level=logging.DEBUG) + # Backtracking failed, so disable it and do + # a plain dep calculation + error message. + allow_backtracking = False + #Don't reset needed_unstable_keywords here, since we don't want to + #send the user through a "one step at a time" unmasking session for + #no good reason. + backtrack_parameters.pop('runtime_pkg_mask', None) + else: + break else: break - - if not (success or mydepgraph.success_without_autounmask()) and backtracked: - - if "--debug" in myopts: - writemsg_level( - "\n\nbacktracking aborted after %s tries\n\n" % \ - backtracked, noiselevel=-1, level=logging.DEBUG) - - mydepgraph = depgraph(settings, trees, myopts, myparams, spinner, - frozen_config=frozen_config, - allow_backtracking=False, - backtrack_parameters=backtracker.get_best_run()) - success, favorites = mydepgraph.select_files(myfiles) - return (success, mydepgraph, favorites) - def resume_depgraph(settings, trees, mtimedb, myopts, myparams, spinner): """ Raises PackageSetNotFound if myfiles contains a missing package set. @@ -6030,11 +5918,11 @@ def _resume_depgraph(settings, trees, mtimedb, myopts, myparams, spinner): return (success, mydepgraph, dropped_tasks) def get_mask_info(root_config, cpv, pkgsettings, - db, pkg_type, built, installed, db_keys, myrepo = None, _pkg_use_enabled=None): + db, pkg_type, built, installed, db_keys, _pkg_use_enabled=None): eapi_masked = False try: metadata = dict(zip(db_keys, - db.aux_get(cpv, db_keys, myrepo=myrepo))) + db.aux_get(cpv, db_keys))) except KeyError: metadata = None @@ -6054,8 +5942,7 @@ def get_mask_info(root_config, cpv, pkgsettings, if _pkg_use_enabled is not None: modified_use = _pkg_use_enabled(pkg) - mreasons = get_masking_status(pkg, pkgsettings, root_config, myrepo=myrepo, use=modified_use) - + mreasons = get_masking_status(pkg, pkgsettings, root_config, use=modified_use) return metadata, mreasons def show_masked_packages(masked_packages): @@ -6065,14 +5952,11 @@ def show_masked_packages(masked_packages): # show one of them to avoid redundant appearance. shown_cpvs = set() have_eapi_mask = False - for (root_config, pkgsettings, cpv, repo, + for (root_config, pkgsettings, cpv, metadata, mreasons) in masked_packages: - output_cpv = cpv - if repo: - output_cpv += _repo_separator + repo - if output_cpv in shown_cpvs: + if cpv in shown_cpvs: continue - shown_cpvs.add(output_cpv) + shown_cpvs.add(cpv) comment, filename = None, None if "package.mask" in mreasons: comment, filename = \ @@ -6094,7 +5978,7 @@ def show_masked_packages(masked_packages): # above via mreasons. pass - writemsg_stdout("- "+output_cpv+" (masked by: "+", ".join(mreasons)+")\n", noiselevel=-1) + writemsg_stdout("- "+cpv+" (masked by: "+", ".join(mreasons)+")\n", noiselevel=-1) if comment and comment not in shown_comments: writemsg_stdout(filename + ":\n" + comment + "\n", @@ -6120,14 +6004,15 @@ def show_blocker_docs_link(): writemsg("section of the Gentoo Linux x86 Handbook (architecture is irrelevant):\n\n", noiselevel=-1) writemsg("http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#blocked\n\n", noiselevel=-1) -def get_masking_status(pkg, pkgsettings, root_config, myrepo=None, use=None): +def get_masking_status(pkg, pkgsettings, root_config, use=None): return [mreason.message for \ - mreason in _get_masking_status(pkg, pkgsettings, root_config, myrepo=myrepo, use=use)] + mreason in _get_masking_status(pkg, pkgsettings, root_config, use=use)] + +def _get_masking_status(pkg, pkgsettings, root_config, use=None): -def _get_masking_status(pkg, pkgsettings, root_config, myrepo=None, use=None): mreasons = _getmaskingstatus( pkg, settings=pkgsettings, - portdb=root_config.trees["porttree"].dbapi, myrepo=myrepo) + portdb=root_config.trees["porttree"].dbapi) if not pkg.installed: if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index a120f54..ec90d56 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -19,7 +19,7 @@ def shorthelp(): print(" [ "+green("--complete-graph")+" ] [ "+green("--deep")+" ]") print(" [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + " ]") print(" [ "+green("--newuse")+" ] [ "+green("--noconfmem")+" ] [ "+green("--nospinner")+" ]") - print(" [ "+green("--oneshot")+" ] [ "+green("--onlydeps")+" ]") + print(" [ "+green("--oneshot")+" ] [ "+green("--onlydeps")+" ] [ " + green("--misspell-suggestions")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]") print(" [ "+green("--reinstall ")+turquoise("changed-use")+" ] [ " + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]") print(bold("Actions:")+" [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+" ]") @@ -280,9 +280,7 @@ def help(myopts, havecolor=1): print(" With this option, output such as USE=\"dar -bar -foo\" will instead") print(" be displayed as USE=\"-bar dar -foo\"") print() - print(" " + green("--ask") + \ - " [ %s | %s ] (%s short option)" % \ - (turquoise("y"), turquoise("n"), green("-a"))) + print(" "+green("--ask")+" ("+green("-a")+" short option)") desc = "Before performing the action, display what will take place (server info for " + \ "--sync, --pretend output for merge, and so forth), then ask " + \ "whether to proceed with the action or abort. Using --ask is more " + \ @@ -580,14 +578,11 @@ def help(myopts, havecolor=1): print(" printed out accompanied by a '+' for enabled and a '-' for") print(" disabled USE flags.") print() - print(" " + green("--quiet") + \ - " [ %s | %s ] (%s short option)" % \ - (turquoise("y"), turquoise("n"), green("-q"))) + print(" "+green("--quiet")+" ("+green("-q")+" short option)") print(" Effects vary, but the general outcome is a reduced or condensed") print(" output from portage's displays.") print() - print(" " + green("--quiet-build") + \ - " [ %s | %s ]" % (turquoise("y"), turquoise("n"))) + print(" "+green("--quiet-build")) desc = "Redirect all build output to logs alone, and do not " + \ "display it on stdout." for line in wrap(desc, desc_width): diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 96fee89..60908cf 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -50,7 +50,7 @@ if sys.hexversion >= 0x3000000: long = int options=[ -"--alphabetical", +"--ask", "--alphabetical", "--ask-enter-invalid", "--buildpkgonly", "--changed-use", @@ -65,6 +65,8 @@ options=[ "--nodeps", "--noreplace", "--nospinner", "--oneshot", "--onlydeps", "--pretend", +"--quiet", +"--quiet-build", "--quiet-unmerge-warn", "--resume", "--searchdesc", @@ -77,6 +79,7 @@ options=[ shortmapping={ "1":"--oneshot", +"a":"--ask", "B":"--buildpkgonly", "c":"--depclean", "C":"--unmerge", @@ -88,6 +91,7 @@ shortmapping={ "n":"--noreplace", "N":"--newuse", "o":"--onlydeps", "O":"--nodeps", "p":"--pretend", "P":"--prune", +"q":"--quiet", "r":"--resume", "s":"--search", "S":"--searchdesc", "t":"--tree", @@ -114,12 +118,10 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): if not regen_infodirs: portage.writemsg_stdout("\n") - if portage.util.noiselimit >= 0: - out.einfo("GNU info directory index is up-to-date.") + out.einfo("GNU info directory index is up-to-date.") else: portage.writemsg_stdout("\n") - if portage.util.noiselimit >= 0: - out.einfo("Regenerating GNU info directory index...") + out.einfo("Regenerating GNU info directory index...") dir_extensions = ("", ".gz", ".bz2") icount=0 @@ -206,7 +208,7 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): (icount, badcount)) writemsg_level(errmsg, level=logging.ERROR, noiselevel=-1) else: - if icount > 0 and portage.util.noiselimit >= 0: + if icount > 0: out.einfo("Processed %d info files." % (icount,)) def display_preserved_libs(vardbapi, myopts): @@ -423,7 +425,6 @@ def insert_optional_args(args): new_args = [] default_arg_opts = { - '--ask' : y_or_n, '--autounmask' : y_or_n, '--buildpkg' : y_or_n, '--complete-graph' : y_or_n, @@ -436,8 +437,6 @@ def insert_optional_args(args): '--jobs' : valid_integers, '--keep-going' : y_or_n, '--package-moves' : y_or_n, - '--quiet' : y_or_n, - '--quiet-build' : y_or_n, '--rebuilt-binaries' : y_or_n, '--root-deps' : ('rdeps',), '--select' : y_or_n, @@ -458,13 +457,11 @@ def insert_optional_args(args): # Don't make things like "-kn" expand to "-k n" # since existence of -n makes it too ambiguous. short_arg_opts_n = { - 'a' : y_or_n, 'b' : y_or_n, 'g' : y_or_n, 'G' : y_or_n, 'k' : y_or_n, 'K' : y_or_n, - 'q' : y_or_n, } arg_stack = args[:] @@ -563,13 +560,6 @@ def parse_opts(tmpcmdline, silent=False): true_y = ("True", "y") argument_options = { - "--ask": { - "shortopt" : "-a", - "help" : "prompt before performing any actions", - "type" : "choice", - "choices" : true_y_or_n - }, - "--autounmask": { "help" : "automatically unmask packages", "type" : "choice", @@ -707,19 +697,6 @@ def parse_opts(tmpcmdline, silent=False): "choices" : true_y_or_n }, - "--quiet": { - "shortopt" : "-q", - "help" : "reduced or condensed output", - "type" : "choice", - "choices" : true_y_or_n - }, - - "--quiet-build": { - "help" : "redirect build output to logs", - "type" : "choice", - "choices" : true_y_or_n - }, - "--rebuilt-binaries": { "help" : "replace installed packages with binary " + \ "packages that have been rebuilt", @@ -778,6 +755,12 @@ def parse_opts(tmpcmdline, silent=False): "choices" : true_y_or_n }, + "--misspell-suggestions": { + "help" : "enable package name suggestions when not existing", + "type" : "choice", + "choices" : true_y_or_n + }, + } if _ENABLE_DYN_LINK_MAP: @@ -817,11 +800,6 @@ def parse_opts(tmpcmdline, silent=False): myoptions, myargs = parser.parse_args(args=tmpcmdline) - if myoptions.ask in true_y: - myoptions.ask = True - else: - myoptions.ask = None - if myoptions.autounmask in true_y: myoptions.autounmask = True @@ -897,16 +875,6 @@ def parse_opts(tmpcmdline, silent=False): if myoptions.package_moves in true_y: myoptions.package_moves = True - if myoptions.quiet in true_y: - myoptions.quiet = True - else: - myoptions.quiet = None - - if myoptions.quiet_build in true_y: - myoptions.quiet_build = True - else: - myoptions.quiet_build = None - if myoptions.rebuilt_binaries in true_y: myoptions.rebuilt_binaries = True @@ -1258,11 +1226,13 @@ def expand_set_arguments(myfiles, myaction, root_config): def repo_name_check(trees): missing_repo_names = set() - for root_trees in trees.values(): - porttree = root_trees.get("porttree") - if porttree: - portdb = porttree.dbapi - missing_repo_names.update(portdb.getMissingRepoNames()) + for root, root_trees in trees.items(): + if "porttree" in root_trees: + portdb = root_trees["porttree"].dbapi + missing_repo_names.update(portdb.porttrees) + repos = portdb.getRepositories() + for r in repos: + missing_repo_names.discard(portdb.getRepositoryPath(r)) if portdb.porttree_root in missing_repo_names and \ not os.path.exists(os.path.join( portdb.porttree_root, "profiles")): @@ -1281,7 +1251,6 @@ def repo_name_check(trees): msg.extend(textwrap.wrap("NOTE: Each repo_name entry " + \ "should be a plain text file containing a unique " + \ "name for the repository on the first line.", 70)) - msg.append("\n") writemsg_level("".join("%s\n" % l for l in msg), level=logging.WARNING, noiselevel=-1) @@ -1293,7 +1262,7 @@ def repo_name_duplicate_check(trees): if 'porttree' in root_trees: portdb = root_trees['porttree'].dbapi if portdb.settings.get('PORTAGE_REPO_DUPLICATE_WARN') != '0': - for repo_name, paths in portdb.getIgnoredRepos(): + for repo_name, paths in portdb._ignored_repos: k = (root, repo_name, portdb.getRepositoryPath(repo_name)) ignored_repos.setdefault(k, []).extend(paths) @@ -1304,7 +1273,7 @@ def repo_name_duplicate_check(trees): msg.append(' profiles/repo_name entries:') msg.append('') for k in sorted(ignored_repos): - msg.append(' %s overrides' % ", ".join(k)) + msg.append(' %s overrides' % (k,)) for path in ignored_repos[k]: msg.append(' %s' % (path,)) msg.append('') @@ -1313,7 +1282,6 @@ def repo_name_duplicate_check(trees): "to avoid having duplicates ignored. " + \ "Set PORTAGE_REPO_DUPLICATE_WARN=\"0\" in " + \ "/etc/make.conf if you would like to disable this warning.")) - msg.append("\n") writemsg_level(''.join('%s\n' % l for l in msg), level=logging.WARNING, noiselevel=-1) @@ -1355,14 +1323,8 @@ def check_procfs(): level=logging.ERROR, noiselevel=-1) return 1 -def emerge_main(args=None): - """ - @param args: command arguments (default: sys.argv[1:]) - @type args: list - """ - if args is None: - args = sys.argv[1:] - +def emerge_main(): + global portage # NFC why this is necessary now - genone portage._disable_legacy_globals() portage.dep._internal_warnings = True # Disable color until we're sure that it should be enabled (after @@ -1372,7 +1334,7 @@ def emerge_main(args=None): # possible, such as --config-root. They will be parsed again later, # together with EMERGE_DEFAULT_OPTS (which may vary depending on the # the value of --config-root). - myaction, myopts, myfiles = parse_opts(args, silent=True) + myaction, myopts, myfiles = parse_opts(sys.argv[1:], silent=True) if "--debug" in myopts: os.environ["PORTAGE_DEBUG"] = "1" if "--config-root" in myopts: @@ -1393,7 +1355,7 @@ def emerge_main(args=None): tmpcmdline = [] if "--ignore-default-opts" not in myopts: tmpcmdline.extend(settings["EMERGE_DEFAULT_OPTS"].split()) - tmpcmdline.extend(args) + tmpcmdline.extend(sys.argv[1:]) myaction, myopts, myfiles = parse_opts(tmpcmdline) if myaction not in ('help', 'info', 'version') and \ @@ -1557,10 +1519,11 @@ def emerge_main(args=None): if settings.get("PORTAGE_DEBUG", "") == "1": spinner.update = spinner.update_quiet + portage.debug=1 portage.util.noiselimit = 0 if "python-trace" in settings.features: - import portage.debug as portage_debug - portage_debug.set_trace(True) + import portage.debug + portage.debug.set_trace(True) if not ("--quiet" in myopts): if '--nospinner' in myopts or \ @@ -1753,7 +1716,7 @@ def emerge_main(args=None): for x in myfiles: if x.startswith(SETPREFIX) or \ - is_valid_package_atom(x, allow_repo=True): + is_valid_package_atom(x): continue if x[:1] == os.sep: continue -- 1.7.3.4