Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 363137 | Differences between
and this patch

Collapse All | Expand All

(-)a/pym/_emerge/depgraph.py (-326 / +211 lines)
Lines 16-22 from portage import os, OrderedDict Link Here
16
from portage import _unicode_decode
16
from portage import _unicode_decode
17
from portage.const import PORTAGE_PACKAGE_ATOM
17
from portage.const import PORTAGE_PACKAGE_ATOM
18
from portage.dbapi import dbapi
18
from portage.dbapi import dbapi
19
from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use, _repo_separator
19
from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use
20
from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use
20
from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use
21
from portage.exception import InvalidAtom, InvalidDependString
21
from portage.exception import InvalidAtom, InvalidDependString
22
from portage.output import colorize, create_color_func, \
22
from portage.output import colorize, create_color_func, \
Lines 54-63 from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice Link Here
54
from _emerge.UnmergeDepPriority import UnmergeDepPriority
54
from _emerge.UnmergeDepPriority import UnmergeDepPriority
55
from _emerge.UseFlagDisplay import pkg_use_display
55
from _emerge.UseFlagDisplay import pkg_use_display
56
56
57
from _emerge.resolver.backtracking import Backtracker, BacktrackParameter
58
from _emerge.resolver.slot_collision import slot_conflict_handler
57
from _emerge.resolver.slot_collision import slot_conflict_handler
59
from _emerge.resolver.circular_dependency import circular_dependency_handler
58
from _emerge.resolver.circular_dependency import circular_dependency_handler
60
from _emerge.resolver.output import Display
59
from _emerge.resolver.output import display
61
60
62
if sys.hexversion >= 0x3000000:
61
if sys.hexversion >= 0x3000000:
63
	basestring = str
62
	basestring = str
Lines 122-136 class _depgraph_sets(object): Link Here
122
		# contains all sets added to the graph
121
		# contains all sets added to the graph
123
		self.sets = {}
122
		self.sets = {}
124
		# contains non-set atoms given as arguments
123
		# contains non-set atoms given as arguments
125
		self.sets['__non_set_args__'] = InternalPackageSet(allow_repo=True)
124
		self.sets['__non_set_args__'] = InternalPackageSet()
126
		# contains all atoms from all sets added to the graph, including
125
		# contains all atoms from all sets added to the graph, including
127
		# atoms given as arguments
126
		# atoms given as arguments
128
		self.atoms = InternalPackageSet(allow_repo=True)
127
		self.atoms = InternalPackageSet()
129
		self.atom_arg_map = {}
128
		self.atom_arg_map = {}
130
129
131
class _dynamic_depgraph_config(object):
130
class _dynamic_depgraph_config(object):
132
131
133
	def __init__(self, depgraph, myparams, allow_backtracking, backtrack_parameters):
132
	def __init__(self, depgraph, myparams, allow_backtracking,
133
		runtime_pkg_mask, needed_unstable_keywords, needed_use_config_changes, needed_license_changes):
134
		self.myparams = myparams.copy()
134
		self.myparams = myparams.copy()
135
		self._vdb_loaded = False
135
		self._vdb_loaded = False
136
		self._allow_backtracking = allow_backtracking
136
		self._allow_backtracking = allow_backtracking
Lines 198-215 class _dynamic_depgraph_config(object): Link Here
198
		self._ignored_deps = []
198
		self._ignored_deps = []
199
		self._highest_pkg_cache = {}
199
		self._highest_pkg_cache = {}
200
200
201
		self._needed_unstable_keywords = backtrack_parameters.needed_unstable_keywords
201
		if runtime_pkg_mask is None:
202
		self._needed_license_changes = backtrack_parameters.needed_license_changes
202
			runtime_pkg_mask = {}
203
		self._needed_use_config_changes = backtrack_parameters.needed_use_config_changes
203
		else:
204
		self._runtime_pkg_mask = backtrack_parameters.runtime_pkg_mask
204
			runtime_pkg_mask = dict((k, v.copy()) for (k, v) in \
205
				runtime_pkg_mask.items())
206
207
		if needed_unstable_keywords is None:
208
			self._needed_unstable_keywords = set()
209
		else:
210
			self._needed_unstable_keywords = needed_unstable_keywords.copy()
211
212
		if needed_license_changes is None:
213
			self._needed_license_changes = {}
214
		else:
215
			self._needed_license_changes = needed_license_changes.copy()
216
217
		if needed_use_config_changes is None:
218
			self._needed_use_config_changes = {}
219
		else:
220
			self._needed_use_config_changes = \
221
				dict((k.copy(), (v[0].copy(), v[1].copy())) for (k, v) in \
222
					needed_use_config_changes.items())
223
224
		self._autounmask = depgraph._frozen_config.myopts.get('--autounmask', 'n') == True
225
226
		self._runtime_pkg_mask = runtime_pkg_mask
205
		self._need_restart = False
227
		self._need_restart = False
206
		# For conditions that always require user intervention, such as
228
		# For conditions that always require user intervention, such as
207
		# unsatisfied REQUIRED_USE (currently has no autounmask support).
229
		# unsatisfied REQUIRED_USE (currently has no autounmask support).
208
		self._skip_restart = False
230
		self._skip_restart = False
209
		self._backtrack_infos = {}
210
211
		self._autounmask = depgraph._frozen_config.myopts.get('--autounmask', 'n') == True
212
		self._success_without_autounmask = False
213
231
214
		for myroot in depgraph._frozen_config.trees:
232
		for myroot in depgraph._frozen_config.trees:
215
			self.sets[myroot] = _depgraph_sets()
233
			self.sets[myroot] = _depgraph_sets()
Lines 288-300 class depgraph(object): Link Here
288
	_dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
306
	_dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
289
	
307
	
290
	def __init__(self, settings, trees, myopts, myparams, spinner,
308
	def __init__(self, settings, trees, myopts, myparams, spinner,
291
		frozen_config=None, backtrack_parameters=BacktrackParameter(), allow_backtracking=False):
309
		frozen_config=None, runtime_pkg_mask=None, needed_unstable_keywords=None, \
310
			needed_use_config_changes=None, needed_license_changes=None, allow_backtracking=False):
292
		if frozen_config is None:
311
		if frozen_config is None:
293
			frozen_config = _frozen_depgraph_config(settings, trees,
312
			frozen_config = _frozen_depgraph_config(settings, trees,
294
			myopts, spinner)
313
			myopts, spinner)
295
		self._frozen_config = frozen_config
314
		self._frozen_config = frozen_config
296
		self._dynamic_config = _dynamic_depgraph_config(self, myparams,
315
		self._dynamic_config = _dynamic_depgraph_config(self, myparams,
297
			allow_backtracking, backtrack_parameters)
316
			allow_backtracking, runtime_pkg_mask, needed_unstable_keywords, \
317
			needed_use_config_changes, needed_license_changes)
298
318
299
		self._select_atoms = self._select_atoms_highest_available
319
		self._select_atoms = self._select_atoms_highest_available
300
		self._select_package = self._select_pkg_highest_available
320
		self._select_package = self._select_pkg_highest_available
Lines 555-561 class depgraph(object): Link Here
555
					# PROVIDE when necessary, while match_from_list does not.
575
					# PROVIDE when necessary, while match_from_list does not.
556
					parent, atom = parent_atom
576
					parent, atom = parent_atom
557
					atom_set = InternalPackageSet(
577
					atom_set = InternalPackageSet(
558
						initial_atoms=(atom,), allow_repo=True)
578
						initial_atoms=(atom,))
559
					if atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)):
579
					if atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)):
560
						parent_atoms.add(parent_atom)
580
						parent_atoms.add(parent_atom)
561
					else:
581
					else:
Lines 705-718 class depgraph(object): Link Here
705
							(dep.parent,
725
							(dep.parent,
706
							self._dynamic_config._runtime_pkg_mask[
726
							self._dynamic_config._runtime_pkg_mask[
707
							dep.parent]), noiselevel=-1)
727
							dep.parent]), noiselevel=-1)
708
				elif not self.need_restart():
728
				else:
709
					# Do not backtrack if only USE have to be changed in
729
					# Do not backtrack if only USE have to be changed in
710
					# order to satisfy the dependency.
730
					# order to satisfy the dependency.
711
					dep_pkg, existing_node = \
731
					dep_pkg, existing_node = \
712
						self._select_package(dep.root, dep.atom.without_use,
732
						self._select_package(dep.root, dep.atom.without_use,
713
							onlydeps=dep.onlydeps)
733
							onlydeps=dep.onlydeps)
714
					if dep_pkg is None:
734
					if dep_pkg is None:
715
						self._dynamic_config._backtrack_infos["missing dependency"] = dep
735
						self._dynamic_config._runtime_pkg_mask.setdefault(
736
							dep.parent, {})["missing dependency"] = \
737
								set([(dep.parent, dep.root, dep.atom)])
716
						self._dynamic_config._need_restart = True
738
						self._dynamic_config._need_restart = True
717
						if "--debug" in self._frozen_config.myopts:
739
						if "--debug" in self._frozen_config.myopts:
718
							msg = []
740
							msg = []
Lines 743-749 class depgraph(object): Link Here
743
				# Use package set for matching since it will match via
765
				# Use package set for matching since it will match via
744
				# PROVIDE when necessary, while match_from_list does not.
766
				# PROVIDE when necessary, while match_from_list does not.
745
				matches = bool(InternalPackageSet(initial_atoms=(atom,),
767
				matches = bool(InternalPackageSet(initial_atoms=(atom,),
746
					allow_repo=True).findAtomForPackage(existing_node,
768
					).findAtomForPackage(existing_node,
747
					modified_use=self._pkg_use_enabled(existing_node)))
769
					modified_use=self._pkg_use_enabled(existing_node)))
748
770
749
		return (existing_node, matches)
771
		return (existing_node, matches)
Lines 869-881 class depgraph(object): Link Here
869
								self._dynamic_config._runtime_pkg_mask[
891
								self._dynamic_config._runtime_pkg_mask[
870
								existing_node]), noiselevel=-1)
892
								existing_node]), noiselevel=-1)
871
					elif self._dynamic_config._allow_backtracking and \
893
					elif self._dynamic_config._allow_backtracking and \
872
						not self._accept_blocker_conflicts() and \
894
						not self._accept_blocker_conflicts():
873
						not self.need_restart():
874
875
						self._add_slot_conflict(pkg)
895
						self._add_slot_conflict(pkg)
876
						if dep.atom is not None and dep.parent is not None:
896
						if dep.atom is not None and dep.parent is not None:
877
							self._add_parent_atom(pkg, (dep.parent, dep.atom))
897
							self._add_parent_atom(pkg, (dep.parent, dep.atom))
878
879
						if arg_atoms:
898
						if arg_atoms:
880
							for parent_atom in arg_atoms:
899
							for parent_atom in arg_atoms:
881
								parent, atom = parent_atom
900
								parent, atom = parent_atom
Lines 909-916 class depgraph(object): Link Here
909
928
910
							all_match = True
929
							all_match = True
911
							for parent, atom in parent_atoms:
930
							for parent, atom in parent_atoms:
912
								i = InternalPackageSet(initial_atoms=(atom,),
931
								i = InternalPackageSet(initial_atoms=(atom,))
913
									allow_repo=True)
914
								if not i.findAtomForPackage(to_be_masked):
932
								if not i.findAtomForPackage(to_be_masked):
915
									all_match = False
933
									all_match = False
916
									break
934
									break
Lines 947-955 class depgraph(object): Link Here
947
							elif pkg > existing_node:
965
							elif pkg > existing_node:
948
								backtrack_data.reverse()
966
								backtrack_data.reverse()
949
967
950
						to_be_masked = backtrack_data[-1][0]
968
						to_be_masked, parent_atoms = backtrack_data[-1]
951
969
952
						self._dynamic_config._backtrack_infos["slot conflict"] = backtrack_data
970
						self._dynamic_config._runtime_pkg_mask.setdefault(
971
							to_be_masked, {})["slot conflict"] = parent_atoms
953
						self._dynamic_config._need_restart = True
972
						self._dynamic_config._need_restart = True
954
						if "--debug" in self._frozen_config.myopts:
973
						if "--debug" in self._frozen_config.myopts:
955
							msg = []
974
							msg = []
Lines 1027-1036 class depgraph(object): Link Here
1027
				self._add_parent_atom(pkg, parent_atom)
1046
				self._add_parent_atom(pkg, parent_atom)
1028
1047
1029
		""" This section determines whether we go deeper into dependencies or not.
1048
		""" This section determines whether we go deeper into dependencies or not.
1030
			We want to go deeper on a few occasions:
1049
		    We want to go deeper on a few occasions:
1031
			Installing package A, we need to make sure package A's deps are met.
1050
		    Installing package A, we need to make sure package A's deps are met.
1032
			emerge --deep <pkgspec>; we need to recursively check dependencies of pkgspec
1051
		    emerge --deep <pkgspec>; we need to recursively check dependencies of pkgspec
1033
			If we are in --nodeps (no recursion) mode, we obviously only check 1 level of dependencies.
1052
		    If we are in --nodeps (no recursion) mode, we obviously only check 1 level of dependencies.
1034
		"""
1053
		"""
1035
		if arg_atoms:
1054
		if arg_atoms:
1036
			depth = 0
1055
			depth = 0
Lines 1445-1452 class depgraph(object): Link Here
1445
				for atom in pkg_atom_map[pkg1]:
1464
				for atom in pkg_atom_map[pkg1]:
1446
					cp_atoms.add(atom)
1465
					cp_atoms.add(atom)
1447
					atom_pkg_graph.add(pkg1, atom)
1466
					atom_pkg_graph.add(pkg1, atom)
1448
					atom_set = InternalPackageSet(initial_atoms=(atom,),
1467
					atom_set = InternalPackageSet(initial_atoms=(atom,))
1449
						allow_repo=True)
1450
					for pkg2 in pkgs:
1468
					for pkg2 in pkgs:
1451
						if pkg2 is pkg1:
1469
						if pkg2 is pkg1:
1452
							continue
1470
							continue
Lines 1570-1576 class depgraph(object): Link Here
1570
		deps = []
1588
		deps = []
1571
		for cat in categories:
1589
		for cat in categories:
1572
			deps.append(Atom(insert_category_into_atom(
1590
			deps.append(Atom(insert_category_into_atom(
1573
				atom_without_category, cat), allow_repo=True))
1591
				atom_without_category, cat)))
1574
		return deps
1592
		return deps
1575
1593
1576
	def _have_new_virt(self, root, atom_cp):
1594
	def _have_new_virt(self, root, atom_cp):
Lines 1690-1697 class depgraph(object): Link Here
1690
					raise portage.exception.PackageNotFound(
1708
					raise portage.exception.PackageNotFound(
1691
						"%s is not in a valid portage tree hierarchy or does not exist" % x)
1709
						"%s is not in a valid portage tree hierarchy or does not exist" % x)
1692
				pkg = self._pkg(mykey, "ebuild", root_config,
1710
				pkg = self._pkg(mykey, "ebuild", root_config,
1693
					onlydeps=onlydeps, myrepo=portdb.getRepositoryName(
1711
					onlydeps=onlydeps)
1694
					os.path.dirname(os.path.dirname(os.path.dirname(ebuild_path)))))
1695
				args.append(PackageArg(arg=x, package=pkg,
1712
				args.append(PackageArg(arg=x, package=pkg,
1696
					root_config=root_config))
1713
					root_config=root_config))
1697
			elif x.startswith(os.path.sep):
1714
			elif x.startswith(os.path.sep):
Lines 1726-1732 class depgraph(object): Link Here
1726
					args.append(SetArg(arg=x, pset=pset,
1743
					args.append(SetArg(arg=x, pset=pset,
1727
						root_config=root_config))
1744
						root_config=root_config))
1728
					continue
1745
					continue
1729
				if not is_valid_package_atom(x, allow_repo=True):
1746
				if not is_valid_package_atom(x):
1730
					portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x,
1747
					portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x,
1731
						noiselevel=-1)
1748
						noiselevel=-1)
1732
					portage.writemsg("!!! Please check ebuild(5) for full details.\n")
1749
					portage.writemsg("!!! Please check ebuild(5) for full details.\n")
Lines 1741-1747 class depgraph(object): Link Here
1741
				#   2) It takes away freedom from the resolver to choose other
1758
				#   2) It takes away freedom from the resolver to choose other
1742
				#      possible expansions when necessary.
1759
				#      possible expansions when necessary.
1743
				if "/" in x:
1760
				if "/" in x:
1744
					args.append(AtomArg(arg=x, atom=Atom(x, allow_repo=True),
1761
					args.append(AtomArg(arg=x, atom=Atom(x),
1745
						root_config=root_config))
1762
						root_config=root_config))
1746
					continue
1763
					continue
1747
				expanded_atoms = self._dep_expand(root_config, x)
1764
				expanded_atoms = self._dep_expand(root_config, x)
Lines 1794-1807 class depgraph(object): Link Here
1794
				if expanded_atoms:
1811
				if expanded_atoms:
1795
					atom = expanded_atoms[0]
1812
					atom = expanded_atoms[0]
1796
				else:
1813
				else:
1797
					null_atom = Atom(insert_category_into_atom(x, "null"),
1814
					null_atom = Atom(insert_category_into_atom(x, "null"))
1798
						allow_repo=True)
1799
					cat, atom_pn = portage.catsplit(null_atom.cp)
1815
					cat, atom_pn = portage.catsplit(null_atom.cp)
1800
					virts_p = root_config.settings.get_virts_p().get(atom_pn)
1816
					virts_p = root_config.settings.get_virts_p().get(atom_pn)
1801
					if virts_p:
1817
					if virts_p:
1802
						# Allow the depgraph to choose which virtual.
1818
						# Allow the depgraph to choose which virtual.
1803
						atom = Atom(null_atom.replace('null/', 'virtual/', 1),
1819
						atom = Atom(null_atom.replace('null/', 'virtual/', 1))
1804
							allow_repo=True)
1805
					else:
1820
					else:
1806
						atom = null_atom
1821
						atom = null_atom
1807
1822
Lines 2030-2036 class depgraph(object): Link Here
2030
			set(self._dynamic_config.digraph).intersection( \
2045
			set(self._dynamic_config.digraph).intersection( \
2031
			self._dynamic_config._needed_license_changes) :
2046
			self._dynamic_config._needed_license_changes) :
2032
			#We failed if the user needs to change the configuration
2047
			#We failed if the user needs to change the configuration
2033
			self._dynamic_config._success_without_autounmask = True
2034
			return False, myfavorites
2048
			return False, myfavorites
2035
2049
2036
		# We're true here unless we are missing binaries.
2050
		# We're true here unless we are missing binaries.
Lines 2049-2055 class depgraph(object): Link Here
2049
		for root in self._dynamic_config.sets:
2063
		for root in self._dynamic_config.sets:
2050
			depgraph_sets = self._dynamic_config.sets[root]
2064
			depgraph_sets = self._dynamic_config.sets[root]
2051
			depgraph_sets.sets.setdefault('__non_set_args__',
2065
			depgraph_sets.sets.setdefault('__non_set_args__',
2052
				InternalPackageSet(allow_repo=True)).clear()
2066
				InternalPackageSet()).clear()
2053
			depgraph_sets.atoms.clear()
2067
			depgraph_sets.atoms.clear()
2054
			depgraph_sets.atom_arg_map.clear()
2068
			depgraph_sets.atom_arg_map.clear()
2055
			set_atoms[root] = []
2069
			set_atoms[root] = []
Lines 2294-2305 class depgraph(object): Link Here
2294
		if target_atom is not None and isinstance(node, Package):
2308
		if target_atom is not None and isinstance(node, Package):
2295
			affecting_use = set()
2309
			affecting_use = set()
2296
			for dep_str in "DEPEND", "RDEPEND", "PDEPEND":
2310
			for dep_str in "DEPEND", "RDEPEND", "PDEPEND":
2297
				try:
2311
				affecting_use.update(extract_affecting_use(
2298
					affecting_use.update(extract_affecting_use(
2312
					node.metadata[dep_str], target_atom))
2299
						node.metadata[dep_str], target_atom))
2300
				except InvalidDependString:
2301
					if not node.installed:
2302
						raise
2303
			affecting_use.difference_update(node.use.mask, node.use.force)
2313
			affecting_use.difference_update(node.use.mask, node.use.force)
2304
			pkg_name = _unicode_decode("%s") % (node.cpv,)
2314
			pkg_name = _unicode_decode("%s") % (node.cpv,)
2305
			if affecting_use:
2315
			if affecting_use:
Lines 2430-2437 class depgraph(object): Link Here
2430
		a matching package has been masked by backtracking.
2440
		a matching package has been masked by backtracking.
2431
		"""
2441
		"""
2432
		backtrack_mask = False
2442
		backtrack_mask = False
2433
		atom_set = InternalPackageSet(initial_atoms=(atom.without_use,),
2443
		atom_set = InternalPackageSet(initial_atoms=(atom.without_use,))
2434
			allow_repo=True)
2435
		xinfo = '"%s"' % atom.unevaluated_atom
2444
		xinfo = '"%s"' % atom.unevaluated_atom
2436
		if arg:
2445
		if arg:
2437
			xinfo='"%s"' % arg
2446
			xinfo='"%s"' % arg
Lines 2459-2531 class depgraph(object): Link Here
2459
				continue
2468
				continue
2460
			match = db.match
2469
			match = db.match
2461
			if hasattr(db, "xmatch"):
2470
			if hasattr(db, "xmatch"):
2462
				cpv_list = db.xmatch("match-all-cpv-only", atom.without_use)
2471
				cpv_list = db.xmatch("match-all", atom.without_use)
2463
			else:
2472
			else:
2464
				cpv_list = db.match(atom.without_use)
2473
				cpv_list = db.match(atom.without_use)
2465
2466
			if atom.repo is None and hasattr(db, "getRepositories"):
2467
				repo_list = db.getRepositories()
2468
			else:
2469
				repo_list = [atom.repo]
2470
2471
			# descending order
2474
			# descending order
2472
			cpv_list.reverse()
2475
			cpv_list.reverse()
2473
			for cpv in cpv_list:
2476
			for cpv in cpv_list:
2474
				for repo in repo_list:
2477
				metadata, mreasons  = get_mask_info(root_config, cpv, pkgsettings, db, \
2475
					if not db.cpv_exists(cpv, myrepo=repo):
2478
					pkg_type, built, installed, db_keys, _pkg_use_enabled=self._pkg_use_enabled)
2476
						continue
2479
2477
2480
				if metadata is not None:
2478
					metadata, mreasons  = get_mask_info(root_config, cpv, pkgsettings, db, pkg_type, \
2481
					pkg = self._pkg(cpv, pkg_type, root_config,
2479
						built, installed, db_keys, myrepo=repo, _pkg_use_enabled=self._pkg_use_enabled)
2482
						installed=installed)
2480
2483
					# pkg.metadata contains calculated USE for ebuilds,
2481
					if metadata is not None:
2484
					# required later for getMissingLicenses.
2482
						if not repo:
2485
					metadata = pkg.metadata
2483
							repo = metadata.get('repository')
2486
					if pkg.cp != atom.cp:
2484
						pkg = self._pkg(cpv, pkg_type, root_config,
2487
						# A cpv can be returned from dbapi.match() as an
2485
							installed=installed, myrepo=repo)
2488
						# old-style virtual match even in cases when the
2486
						if not atom_set.findAtomForPackage(pkg,
2489
						# package does not actually PROVIDE the virtual.
2487
							modified_use=self._pkg_use_enabled(pkg)):
2490
						# Filter out any such false matches here.
2491
						if not atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)):
2488
							continue
2492
							continue
2489
						# pkg.metadata contains calculated USE for ebuilds,
2493
					if pkg in self._dynamic_config._runtime_pkg_mask:
2490
						# required later for getMissingLicenses.
2494
						backtrack_reasons = \
2491
						metadata = pkg.metadata
2495
							self._dynamic_config._runtime_pkg_mask[pkg]
2492
						if pkg in self._dynamic_config._runtime_pkg_mask:
2496
						mreasons.append('backtracking: %s' % \
2493
							backtrack_reasons = \
2497
							', '.join(sorted(backtrack_reasons)))
2494
								self._dynamic_config._runtime_pkg_mask[pkg]
2498
						backtrack_mask = True
2495
							mreasons.append('backtracking: %s' % \
2499
					if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \
2496
								', '.join(sorted(backtrack_reasons)))
2500
						modified_use=self._pkg_use_enabled(pkg)):
2497
							backtrack_mask = True
2501
						mreasons = ["exclude option"]
2498
						if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \
2502
					if mreasons:
2499
							modified_use=self._pkg_use_enabled(pkg)):
2503
						masked_pkg_instances.add(pkg)
2500
							mreasons = ["exclude option"]
2504
					if atom.unevaluated_atom.use:
2501
						if mreasons:
2505
						try:
2502
							masked_pkg_instances.add(pkg)
2506
							if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \
2503
						if atom.unevaluated_atom.use:
2507
								or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use:
2504
							try:
2508
								missing_use.append(pkg)
2505
								if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \
2509
								if not mreasons:
2506
									or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use:
2510
									continue
2507
									missing_use.append(pkg)
2511
						except InvalidAtom:
2508
									if not mreasons:
2512
							writemsg("violated_conditionals raised " + \
2509
										continue
2513
								"InvalidAtom: '%s' parent: %s" % \
2510
							except InvalidAtom:
2514
								(atom, myparent), noiselevel=-1)
2511
								writemsg("violated_conditionals raised " + \
2515
							raise
2512
									"InvalidAtom: '%s' parent: %s" % \
2516
					if not mreasons and \
2513
									(atom, myparent), noiselevel=-1)
2517
						not pkg.built and \
2514
								raise
2518
						pkg.metadata["REQUIRED_USE"] and \
2515
						if not mreasons and \
2519
						eapi_has_required_use(pkg.metadata["EAPI"]):
2516
							not pkg.built and \
2520
						if not check_required_use(
2517
							pkg.metadata["REQUIRED_USE"] and \
2521
							pkg.metadata["REQUIRED_USE"],
2518
							eapi_has_required_use(pkg.metadata["EAPI"]):
2522
							self._pkg_use_enabled(pkg),
2519
							if not check_required_use(
2523
							pkg.iuse.is_valid_flag):
2520
								pkg.metadata["REQUIRED_USE"],
2524
							required_use_unsatisfied.append(pkg)
2521
								self._pkg_use_enabled(pkg),
2525
							continue
2522
								pkg.iuse.is_valid_flag):
2526
					if pkg.built and not mreasons:
2523
								required_use_unsatisfied.append(pkg)
2527
						mreasons = ["use flag configuration mismatch"]
2524
								continue
2528
				masked_packages.append(
2525
						if pkg.built and not mreasons:
2529
					(root_config, pkgsettings, cpv, metadata, mreasons))
2526
							mreasons = ["use flag configuration mismatch"]
2527
					masked_packages.append(
2528
						(root_config, pkgsettings, cpv, repo, metadata, mreasons))
2529
2530
2530
		if check_backtrack:
2531
		if check_backtrack:
2531
			if backtrack_mask:
2532
			if backtrack_mask:
Lines 2688-2694 class depgraph(object): Link Here
2688
			# that the user wants the latest version, so only the first
2689
			# that the user wants the latest version, so only the first
2689
			# instance is displayed.
2690
			# instance is displayed.
2690
			pkg = required_use_unsatisfied[0]
2691
			pkg = required_use_unsatisfied[0]
2691
			output_cpv = pkg.cpv + _repo_separator + pkg.repo
2692
			output_cpv = pkg.cpv
2692
			writemsg_stdout("\n!!! " + \
2693
			writemsg_stdout("\n!!! " + \
2693
				colorize("BAD", "The ebuild selected to satisfy ") + \
2694
				colorize("BAD", "The ebuild selected to satisfy ") + \
2694
				colorize("INFORM", xinfo) + \
2695
				colorize("INFORM", xinfo) + \
Lines 2741-2747 class depgraph(object): Link Here
2741
			mask_docs = True
2742
			mask_docs = True
2742
		else:
2743
		else:
2743
			writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1)
2744
			writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1)
2744
			if isinstance(myparent, AtomArg):
2745
2746
			if self._frozen_config.myopts.get('--misspell-suggestions', 'y') == 'y' and \
2747
				isinstance(myparent, AtomArg):
2745
				cp = myparent.atom.cp.lower()
2748
				cp = myparent.atom.cp.lower()
2746
				cat, pkg = portage.catsplit(cp)
2749
				cat, pkg = portage.catsplit(cp)
2747
				if cat == "null":
2750
				if cat == "null":
Lines 2827-2840 class depgraph(object): Link Here
2827
		db = root_config.trees[self.pkg_tree_map[pkg_type]].dbapi
2830
		db = root_config.trees[self.pkg_tree_map[pkg_type]].dbapi
2828
2831
2829
		if hasattr(db, "xmatch"):
2832
		if hasattr(db, "xmatch"):
2830
			# For portdbapi we match only against the cpv, in order
2833
			cpv_list = db.xmatch("match-all", atom)
2831
			# to bypass unnecessary cache access for things like IUSE
2832
			# and SLOT. Later, we cache the metadata in a Package
2833
			# instance, and use that for further matching. This
2834
			# optimization is especially relevant since
2835
			# pordbapi.aux_get() does not cache calls that have
2836
			# myrepo or mytree arguments.
2837
			cpv_list = db.xmatch("match-all-cpv-only", atom)
2838
		else:
2834
		else:
2839
			cpv_list = db.match(atom)
2835
			cpv_list = db.match(atom)
2840
2836
Lines 2861-2867 class depgraph(object): Link Here
2861
				if not slot_available:
2857
				if not slot_available:
2862
					continue
2858
					continue
2863
				inst_pkg = self._pkg(cpv, "installed",
2859
				inst_pkg = self._pkg(cpv, "installed",
2864
					root_config, installed=installed, myrepo = atom.repo)
2860
					root_config, installed=installed)
2865
				# Remove the slot from the atom and verify that
2861
				# Remove the slot from the atom and verify that
2866
				# the package matches the resulting atom.
2862
				# the package matches the resulting atom.
2867
				if portage.match_from_list(
2863
				if portage.match_from_list(
Lines 2870-2908 class depgraph(object): Link Here
2870
					return
2866
					return
2871
2867
2872
		if cpv_list:
2868
		if cpv_list:
2873
			atom_set = InternalPackageSet(initial_atoms=(atom,),
2874
				allow_repo=True)
2875
			if atom.repo is None and hasattr(db, "getRepositories"):
2876
				repo_list = db.getRepositories()
2877
			else:
2878
				repo_list = [atom.repo]
2879
2869
2880
			# descending order
2870
			# descending order
2881
			cpv_list.reverse()
2871
			cpv_list.reverse()
2882
			for cpv in cpv_list:
2872
			for cpv in cpv_list:
2883
				for repo in repo_list:
2873
				try:
2884
2874
					pkg = self._pkg(cpv, pkg_type, root_config,
2885
					try:
2875
						installed=installed, onlydeps=onlydeps)
2886
						pkg = self._pkg(cpv, pkg_type, root_config,
2876
				except portage.exception.PackageNotFound:
2887
							installed=installed, onlydeps=onlydeps, myrepo=repo)
2877
					pass
2888
					except portage.exception.PackageNotFound:
2878
				else:
2889
						pass
2879
					if pkg.cp != atom.cp:
2890
					else:
2891
						# A cpv can be returned from dbapi.match() as an
2880
						# A cpv can be returned from dbapi.match() as an
2892
						# old-style virtual match even in cases when the
2881
						# old-style virtual match even in cases when the
2893
						# package does not actually PROVIDE the virtual.
2882
						# package does not actually PROVIDE the virtual.
2894
						# Filter out any such false matches here.
2883
						# Filter out any such false matches here.
2895
2884
						if not InternalPackageSet(initial_atoms=(atom,)
2896
						# Make sure that cpv from the current repo satisfies the atom.
2885
							).findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)):
2897
						# This might not be the case if there are several repos with
2898
						# the same cpv, but different metadata keys, like SLOT.
2899
						# Also, for portdbapi, parts of the match that require
2900
						# metadata access are deferred until we have cached the
2901
						# metadata in a Package instance.
2902
						if not atom_set.findAtomForPackage(pkg,
2903
							modified_use=self._pkg_use_enabled(pkg)):
2904
							continue
2886
							continue
2905
						yield pkg
2887
					yield pkg
2906
2888
2907
	def _select_pkg_highest_available(self, root, atom, onlydeps=False):
2889
	def _select_pkg_highest_available(self, root, atom, onlydeps=False):
2908
		cache_key = (root, atom, onlydeps)
2890
		cache_key = (root, atom, onlydeps)
Lines 3032-3049 class depgraph(object): Link Here
3032
3014
3033
		if masked_by_unstable_keywords:
3015
		if masked_by_unstable_keywords:
3034
			self._dynamic_config._needed_unstable_keywords.add(pkg)
3016
			self._dynamic_config._needed_unstable_keywords.add(pkg)
3035
			backtrack_infos = self._dynamic_config._backtrack_infos
3036
			backtrack_infos.setdefault("config", {})
3037
			backtrack_infos["config"].setdefault("needed_unstable_keywords", set())
3038
			backtrack_infos["config"]["needed_unstable_keywords"].add(pkg)
3039
			
3040
3017
3041
		if missing_licenses:
3018
		if missing_licenses:
3042
			self._dynamic_config._needed_license_changes.setdefault(pkg, set()).update(missing_licenses)
3019
			self._dynamic_config._needed_license_changes.setdefault(pkg, set()).update(missing_licenses)
3043
			backtrack_infos = self._dynamic_config._backtrack_infos
3044
			backtrack_infos.setdefault("config", {})
3045
			backtrack_infos["config"].setdefault("needed_license_changes", set())
3046
			backtrack_infos["config"]["needed_license_changes"].add((pkg, frozenset(missing_licenses)))
3047
3020
3048
		return True
3021
		return True
3049
3022
Lines 3119-3130 class depgraph(object): Link Here
3119
			if required_use and check_required_use(required_use, old_use, pkg.iuse.is_valid_flag) and \
3092
			if required_use and check_required_use(required_use, old_use, pkg.iuse.is_valid_flag) and \
3120
				not check_required_use(required_use, new_use, pkg.iuse.is_valid_flag):
3093
				not check_required_use(required_use, new_use, pkg.iuse.is_valid_flag):
3121
				return old_use
3094
				return old_use
3122
3095
			
3123
			self._dynamic_config._needed_use_config_changes[pkg] = (new_use, new_changes)
3096
			self._dynamic_config._needed_use_config_changes[pkg] = (new_use, new_changes)
3124
			backtrack_infos = self._dynamic_config._backtrack_infos
3125
			backtrack_infos.setdefault("config", {})
3126
			backtrack_infos["config"].setdefault("needed_use_config_changes", [])
3127
			backtrack_infos["config"]["needed_use_config_changes"].append((pkg, (new_use, new_changes)))
3128
			if want_restart_for_use_change(pkg, new_use):
3097
			if want_restart_for_use_change(pkg, new_use):
3129
				self._dynamic_config._need_restart = True
3098
				self._dynamic_config._need_restart = True
3130
		return new_use
3099
		return new_use
Lines 3143-3149 class depgraph(object): Link Here
3143
		if not isinstance(atom, portage.dep.Atom):
3112
		if not isinstance(atom, portage.dep.Atom):
3144
			atom = portage.dep.Atom(atom)
3113
			atom = portage.dep.Atom(atom)
3145
		atom_cp = atom.cp
3114
		atom_cp = atom.cp
3146
		atom_set = InternalPackageSet(initial_atoms=(atom,), allow_repo=True)
3115
		atom_set = InternalPackageSet(initial_atoms=(atom,))
3147
		existing_node = None
3116
		existing_node = None
3148
		myeb = None
3117
		myeb = None
3149
		rebuilt_binaries = 'rebuilt_binaries' in self._dynamic_config.myparams
3118
		rebuilt_binaries = 'rebuilt_binaries' in self._dynamic_config.myparams
Lines 3203-3224 class depgraph(object): Link Here
3203
						# list only contains unbuilt ebuilds since USE can't
3172
						# list only contains unbuilt ebuilds since USE can't
3204
						# be changed for built packages.
3173
						# be changed for built packages.
3205
						higher_version_rejected = False
3174
						higher_version_rejected = False
3206
						repo_priority = pkg.repo_priority
3207
						for rejected in packages_with_invalid_use_config:
3175
						for rejected in packages_with_invalid_use_config:
3208
							if rejected.cp != pkg.cp:
3176
							if rejected.cp != pkg.cp:
3209
								continue
3177
								continue
3210
							if rejected > pkg:
3178
							if rejected > pkg:
3211
								higher_version_rejected = True
3179
								higher_version_rejected = True
3212
								break
3180
								break
3213
							if portage.dep.cpvequal(rejected.cpv, pkg.cpv):
3214
								# If version is identical then compare
3215
								# repo priority (see bug #350254).
3216
								rej_repo_priority = rejected.repo_priority
3217
								if rej_repo_priority is not None and \
3218
									(repo_priority is None or
3219
									rej_repo_priority > repo_priority):
3220
									higher_version_rejected = True
3221
									break
3222
						if higher_version_rejected:
3181
						if higher_version_rejected:
3223
							continue
3182
							continue
3224
3183
Lines 3284-3301 class depgraph(object): Link Here
3284
								else:
3243
								else:
3285
									try:
3244
									try:
3286
										pkg_eb = self._pkg(
3245
										pkg_eb = self._pkg(
3287
											pkg.cpv, "ebuild", root_config, myrepo=pkg.repo)
3246
											pkg.cpv, "ebuild", root_config)
3288
									except portage.exception.PackageNotFound:
3247
									except portage.exception.PackageNotFound:
3289
										pkg_eb_visible = False
3248
										continue
3290
										for pkg_eb in self._iter_match_pkgs(pkg.root_config,
3291
											"ebuild", Atom("=%s" % (pkg.cpv,))):
3292
											if self._pkg_visibility_check(pkg_eb, \
3293
												allow_unstable_keywords=allow_unstable_keywords,
3294
												allow_license_changes=allow_license_changes):
3295
												pkg_eb_visible = True
3296
												break
3297
										if not pkg_eb_visible:
3298
											continue
3299
									else:
3249
									else:
3300
										if not self._pkg_visibility_check(pkg_eb, \
3250
										if not self._pkg_visibility_check(pkg_eb, \
3301
											allow_unstable_keywords=allow_unstable_keywords,
3251
											allow_unstable_keywords=allow_unstable_keywords,
Lines 3732-3756 class depgraph(object): Link Here
3732
		return 1
3682
		return 1
3733
3683
3734
	def _pkg(self, cpv, type_name, root_config, installed=False, 
3684
	def _pkg(self, cpv, type_name, root_config, installed=False, 
3735
		onlydeps=False, myrepo = None):
3685
		onlydeps=False):
3736
		"""
3686
		"""
3737
		Get a package instance from the cache, or create a new
3687
		Get a package instance from the cache, or create a new
3738
		one if necessary. Raises PackageNotFound from aux_get if it
3688
		one if necessary. Raises PackageNotFound from aux_get if it
3739
		failures for some reason (package does not exist or is
3689
		failures for some reason (package does not exist or is
3740
		corrupt).
3690
		corrupt).
3741
		"""
3691
		"""
3742
		if type_name != "ebuild":
3743
			# For installed (and binary) packages we don't care for the repo
3744
			# when it comes to hashing, because there can only be one cpv.
3745
			# So overwrite the repo_key with type_name.
3746
			repo_key = type_name
3747
			myrepo = None
3748
		elif myrepo is None:
3749
			raise AssertionError(
3750
				"depgraph._pkg() called without 'myrepo' argument")
3751
		else:
3752
			repo_key = myrepo
3753
3754
		operation = "merge"
3692
		operation = "merge"
3755
		if installed or onlydeps:
3693
		if installed or onlydeps:
3756
			operation = "nomerge"
3694
			operation = "nomerge"
Lines 3758-3784 class depgraph(object): Link Here
3758
		# that refers to FakeVartree instead of the real vartree.
3696
		# that refers to FakeVartree instead of the real vartree.
3759
		root_config = self._frozen_config.roots[root_config.root]
3697
		root_config = self._frozen_config.roots[root_config.root]
3760
		pkg = self._frozen_config._pkg_cache.get(
3698
		pkg = self._frozen_config._pkg_cache.get(
3761
			(type_name, root_config.root, cpv, operation, repo_key))
3699
			(type_name, root_config.root, cpv, operation))
3762
		if pkg is None and onlydeps and not installed:
3700
		if pkg is None and onlydeps and not installed:
3763
			# Maybe it already got pulled in as a "merge" node.
3701
			# Maybe it already got pulled in as a "merge" node.
3764
			pkg = self._dynamic_config.mydbapi[root_config.root].get(
3702
			pkg = self._dynamic_config.mydbapi[root_config.root].get(
3765
				(type_name, root_config.root, cpv, 'merge', repo_key))
3703
				(type_name, root_config.root, cpv, 'merge'))
3766
3704
3767
		if pkg is None:
3705
		if pkg is None:
3768
			tree_type = self.pkg_tree_map[type_name]
3706
			tree_type = self.pkg_tree_map[type_name]
3769
			db = root_config.trees[tree_type].dbapi
3707
			db = root_config.trees[tree_type].dbapi
3770
			db_keys = list(self._frozen_config._trees_orig[root_config.root][
3708
			db_keys = list(self._frozen_config._trees_orig[root_config.root][
3771
				tree_type].dbapi._aux_cache_keys)
3709
				tree_type].dbapi._aux_cache_keys)
3772
3773
			try:
3710
			try:
3774
				metadata = zip(db_keys, db.aux_get(cpv, db_keys, myrepo=myrepo))
3711
				metadata = zip(db_keys, db.aux_get(cpv, db_keys))
3775
			except KeyError:
3712
			except KeyError:
3776
				raise portage.exception.PackageNotFound(cpv)
3713
				raise portage.exception.PackageNotFound(cpv)
3777
3778
			pkg = Package(built=(type_name != "ebuild"), cpv=cpv,
3714
			pkg = Package(built=(type_name != "ebuild"), cpv=cpv,
3779
				installed=installed, metadata=metadata, onlydeps=onlydeps,
3715
				installed=installed, metadata=metadata, onlydeps=onlydeps,
3780
				root_config=root_config, type_name=type_name)
3716
				root_config=root_config, type_name=type_name)
3781
3782
			self._frozen_config._pkg_cache[pkg] = pkg
3717
			self._frozen_config._pkg_cache[pkg] = pkg
3783
3718
3784
			if not self._pkg_visibility_check(pkg) and \
3719
			if not self._pkg_visibility_check(pkg) and \
Lines 4192-4207 class depgraph(object): Link Here
4192
		graph = self._dynamic_config._scheduler_graph
4127
		graph = self._dynamic_config._scheduler_graph
4193
		trees = self._frozen_config.trees
4128
		trees = self._frozen_config.trees
4194
		pruned_pkg_cache = {}
4129
		pruned_pkg_cache = {}
4195
		for key, pkg in pkg_cache.items():
4130
		for pkg in pkg_cache:
4196
			if pkg in graph or \
4131
			if pkg in graph or \
4197
				(pkg.installed and pkg in trees[pkg.root]['vartree'].dbapi):
4132
				(pkg.installed and pkg in trees[pkg.root]['vartree'].dbapi):
4198
				pruned_pkg_cache[key] = pkg
4133
				pruned_pkg_cache[pkg] = pkg
4199
4134
4200
		for root in trees:
4135
		for root in trees:
4201
			trees[root]['vartree']._pkg_cache = pruned_pkg_cache
4136
			trees[root]['vartree']._pkg_cache = pruned_pkg_cache
4202
			self.break_refs(trees[root]['vartree'].dbapi)
4137
			self.break_refs(trees[root]['vartree'].dbapi)
4203
4138
4204
		self.break_refs(pruned_pkg_cache.values())
4139
		self.break_refs(pruned_pkg_cache)
4205
		sched_config = \
4140
		sched_config = \
4206
			_scheduler_graph_config(trees, pruned_pkg_cache, graph, mergelist)
4141
			_scheduler_graph_config(trees, pruned_pkg_cache, graph, mergelist)
4207
4142
Lines 5092-5098 class depgraph(object): Link Here
5092
		# redundantly displaying this exact same merge list
5027
		# redundantly displaying this exact same merge list
5093
		# again via _show_merge_list().
5028
		# again via _show_merge_list().
5094
		self._dynamic_config._displayed_list = mylist
5029
		self._dynamic_config._displayed_list = mylist
5095
		display = Display()
5096
5030
5097
		return display(self, mylist, favorites, verbosity)
5031
		return display(self, mylist, favorites, verbosity)
5098
5032
Lines 5272-5278 class depgraph(object): Link Here
5272
			pkgsettings = self._frozen_config.pkgsettings[pkg.root]
5206
			pkgsettings = self._frozen_config.pkgsettings[pkg.root]
5273
			mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled(pkg))
5207
			mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled(pkg))
5274
			masked_packages.append((root_config, pkgsettings,
5208
			masked_packages.append((root_config, pkgsettings,
5275
				pkg.cpv, pkg.repo, pkg.metadata, mreasons))
5209
				pkg.cpv, pkg.metadata, mreasons))
5276
		if masked_packages:
5210
		if masked_packages:
5277
			writemsg("\n" + colorize("BAD", "!!!") + \
5211
			writemsg("\n" + colorize("BAD", "!!!") + \
5278
				" The following updates are masked by LICENSE changes:\n",
5212
				" The following updates are masked by LICENSE changes:\n",
Lines 5287-5293 class depgraph(object): Link Here
5287
			pkgsettings = self._frozen_config.pkgsettings[pkg.root]
5221
			pkgsettings = self._frozen_config.pkgsettings[pkg.root]
5288
			mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled)
5222
			mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled)
5289
			masked_packages.append((root_config, pkgsettings,
5223
			masked_packages.append((root_config, pkgsettings,
5290
				pkg.cpv, pkg.repo, pkg.metadata, mreasons))
5224
				pkg.cpv, pkg.metadata, mreasons))
5291
		if masked_packages:
5225
		if masked_packages:
5292
			writemsg("\n" + colorize("BAD", "!!!") + \
5226
			writemsg("\n" + colorize("BAD", "!!!") + \
5293
				" The following installed packages are masked:\n",
5227
				" The following installed packages are masked:\n",
Lines 5378-5391 class depgraph(object): Link Here
5378
		if not isinstance(mergelist, list):
5312
		if not isinstance(mergelist, list):
5379
			mergelist = []
5313
			mergelist = []
5380
5314
5381
		favorites = resume_data.get("favorites")
5382
		args_set = self._dynamic_config.sets[
5383
			self._frozen_config.target_root].sets['__non_set_args__']
5384
		if isinstance(favorites, list):
5385
			args = self._load_favorites(favorites)
5386
		else:
5387
			args = []
5388
5389
		fakedb = self._dynamic_config.mydbapi
5315
		fakedb = self._dynamic_config.mydbapi
5390
		trees = self._frozen_config.trees
5316
		trees = self._frozen_config.trees
5391
		serialized_tasks = []
5317
		serialized_tasks = []
Lines 5399-5437 class depgraph(object): Link Here
5399
			if action != "merge":
5325
			if action != "merge":
5400
				continue
5326
				continue
5401
			root_config = self._frozen_config.roots[myroot]
5327
			root_config = self._frozen_config.roots[myroot]
5402
5403
			# Use the resume "favorites" list to see if a repo was specified
5404
			# for this package.
5405
			depgraph_sets = self._dynamic_config.sets[root_config.root]
5406
			repo = None
5407
			for atom in depgraph_sets.atoms.getAtoms():
5408
				if atom.repo and portage.dep.match_from_list(atom, [pkg_key]):
5409
					repo = atom.repo
5410
					break
5411
5412
			atom = "=" + pkg_key
5413
			if repo:
5414
				atom = atom + _repo_separator + repo
5415
5416
			try:
5328
			try:
5417
				atom = Atom(atom, allow_repo=True)
5329
				pkg = self._pkg(pkg_key, pkg_type, root_config)
5418
			except InvalidAtom:
5330
			except portage.exception.PackageNotFound:
5419
				continue
5420
5421
			pkg = None
5422
			for pkg in self._iter_match_pkgs(root_config, pkg_type, atom):
5423
				if not self._pkg_visibility_check(pkg) or \
5424
					self._frozen_config.excluded_pkgs.findAtomForPackage(pkg,
5425
						modified_use=self._pkg_use_enabled(pkg)):
5426
					continue
5427
				break
5428
5429
			if pkg is None:
5430
				# It does no exist or it is corrupt.
5331
				# It does no exist or it is corrupt.
5431
				if skip_missing:
5332
				if skip_missing:
5432
					# TODO: log these somewhere
5333
					# TODO: log these somewhere
5433
					continue
5334
					continue
5434
				raise portage.exception.PackageNotFound(pkg_key)
5335
				raise
5435
5336
5436
			if "merge" == pkg.operation and \
5337
			if "merge" == pkg.operation and \
5437
				self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \
5338
				self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \
Lines 5472-5477 class depgraph(object): Link Here
5472
			# recognized, deep traversal of dependencies is required.
5373
			# recognized, deep traversal of dependencies is required.
5473
			self._dynamic_config.myparams["deep"] = True
5374
			self._dynamic_config.myparams["deep"] = True
5474
5375
5376
			favorites = resume_data.get("favorites")
5377
			args_set = self._dynamic_config.sets[
5378
				self._frozen_config.target_root].sets['__non_set_args__']
5379
			if isinstance(favorites, list):
5380
				args = self._load_favorites(favorites)
5381
			else:
5382
				args = []
5383
5475
			for task in serialized_tasks:
5384
			for task in serialized_tasks:
5476
				if isinstance(task, Package) and \
5385
				if isinstance(task, Package) and \
5477
					task.operation == "merge":
5386
					task.operation == "merge":
Lines 5571-5577 class depgraph(object): Link Here
5571
					root_config=root_config))
5480
					root_config=root_config))
5572
			else:
5481
			else:
5573
				try:
5482
				try:
5574
					x = Atom(x, allow_repo=True)
5483
					x = Atom(x)
5575
				except portage.exception.InvalidAtom:
5484
				except portage.exception.InvalidAtom:
5576
					continue
5485
					continue
5577
				args.append(AtomArg(arg=x, atom=x,
5486
				args.append(AtomArg(arg=x, atom=x,
Lines 5621-5631 class depgraph(object): Link Here
5621
		return self._dynamic_config._need_restart and \
5530
		return self._dynamic_config._need_restart and \
5622
			not self._dynamic_config._skip_restart
5531
			not self._dynamic_config._skip_restart
5623
5532
5624
	def success_without_autounmask(self):
5533
	def get_backtrack_parameters(self):
5625
		return self._dynamic_config._success_without_autounmask
5534
		return {
5626
5535
			"needed_unstable_keywords":
5627
	def get_backtrack_infos(self):
5536
				self._dynamic_config._needed_unstable_keywords.copy(), \
5628
		return self._dynamic_config._backtrack_infos
5537
			"runtime_pkg_mask":
5538
				self._dynamic_config._runtime_pkg_mask.copy(),
5539
			"needed_use_config_changes":
5540
				self._dynamic_config._needed_use_config_changes.copy(),
5541
			"needed_license_changes":
5542
				self._dynamic_config._needed_license_changes.copy(),
5543
			}
5629
			
5544
			
5630
5545
5631
class _dep_check_composite_db(dbapi):
5546
class _dep_check_composite_db(dbapi):
Lines 5722-5739 class _dep_check_composite_db(dbapi): Link Here
5722
				else:
5637
				else:
5723
					try:
5638
					try:
5724
						pkg_eb = self._depgraph._pkg(
5639
						pkg_eb = self._depgraph._pkg(
5725
							pkg.cpv, "ebuild", pkg.root_config,
5640
							pkg.cpv, "ebuild", pkg.root_config)
5726
							myrepo=pkg.repo)
5727
					except portage.exception.PackageNotFound:
5641
					except portage.exception.PackageNotFound:
5728
						pkg_eb_visible = False
5642
						return False
5729
						for pkg_eb in self._depgraph._iter_match_pkgs(
5730
							pkg.root_config, "ebuild",
5731
							Atom("=%s" % (pkg.cpv,))):
5732
							if self._depgraph._pkg_visibility_check(pkg_eb):
5733
								pkg_eb_visible = True
5734
								break
5735
						if not pkg_eb_visible:
5736
							return False
5737
					else:
5643
					else:
5738
						if not self._depgraph._pkg_visibility_check(pkg_eb):
5644
						if not self._depgraph._pkg_visibility_check(pkg_eb):
5739
							return False
5645
							return False
Lines 5784-5797 class _dep_check_composite_db(dbapi): Link Here
5784
		if expanded_atoms:
5690
		if expanded_atoms:
5785
			atom = expanded_atoms[0]
5691
			atom = expanded_atoms[0]
5786
		else:
5692
		else:
5787
			null_atom = Atom(insert_category_into_atom(atom, "null"),
5693
			null_atom = Atom(insert_category_into_atom(atom, "null"))
5788
				allow_repo=True)
5789
			cat, atom_pn = portage.catsplit(null_atom.cp)
5694
			cat, atom_pn = portage.catsplit(null_atom.cp)
5790
			virts_p = root_config.settings.get_virts_p().get(atom_pn)
5695
			virts_p = root_config.settings.get_virts_p().get(atom_pn)
5791
			if virts_p:
5696
			if virts_p:
5792
				# Allow the resolver to choose which virtual.
5697
				# Allow the resolver to choose which virtual.
5793
				atom = Atom(null_atom.replace('null/', 'virtual/', 1),
5698
				atom = Atom(null_atom.replace('null/', 'virtual/', 1))
5794
					allow_repo=True)
5795
			else:
5699
			else:
5796
				atom = null_atom
5700
				atom = null_atom
5797
		return atom
5701
		return atom
Lines 5870-5884 def _spinner_start(spinner, myopts): Link Here
5870
5774
5871
def _spinner_stop(spinner):
5775
def _spinner_stop(spinner):
5872
	if spinner is None or \
5776
	if spinner is None or \
5873
		spinner.update == spinner.update_quiet:
5777
		spinner.update is spinner.update_quiet:
5874
		return
5778
		return
5875
5779
5876
	if spinner.update != spinner.update_basic:
5780
	portage.writemsg_stdout("\b\b... done!\n")
5877
		# update_basic is used for non-tty output,
5878
		# so don't output backspaces in that case.
5879
		portage.writemsg_stdout("\b\b")
5880
5881
	portage.writemsg_stdout("... done!\n")
5882
5781
5883
def backtrack_depgraph(settings, trees, myopts, myparams, 
5782
def backtrack_depgraph(settings, trees, myopts, myparams, 
5884
	myaction, myfiles, spinner):
5783
	myaction, myfiles, spinner):
Lines 5892-5946 def backtrack_depgraph(settings, trees, myopts, myparams, Link Here
5892
	finally:
5791
	finally:
5893
		_spinner_stop(spinner)
5792
		_spinner_stop(spinner)
5894
5793
5794
def _backtrack_depgraph(settings, trees, myopts, myparams, 
5795
	myaction, myfiles, spinner):
5895
5796
5896
def _backtrack_depgraph(settings, trees, myopts, myparams, myaction, myfiles, spinner):
5797
	backtrack_max = myopts.get('--backtrack', 10)
5897
5798
	backtrack_parameters = {}
5898
	max_retries = myopts.get('--backtrack', 10)
5799
	needed_unstable_keywords = None
5899
	max_depth = max(1, (max_retries + 1) / 2)
5800
	allow_backtracking = backtrack_max > 0
5900
	allow_backtracking = max_retries > 0
5901
	backtracker = Backtracker(max_depth)
5902
	backtracked = 0
5801
	backtracked = 0
5903
5904
	frozen_config = _frozen_depgraph_config(settings, trees,
5802
	frozen_config = _frozen_depgraph_config(settings, trees,
5905
		myopts, spinner)
5803
		myopts, spinner)
5906
5804
	while True:
5907
	while backtracker:
5908
		backtrack_parameters = backtracker.get()
5909
5910
		mydepgraph = depgraph(settings, trees, myopts, myparams, spinner,
5805
		mydepgraph = depgraph(settings, trees, myopts, myparams, spinner,
5911
			frozen_config=frozen_config,
5806
			frozen_config=frozen_config,
5912
			allow_backtracking=allow_backtracking,
5807
			allow_backtracking=allow_backtracking,
5913
			backtrack_parameters=backtrack_parameters)
5808
			**backtrack_parameters)
5914
		success, favorites = mydepgraph.select_files(myfiles)
5809
		success, favorites = mydepgraph.select_files(myfiles)
5915
5810
		if not success:
5916
		if success or mydepgraph.success_without_autounmask():
5811
			if mydepgraph.need_restart() and backtracked < backtrack_max:
5917
			break
5812
				backtrack_parameters = mydepgraph.get_backtrack_parameters()
5918
		elif not allow_backtracking:
5813
				backtracked += 1
5919
			break
5814
			elif backtracked and allow_backtracking:
5920
		elif backtracked >= max_retries:
5815
				if "--debug" in myopts:
5921
			break
5816
					writemsg_level(
5922
		elif mydepgraph.need_restart():
5817
						"\n\nbacktracking aborted after %s tries\n\n" % \
5923
			backtracked += 1
5818
						backtracked, noiselevel=-1, level=logging.DEBUG)
5924
			backtracker.feedback(mydepgraph.get_backtrack_infos())
5819
				# Backtracking failed, so disable it and do
5820
				# a plain dep calculation + error message.
5821
				allow_backtracking = False
5822
				#Don't reset needed_unstable_keywords here, since we don't want to
5823
				#send the user through a "one step at a time" unmasking session for
5824
				#no good reason.
5825
				backtrack_parameters.pop('runtime_pkg_mask', None)
5826
			else:
5827
				break
5925
		else:
5828
		else:
5926
			break
5829
			break
5927
5928
	if not (success or mydepgraph.success_without_autounmask()) and backtracked:
5929
5930
		if "--debug" in myopts:
5931
			writemsg_level(
5932
				"\n\nbacktracking aborted after %s tries\n\n" % \
5933
				backtracked, noiselevel=-1, level=logging.DEBUG)
5934
5935
		mydepgraph = depgraph(settings, trees, myopts, myparams, spinner,
5936
			frozen_config=frozen_config,
5937
			allow_backtracking=False,
5938
			backtrack_parameters=backtracker.get_best_run())
5939
		success, favorites = mydepgraph.select_files(myfiles)
5940
5941
	return (success, mydepgraph, favorites)
5830
	return (success, mydepgraph, favorites)
5942
5831
5943
5944
def resume_depgraph(settings, trees, mtimedb, myopts, myparams, spinner):
5832
def resume_depgraph(settings, trees, mtimedb, myopts, myparams, spinner):
5945
	"""
5833
	"""
5946
	Raises PackageSetNotFound if myfiles contains a missing package set.
5834
	Raises PackageSetNotFound if myfiles contains a missing package set.
Lines 6030-6040 def _resume_depgraph(settings, trees, mtimedb, myopts, myparams, spinner): Link Here
6030
	return (success, mydepgraph, dropped_tasks)
5918
	return (success, mydepgraph, dropped_tasks)
6031
5919
6032
def get_mask_info(root_config, cpv, pkgsettings,
5920
def get_mask_info(root_config, cpv, pkgsettings,
6033
	db, pkg_type, built, installed, db_keys, myrepo = None, _pkg_use_enabled=None):
5921
	db, pkg_type, built, installed, db_keys, _pkg_use_enabled=None):
6034
	eapi_masked = False
5922
	eapi_masked = False
6035
	try:
5923
	try:
6036
		metadata = dict(zip(db_keys,
5924
		metadata = dict(zip(db_keys,
6037
			db.aux_get(cpv, db_keys, myrepo=myrepo)))
5925
			db.aux_get(cpv, db_keys)))
6038
	except KeyError:
5926
	except KeyError:
6039
		metadata = None
5927
		metadata = None
6040
5928
Lines 6054-6061 def get_mask_info(root_config, cpv, pkgsettings, Link Here
6054
			if _pkg_use_enabled is not None:
5942
			if _pkg_use_enabled is not None:
6055
				modified_use = _pkg_use_enabled(pkg)
5943
				modified_use = _pkg_use_enabled(pkg)
6056
5944
6057
			mreasons = get_masking_status(pkg, pkgsettings, root_config, myrepo=myrepo, use=modified_use)
5945
			mreasons = get_masking_status(pkg, pkgsettings, root_config, use=modified_use)
6058
6059
	return metadata, mreasons
5946
	return metadata, mreasons
6060
5947
6061
def show_masked_packages(masked_packages):
5948
def show_masked_packages(masked_packages):
Lines 6065-6078 def show_masked_packages(masked_packages): Link Here
6065
	# show one of them to avoid redundant appearance.
5952
	# show one of them to avoid redundant appearance.
6066
	shown_cpvs = set()
5953
	shown_cpvs = set()
6067
	have_eapi_mask = False
5954
	have_eapi_mask = False
6068
	for (root_config, pkgsettings, cpv, repo,
5955
	for (root_config, pkgsettings, cpv,
6069
		metadata, mreasons) in masked_packages:
5956
		metadata, mreasons) in masked_packages:
6070
		output_cpv = cpv
5957
		if cpv in shown_cpvs:
6071
		if repo:
6072
			output_cpv += _repo_separator + repo
6073
		if output_cpv in shown_cpvs:
6074
			continue
5958
			continue
6075
		shown_cpvs.add(output_cpv)
5959
		shown_cpvs.add(cpv)
6076
		comment, filename = None, None
5960
		comment, filename = None, None
6077
		if "package.mask" in mreasons:
5961
		if "package.mask" in mreasons:
6078
			comment, filename = \
5962
			comment, filename = \
Lines 6094-6100 def show_masked_packages(masked_packages): Link Here
6094
				# above via mreasons.
5978
				# above via mreasons.
6095
				pass
5979
				pass
6096
5980
6097
		writemsg_stdout("- "+output_cpv+" (masked by: "+", ".join(mreasons)+")\n", noiselevel=-1)
5981
		writemsg_stdout("- "+cpv+" (masked by: "+", ".join(mreasons)+")\n", noiselevel=-1)
6098
5982
6099
		if comment and comment not in shown_comments:
5983
		if comment and comment not in shown_comments:
6100
			writemsg_stdout(filename + ":\n" + comment + "\n",
5984
			writemsg_stdout(filename + ":\n" + comment + "\n",
Lines 6120-6133 def show_blocker_docs_link(): Link Here
6120
	writemsg("section of the Gentoo Linux x86 Handbook (architecture is irrelevant):\n\n", noiselevel=-1)
6004
	writemsg("section of the Gentoo Linux x86 Handbook (architecture is irrelevant):\n\n", noiselevel=-1)
6121
	writemsg("http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#blocked\n\n", noiselevel=-1)
6005
	writemsg("http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#blocked\n\n", noiselevel=-1)
6122
6006
6123
def get_masking_status(pkg, pkgsettings, root_config, myrepo=None, use=None):
6007
def get_masking_status(pkg, pkgsettings, root_config, use=None):
6124
	return [mreason.message for \
6008
	return [mreason.message for \
6125
		mreason in _get_masking_status(pkg, pkgsettings, root_config, myrepo=myrepo, use=use)]
6009
		mreason in _get_masking_status(pkg, pkgsettings, root_config, use=use)]
6010
6011
def _get_masking_status(pkg, pkgsettings, root_config, use=None):
6126
6012
6127
def _get_masking_status(pkg, pkgsettings, root_config, myrepo=None, use=None):
6128
	mreasons = _getmaskingstatus(
6013
	mreasons = _getmaskingstatus(
6129
		pkg, settings=pkgsettings,
6014
		pkg, settings=pkgsettings,
6130
		portdb=root_config.trees["porttree"].dbapi, myrepo=myrepo)
6015
		portdb=root_config.trees["porttree"].dbapi)
6131
6016
6132
	if not pkg.installed:
6017
	if not pkg.installed:
6133
		if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata):
6018
		if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata):
(-)a/pym/_emerge/help.py (-9 / +4 lines)
Lines 19-25 def shorthelp(): Link Here
19
	print("          [ "+green("--complete-graph")+"             ] [ "+green("--deep")+"       ]")
19
	print("          [ "+green("--complete-graph")+"             ] [ "+green("--deep")+"       ]")
20
	print("          [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + "            ]")
20
	print("          [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + "            ]")
21
	print("          [ "+green("--newuse")+"    ] [ "+green("--noconfmem")+"  ] [ "+green("--nospinner")+"  ]")
21
	print("          [ "+green("--newuse")+"    ] [ "+green("--noconfmem")+"  ] [ "+green("--nospinner")+"  ]")
22
	print("          [ "+green("--oneshot")+"   ] [ "+green("--onlydeps")+"   ]")
22
	print("          [ "+green("--oneshot")+"   ] [ "+green("--onlydeps")+"   ] [ " + green("--misspell-suggestions")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]")
23
	print("          [ "+green("--reinstall ")+turquoise("changed-use")+"      ] [ " + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" >         ]")
23
	print("          [ "+green("--reinstall ")+turquoise("changed-use")+"      ] [ " + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" >         ]")
24
	print(bold("Actions:")+"  [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+"        ]")
24
	print(bold("Actions:")+"  [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+"        ]")
25
25
Lines 280-288 def help(myopts, havecolor=1): Link Here
280
		print("              With this option, output such as USE=\"dar -bar -foo\" will instead")
280
		print("              With this option, output such as USE=\"dar -bar -foo\" will instead")
281
		print("              be displayed as USE=\"-bar dar -foo\"")
281
		print("              be displayed as USE=\"-bar dar -foo\"")
282
		print()
282
		print()
283
		print("       " + green("--ask") + \
283
		print("       "+green("--ask")+" ("+green("-a")+" short option)")
284
			" [ %s | %s ] (%s short option)" % \
285
			(turquoise("y"), turquoise("n"), green("-a")))
286
		desc = "Before performing the action, display what will take place (server info for " + \
284
		desc = "Before performing the action, display what will take place (server info for " + \
287
			"--sync, --pretend output for merge, and so forth), then ask " + \
285
			"--sync, --pretend output for merge, and so forth), then ask " + \
288
			"whether to proceed with the action or abort.  Using --ask is more " + \
286
			"whether to proceed with the action or abort.  Using --ask is more " + \
Lines 580-593 def help(myopts, havecolor=1): Link Here
580
		print("              printed out accompanied by a '+' for enabled and a '-' for")
578
		print("              printed out accompanied by a '+' for enabled and a '-' for")
581
		print("              disabled USE flags.")
579
		print("              disabled USE flags.")
582
		print()
580
		print()
583
		print("       " + green("--quiet") + \
581
		print("       "+green("--quiet")+" ("+green("-q")+" short option)")
584
			" [ %s | %s ] (%s short option)" % \
585
			(turquoise("y"), turquoise("n"), green("-q")))
586
		print("              Effects vary, but the general outcome is a reduced or condensed")
582
		print("              Effects vary, but the general outcome is a reduced or condensed")
587
		print("              output from portage's displays.")
583
		print("              output from portage's displays.")
588
		print()
584
		print()
589
		print("       " + green("--quiet-build") + \
585
		print("       "+green("--quiet-build"))
590
			" [ %s | %s ]" % (turquoise("y"), turquoise("n")))
591
		desc = "Redirect all build output to logs alone, and do not " + \
586
		desc = "Redirect all build output to logs alone, and do not " + \
592
			"display it on stdout."
587
			"display it on stdout."
593
		for line in wrap(desc, desc_width):
588
		for line in wrap(desc, desc_width):
(-)a/pym/_emerge/main.py (-69 / +31 lines)
Lines 50-56 if sys.hexversion >= 0x3000000: Link Here
50
	long = int
50
	long = int
51
51
52
options=[
52
options=[
53
"--alphabetical",
53
"--ask",          "--alphabetical",
54
"--ask-enter-invalid",
54
"--ask-enter-invalid",
55
"--buildpkgonly",
55
"--buildpkgonly",
56
"--changed-use",
56
"--changed-use",
Lines 65-70 options=[ Link Here
65
"--nodeps",       "--noreplace",
65
"--nodeps",       "--noreplace",
66
"--nospinner",    "--oneshot",
66
"--nospinner",    "--oneshot",
67
"--onlydeps",     "--pretend",
67
"--onlydeps",     "--pretend",
68
"--quiet",
69
"--quiet-build",
68
"--quiet-unmerge-warn",
70
"--quiet-unmerge-warn",
69
"--resume",
71
"--resume",
70
"--searchdesc",
72
"--searchdesc",
Lines 77-82 options=[ Link Here
77
79
78
shortmapping={
80
shortmapping={
79
"1":"--oneshot",
81
"1":"--oneshot",
82
"a":"--ask",
80
"B":"--buildpkgonly",
83
"B":"--buildpkgonly",
81
"c":"--depclean",
84
"c":"--depclean",
82
"C":"--unmerge",
85
"C":"--unmerge",
Lines 88-93 shortmapping={ Link Here
88
"n":"--noreplace", "N":"--newuse",
91
"n":"--noreplace", "N":"--newuse",
89
"o":"--onlydeps",  "O":"--nodeps",
92
"o":"--onlydeps",  "O":"--nodeps",
90
"p":"--pretend",   "P":"--prune",
93
"p":"--pretend",   "P":"--prune",
94
"q":"--quiet",
91
"r":"--resume",
95
"r":"--resume",
92
"s":"--search",    "S":"--searchdesc",
96
"s":"--search",    "S":"--searchdesc",
93
"t":"--tree",
97
"t":"--tree",
Lines 114-125 def chk_updated_info_files(root, infodirs, prev_mtimes, retval): Link Here
114
118
115
		if not regen_infodirs:
119
		if not regen_infodirs:
116
			portage.writemsg_stdout("\n")
120
			portage.writemsg_stdout("\n")
117
			if portage.util.noiselimit >= 0:
121
			out.einfo("GNU info directory index is up-to-date.")
118
				out.einfo("GNU info directory index is up-to-date.")
119
		else:
122
		else:
120
			portage.writemsg_stdout("\n")
123
			portage.writemsg_stdout("\n")
121
			if portage.util.noiselimit >= 0:
124
			out.einfo("Regenerating GNU info directory index...")
122
				out.einfo("Regenerating GNU info directory index...")
123
125
124
			dir_extensions = ("", ".gz", ".bz2")
126
			dir_extensions = ("", ".gz", ".bz2")
125
			icount=0
127
			icount=0
Lines 206-212 def chk_updated_info_files(root, infodirs, prev_mtimes, retval): Link Here
206
					(icount, badcount))
208
					(icount, badcount))
207
				writemsg_level(errmsg, level=logging.ERROR, noiselevel=-1)
209
				writemsg_level(errmsg, level=logging.ERROR, noiselevel=-1)
208
			else:
210
			else:
209
				if icount > 0 and portage.util.noiselimit >= 0:
211
				if icount > 0:
210
					out.einfo("Processed %d info files." % (icount,))
212
					out.einfo("Processed %d info files." % (icount,))
211
213
212
def display_preserved_libs(vardbapi, myopts):
214
def display_preserved_libs(vardbapi, myopts):
Lines 423-429 def insert_optional_args(args): Link Here
423
	new_args = []
425
	new_args = []
424
426
425
	default_arg_opts = {
427
	default_arg_opts = {
426
		'--ask'                  : y_or_n,
427
		'--autounmask'           : y_or_n,
428
		'--autounmask'           : y_or_n,
428
		'--buildpkg'             : y_or_n,
429
		'--buildpkg'             : y_or_n,
429
		'--complete-graph'       : y_or_n,
430
		'--complete-graph'       : y_or_n,
Lines 436-443 def insert_optional_args(args): Link Here
436
		'--jobs'       : valid_integers,
437
		'--jobs'       : valid_integers,
437
		'--keep-going'           : y_or_n,
438
		'--keep-going'           : y_or_n,
438
		'--package-moves'        : y_or_n,
439
		'--package-moves'        : y_or_n,
439
		'--quiet'                : y_or_n,
440
		'--quiet-build'          : y_or_n,
441
		'--rebuilt-binaries'     : y_or_n,
440
		'--rebuilt-binaries'     : y_or_n,
442
		'--root-deps'  : ('rdeps',),
441
		'--root-deps'  : ('rdeps',),
443
		'--select'               : y_or_n,
442
		'--select'               : y_or_n,
Lines 458-470 def insert_optional_args(args): Link Here
458
	# Don't make things like "-kn" expand to "-k n"
457
	# Don't make things like "-kn" expand to "-k n"
459
	# since existence of -n makes it too ambiguous.
458
	# since existence of -n makes it too ambiguous.
460
	short_arg_opts_n = {
459
	short_arg_opts_n = {
461
		'a' : y_or_n,
462
		'b' : y_or_n,
460
		'b' : y_or_n,
463
		'g' : y_or_n,
461
		'g' : y_or_n,
464
		'G' : y_or_n,
462
		'G' : y_or_n,
465
		'k' : y_or_n,
463
		'k' : y_or_n,
466
		'K' : y_or_n,
464
		'K' : y_or_n,
467
		'q' : y_or_n,
468
	}
465
	}
469
466
470
	arg_stack = args[:]
467
	arg_stack = args[:]
Lines 563-575 def parse_opts(tmpcmdline, silent=False): Link Here
563
	true_y = ("True", "y")
560
	true_y = ("True", "y")
564
	argument_options = {
561
	argument_options = {
565
562
566
		"--ask": {
567
			"shortopt" : "-a",
568
			"help"    : "prompt before performing any actions",
569
			"type"    : "choice",
570
			"choices" : true_y_or_n
571
		},
572
573
		"--autounmask": {
563
		"--autounmask": {
574
			"help"    : "automatically unmask packages",
564
			"help"    : "automatically unmask packages",
575
			"type"    : "choice",
565
			"type"    : "choice",
Lines 707-725 def parse_opts(tmpcmdline, silent=False): Link Here
707
			"choices"  : true_y_or_n
697
			"choices"  : true_y_or_n
708
		},
698
		},
709
699
710
		"--quiet": {
711
			"shortopt" : "-q",
712
			"help"     : "reduced or condensed output",
713
			"type"     : "choice",
714
			"choices"  : true_y_or_n
715
		},
716
717
		"--quiet-build": {
718
			"help"     : "redirect build output to logs",
719
			"type"     : "choice",
720
			"choices"  : true_y_or_n
721
		},
722
723
		"--rebuilt-binaries": {
700
		"--rebuilt-binaries": {
724
			"help"     : "replace installed packages with binary " + \
701
			"help"     : "replace installed packages with binary " + \
725
			             "packages that have been rebuilt",
702
			             "packages that have been rebuilt",
Lines 778-783 def parse_opts(tmpcmdline, silent=False): Link Here
778
			"choices"  : true_y_or_n
755
			"choices"  : true_y_or_n
779
		},
756
		},
780
757
758
		"--misspell-suggestions": {
759
			"help"     : "enable package name suggestions when not existing",
760
			"type"     : "choice",
761
			"choices"  : true_y_or_n
762
		},
763
781
	}
764
	}
782
765
783
	if _ENABLE_DYN_LINK_MAP:
766
	if _ENABLE_DYN_LINK_MAP:
Lines 817-827 def parse_opts(tmpcmdline, silent=False): Link Here
817
800
818
	myoptions, myargs = parser.parse_args(args=tmpcmdline)
801
	myoptions, myargs = parser.parse_args(args=tmpcmdline)
819
802
820
	if myoptions.ask in true_y:
821
		myoptions.ask = True
822
	else:
823
		myoptions.ask = None
824
825
	if myoptions.autounmask in true_y:
803
	if myoptions.autounmask in true_y:
826
		myoptions.autounmask = True
804
		myoptions.autounmask = True
827
805
Lines 897-912 def parse_opts(tmpcmdline, silent=False): Link Here
897
	if myoptions.package_moves in true_y:
875
	if myoptions.package_moves in true_y:
898
		myoptions.package_moves = True
876
		myoptions.package_moves = True
899
877
900
	if myoptions.quiet in true_y:
901
		myoptions.quiet = True
902
	else:
903
		myoptions.quiet = None
904
905
	if myoptions.quiet_build in true_y:
906
		myoptions.quiet_build = True
907
	else:
908
		myoptions.quiet_build = None
909
910
	if myoptions.rebuilt_binaries in true_y:
878
	if myoptions.rebuilt_binaries in true_y:
911
		myoptions.rebuilt_binaries = True
879
		myoptions.rebuilt_binaries = True
912
880
Lines 1258-1268 def expand_set_arguments(myfiles, myaction, root_config): Link Here
1258
1226
1259
def repo_name_check(trees):
1227
def repo_name_check(trees):
1260
	missing_repo_names = set()
1228
	missing_repo_names = set()
1261
	for root_trees in trees.values():
1229
	for root, root_trees in trees.items():
1262
		porttree = root_trees.get("porttree")
1230
		if "porttree" in root_trees:
1263
		if porttree:
1231
			portdb = root_trees["porttree"].dbapi
1264
			portdb = porttree.dbapi
1232
			missing_repo_names.update(portdb.porttrees)
1265
			missing_repo_names.update(portdb.getMissingRepoNames())
1233
			repos = portdb.getRepositories()
1234
			for r in repos:
1235
				missing_repo_names.discard(portdb.getRepositoryPath(r))
1266
			if portdb.porttree_root in missing_repo_names and \
1236
			if portdb.porttree_root in missing_repo_names and \
1267
				not os.path.exists(os.path.join(
1237
				not os.path.exists(os.path.join(
1268
				portdb.porttree_root, "profiles")):
1238
				portdb.porttree_root, "profiles")):
Lines 1281-1287 def repo_name_check(trees): Link Here
1281
		msg.extend(textwrap.wrap("NOTE: Each repo_name entry " + \
1251
		msg.extend(textwrap.wrap("NOTE: Each repo_name entry " + \
1282
			"should be a plain text file containing a unique " + \
1252
			"should be a plain text file containing a unique " + \
1283
			"name for the repository on the first line.", 70))
1253
			"name for the repository on the first line.", 70))
1284
		msg.append("\n")
1285
		writemsg_level("".join("%s\n" % l for l in msg),
1254
		writemsg_level("".join("%s\n" % l for l in msg),
1286
			level=logging.WARNING, noiselevel=-1)
1255
			level=logging.WARNING, noiselevel=-1)
1287
1256
Lines 1293-1299 def repo_name_duplicate_check(trees): Link Here
1293
		if 'porttree' in root_trees:
1262
		if 'porttree' in root_trees:
1294
			portdb = root_trees['porttree'].dbapi
1263
			portdb = root_trees['porttree'].dbapi
1295
			if portdb.settings.get('PORTAGE_REPO_DUPLICATE_WARN') != '0':
1264
			if portdb.settings.get('PORTAGE_REPO_DUPLICATE_WARN') != '0':
1296
				for repo_name, paths in portdb.getIgnoredRepos():
1265
				for repo_name, paths in portdb._ignored_repos:
1297
					k = (root, repo_name, portdb.getRepositoryPath(repo_name))
1266
					k = (root, repo_name, portdb.getRepositoryPath(repo_name))
1298
					ignored_repos.setdefault(k, []).extend(paths)
1267
					ignored_repos.setdefault(k, []).extend(paths)
1299
1268
Lines 1304-1310 def repo_name_duplicate_check(trees): Link Here
1304
		msg.append('  profiles/repo_name entries:')
1273
		msg.append('  profiles/repo_name entries:')
1305
		msg.append('')
1274
		msg.append('')
1306
		for k in sorted(ignored_repos):
1275
		for k in sorted(ignored_repos):
1307
			msg.append('  %s overrides' % ", ".join(k))
1276
			msg.append('  %s overrides' % (k,))
1308
			for path in ignored_repos[k]:
1277
			for path in ignored_repos[k]:
1309
				msg.append('    %s' % (path,))
1278
				msg.append('    %s' % (path,))
1310
			msg.append('')
1279
			msg.append('')
Lines 1313-1319 def repo_name_duplicate_check(trees): Link Here
1313
			"to avoid having duplicates ignored. " + \
1282
			"to avoid having duplicates ignored. " + \
1314
			"Set PORTAGE_REPO_DUPLICATE_WARN=\"0\" in " + \
1283
			"Set PORTAGE_REPO_DUPLICATE_WARN=\"0\" in " + \
1315
			"/etc/make.conf if you would like to disable this warning."))
1284
			"/etc/make.conf if you would like to disable this warning."))
1316
		msg.append("\n")
1317
		writemsg_level(''.join('%s\n' % l for l in msg),
1285
		writemsg_level(''.join('%s\n' % l for l in msg),
1318
			level=logging.WARNING, noiselevel=-1)
1286
			level=logging.WARNING, noiselevel=-1)
1319
1287
Lines 1355-1368 def check_procfs(): Link Here
1355
		level=logging.ERROR, noiselevel=-1)
1323
		level=logging.ERROR, noiselevel=-1)
1356
	return 1
1324
	return 1
1357
1325
1358
def emerge_main(args=None):
1326
def emerge_main():
1359
	"""
1327
	global portage	# NFC why this is necessary now - genone
1360
	@param args: command arguments (default: sys.argv[1:])
1361
	@type args: list
1362
	"""
1363
	if args is None:
1364
		args = sys.argv[1:]
1365
1366
	portage._disable_legacy_globals()
1328
	portage._disable_legacy_globals()
1367
	portage.dep._internal_warnings = True
1329
	portage.dep._internal_warnings = True
1368
	# Disable color until we're sure that it should be enabled (after
1330
	# Disable color until we're sure that it should be enabled (after
Lines 1372-1378 def emerge_main(args=None): Link Here
1372
	# possible, such as --config-root.  They will be parsed again later,
1334
	# possible, such as --config-root.  They will be parsed again later,
1373
	# together with EMERGE_DEFAULT_OPTS (which may vary depending on the
1335
	# together with EMERGE_DEFAULT_OPTS (which may vary depending on the
1374
	# the value of --config-root).
1336
	# the value of --config-root).
1375
	myaction, myopts, myfiles = parse_opts(args, silent=True)
1337
	myaction, myopts, myfiles = parse_opts(sys.argv[1:], silent=True)
1376
	if "--debug" in myopts:
1338
	if "--debug" in myopts:
1377
		os.environ["PORTAGE_DEBUG"] = "1"
1339
		os.environ["PORTAGE_DEBUG"] = "1"
1378
	if "--config-root" in myopts:
1340
	if "--config-root" in myopts:
Lines 1393-1399 def emerge_main(args=None): Link Here
1393
	tmpcmdline = []
1355
	tmpcmdline = []
1394
	if "--ignore-default-opts" not in myopts:
1356
	if "--ignore-default-opts" not in myopts:
1395
		tmpcmdline.extend(settings["EMERGE_DEFAULT_OPTS"].split())
1357
		tmpcmdline.extend(settings["EMERGE_DEFAULT_OPTS"].split())
1396
	tmpcmdline.extend(args)
1358
	tmpcmdline.extend(sys.argv[1:])
1397
	myaction, myopts, myfiles = parse_opts(tmpcmdline)
1359
	myaction, myopts, myfiles = parse_opts(tmpcmdline)
1398
1360
1399
	if myaction not in ('help', 'info', 'version') and \
1361
	if myaction not in ('help', 'info', 'version') and \
Lines 1557-1566 def emerge_main(args=None): Link Here
1557
1519
1558
	if settings.get("PORTAGE_DEBUG", "") == "1":
1520
	if settings.get("PORTAGE_DEBUG", "") == "1":
1559
		spinner.update = spinner.update_quiet
1521
		spinner.update = spinner.update_quiet
1522
		portage.debug=1
1560
		portage.util.noiselimit = 0
1523
		portage.util.noiselimit = 0
1561
		if "python-trace" in settings.features:
1524
		if "python-trace" in settings.features:
1562
			import portage.debug as portage_debug
1525
			import portage.debug
1563
			portage_debug.set_trace(True)
1526
			portage.debug.set_trace(True)
1564
1527
1565
	if not ("--quiet" in myopts):
1528
	if not ("--quiet" in myopts):
1566
		if '--nospinner' in myopts or \
1529
		if '--nospinner' in myopts or \
Lines 1753-1759 def emerge_main(args=None): Link Here
1753
1716
1754
		for x in myfiles:
1717
		for x in myfiles:
1755
			if x.startswith(SETPREFIX) or \
1718
			if x.startswith(SETPREFIX) or \
1756
				is_valid_package_atom(x, allow_repo=True):
1719
				is_valid_package_atom(x):
1757
				continue
1720
				continue
1758
			if x[:1] == os.sep:
1721
			if x[:1] == os.sep:
1759
				continue
1722
				continue
1760
- 

Return to bug 363137