Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 310613
Collapse All | Expand All

(-)pym/portage/dep/__init__.py (-3 / +13 lines)
Lines 213-219 Link Here
213
# behavior will be explicitly enabled as necessary.
213
# behavior will be explicitly enabled as necessary.
214
_dep_check_strict = False
214
_dep_check_strict = False
215
215
216
def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
216
def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[], metadata_store = None, inducing_use = set()):
217
	"""
217
	"""
218
	Takes a paren_reduce'd array and reduces the use? conditionals out
218
	Takes a paren_reduce'd array and reduces the use? conditionals out
219
	leaving an array with subarrays
219
	leaving an array with subarrays
Lines 245-251 Link Here
245
		head = mydeparray.pop(0)
245
		head = mydeparray.pop(0)
246
246
247
		if not isinstance(head, basestring):
247
		if not isinstance(head, basestring):
248
			additions = use_reduce(head, uselist, masklist, matchall, excludeall)
248
			additions = use_reduce(head, uselist, masklist, matchall, excludeall, \
249
				metadata_store=metadata_store, inducing_use=inducing_use)
249
			if additions:
250
			if additions:
250
				rlist.append(additions)
251
				rlist.append(additions)
251
			elif rlist and rlist[-1] == "||":
252
			elif rlist and rlist[-1] == "||":
Lines 257-265 Link Here
257
			if head[-1:] == "?": # Use reduce next group on fail.
258
			if head[-1:] == "?": # Use reduce next group on fail.
258
				# Pull any other use conditions and the following atom or list into a separate array
259
				# Pull any other use conditions and the following atom or list into a separate array
259
				newdeparray = [head]
260
				newdeparray = [head]
261
				new_inducing_use = inducing_use.copy()
262
260
				while isinstance(newdeparray[-1], basestring) and \
263
				while isinstance(newdeparray[-1], basestring) and \
261
					newdeparray[-1][-1:] == "?":
264
					newdeparray[-1][-1:] == "?":
262
					if mydeparray:
265
					if mydeparray:
266
						new_inducing_use.add(newdeparray[-1][:-1])
263
						newdeparray.append(mydeparray.pop(0))
267
						newdeparray.append(mydeparray.pop(0))
264
					else:
268
					else:
265
						raise ValueError(_("Conditional with no target."))
269
						raise ValueError(_("Conditional with no target."))
Lines 307-313 Link Here
307
				if ismatch:
311
				if ismatch:
308
					target = newdeparray[-1]
312
					target = newdeparray[-1]
309
					if isinstance(target, list):
313
					if isinstance(target, list):
310
						additions = use_reduce(target, uselist, masklist, matchall, excludeall)
314
						additions = use_reduce(target, uselist, masklist, matchall, excludeall, \
315
							metadata_store=metadata_store, inducing_use=new_inducing_use)
311
						if additions:
316
						if additions:
312
							rlist.append(additions)
317
							rlist.append(additions)
313
					elif not _dep_check_strict:
318
					elif not _dep_check_strict:
Lines 319-324 Link Here
319
324
320
			else:
325
			else:
321
				rlist += [head]
326
				rlist += [head]
327
				if inducing_use and metadata_store is not None:
328
					if not head in metadata_store:
329
						metadata_store[head] = inducing_use
330
					else:
331
						metadata_store[head].union(inducing_use)
322
332
323
	return rlist
333
	return rlist
324
334
(-)pym/portage/util/digraph.py (-2 / +17 lines)
Lines 17-28 Link Here
17
		# { node : ( { child : priority } , { parent : priority } ) }
17
		# { node : ( { child : priority } , { parent : priority } ) }
18
		self.nodes = {}
18
		self.nodes = {}
19
		self.order = []
19
		self.order = []
20
		self.metadata = {}
20
21
21
	def add(self, node, parent, priority=0):
22
	def add(self, node, parent, priority=0, metadata = set()):
22
		"""Adds the specified node with the specified parent.
23
		"""Adds the specified node with the specified parent.
23
		
24
		
24
		If the dep is a soft-dep and the node already has a hard
25
		If the dep is a soft-dep and the node already has a hard
25
		relationship to the parent, the relationship is left as hard."""
26
		relationship to the parent, the relationship is left as hard."""
27
28
		if metadata:
29
			self.metadata[(node, parent)] = metadata
26
		
30
		
27
		if node not in self.nodes:
31
		if node not in self.nodes:
28
			self.nodes[node] = ({}, {}, node)
32
			self.nodes[node] = ({}, {}, node)
Lines 86-91 Link Here
86
		Any endpoint vertices that become isolated will remain in the graph.
90
		Any endpoint vertices that become isolated will remain in the graph.
87
		"""
91
		"""
88
92
93
		if (child, parent) in self.metadata:
94
			del self.metadata[(child, parent)]
95
89
		# Nothing should be modified when a KeyError is raised.
96
		# Nothing should be modified when a KeyError is raised.
90
		for k in parent, child:
97
		for k in parent, child:
91
			if k not in self.nodes:
98
			if k not in self.nodes:
Lines 245-250 Link Here
245
				parents_clone[parent] = priorities_clone
252
				parents_clone[parent] = priorities_clone
246
			clone.nodes[node] = (children_clone, parents_clone, node)
253
			clone.nodes[node] = (children_clone, parents_clone, node)
247
		clone.order = self.order[:]
254
		clone.order = self.order[:]
255
		clone.metadata = {}
256
		for (a,b) in self.metadata:
257
			clone.metadata[(a,b)] = self.metadata[(a,b)]
248
		return clone
258
		return clone
249
259
250
	def delnode(self, node):
260
	def delnode(self, node):
Lines 273-279 Link Here
273
			else:
283
			else:
274
				output("(no children)\n")
284
				output("(no children)\n")
275
			for child, priorities in self.nodes[node][0].items():
285
			for child, priorities in self.nodes[node][0].items():
276
				output("  %s (%s)\n" % (child, priorities[-1],))
286
				msg = "  %s (%s)" % (child, priorities[-1], )
287
				if (child, node) in self.metadata:
288
					msg += " induced by USE=\""
289
					msg += " ".join(self.metadata[(child, node)]) + "\""
290
				msg += "\n"
291
				output(msg)
277
292
278
	# Backward compatibility
293
	# Backward compatibility
279
	addnode = add
294
	addnode = add
(-)pym/_emerge/depgraph.py (-15 / +22 lines)
Lines 725-731 Link Here
725
					return 0
725
					return 0
726
		return 1
726
		return 1
727
727
728
	def _add_dep(self, dep, allow_unsatisfied=False):
728
	def _add_dep(self, dep, allow_unsatisfied=False, inducing_use = ""):
729
		debug = "--debug" in self._frozen_config.myopts
729
		debug = "--debug" in self._frozen_config.myopts
730
		buildpkgonly = "--buildpkgonly" in self._frozen_config.myopts
730
		buildpkgonly = "--buildpkgonly" in self._frozen_config.myopts
731
		nodeps = "--nodeps" in self._frozen_config.myopts
731
		nodeps = "--nodeps" in self._frozen_config.myopts
Lines 834-844 Link Here
834
				self._dynamic_config._ignored_deps.append(dep)
834
				self._dynamic_config._ignored_deps.append(dep)
835
				return 1
835
				return 1
836
836
837
		if not self._add_pkg(dep_pkg, dep):
837
		if not self._add_pkg(dep_pkg, dep, inducing_use):
838
			return 0
838
			return 0
839
		return 1
839
		return 1
840
840
841
	def _add_pkg(self, pkg, dep):
841
	def _add_pkg(self, pkg, dep, inducing_use = ""):
842
		myparent = None
842
		myparent = None
843
		priority = None
843
		priority = None
844
		depth = 0
844
		depth = 0
Lines 912-918 Link Here
912
						for parent_atom in arg_atoms:
912
						for parent_atom in arg_atoms:
913
							parent, atom = parent_atom
913
							parent, atom = parent_atom
914
							self._dynamic_config.digraph.add(existing_node, parent,
914
							self._dynamic_config.digraph.add(existing_node, parent,
915
								priority=priority)
915
								priority=priority, metadata=inducing_use)
916
							self._add_parent_atom(existing_node, parent_atom)
916
							self._add_parent_atom(existing_node, parent_atom)
917
					# If a direct circular dependency is not an unsatisfied
917
					# If a direct circular dependency is not an unsatisfied
918
					# buildtime dependency then drop it here since otherwise
918
					# buildtime dependency then drop it here since otherwise
Lines 921-927 Link Here
921
					if existing_node != myparent or \
921
					if existing_node != myparent or \
922
						(priority.buildtime and not priority.satisfied):
922
						(priority.buildtime and not priority.satisfied):
923
						self._dynamic_config.digraph.addnode(existing_node, myparent,
923
						self._dynamic_config.digraph.addnode(existing_node, myparent,
924
							priority=priority)
924
							priority=priority, metadata=inducing_use)
925
						if dep.atom is not None and dep.parent is not None:
925
						if dep.atom is not None and dep.parent is not None:
926
							self._add_parent_atom(existing_node,
926
							self._add_parent_atom(existing_node,
927
								(dep.parent, dep.atom))
927
								(dep.parent, dep.atom))
Lines 1028-1034 Link Here
1028
		# Do this even when addme is False (--onlydeps) so that the
1028
		# Do this even when addme is False (--onlydeps) so that the
1029
		# parent/child relationship is always known in case
1029
		# parent/child relationship is always known in case
1030
		# self._show_slot_collision_notice() needs to be called later.
1030
		# self._show_slot_collision_notice() needs to be called later.
1031
		self._dynamic_config.digraph.add(pkg, myparent, priority=priority)
1031
		self._dynamic_config.digraph.add(pkg, myparent, priority=priority, metadata=inducing_use)
1032
		if dep.atom is not None and dep.parent is not None:
1032
		if dep.atom is not None and dep.parent is not None:
1033
			self._add_parent_atom(pkg, (dep.parent, dep.atom))
1033
			self._add_parent_atom(pkg, (dep.parent, dep.atom))
1034
1034
Lines 1173-1183 Link Here
1173
						noiselevel=-1, level=logging.DEBUG)
1173
						noiselevel=-1, level=logging.DEBUG)
1174
1174
1175
				try:
1175
				try:
1176
1176
					metadata_store = {}
1177
					dep_string = portage.dep.paren_normalize(
1177
					dep_string = portage.dep.paren_normalize(
1178
						portage.dep.use_reduce(
1178
						portage.dep.use_reduce(
1179
						portage.dep.paren_reduce(dep_string),
1179
						portage.dep.paren_reduce(dep_string),
1180
						uselist=pkg.use.enabled))
1180
						uselist=pkg.use.enabled, metadata_store=metadata_store))
1181
1181
1182
					dep_string = list(self._queue_disjunctive_deps(
1182
					dep_string = list(self._queue_disjunctive_deps(
1183
						pkg, dep_root, dep_priority, dep_string))
1183
						pkg, dep_root, dep_priority, dep_string))
Lines 1196-1202 Link Here
1196
1196
1197
				if not self._add_pkg_dep_string(
1197
				if not self._add_pkg_dep_string(
1198
					pkg, dep_root, dep_priority, dep_string,
1198
					pkg, dep_root, dep_priority, dep_string,
1199
					allow_unsatisfied, ignore_blockers=ignore_blockers):
1199
					allow_unsatisfied, ignore_blockers=ignore_blockers, metadata_store=metadata_store):
1200
					return 0
1200
					return 0
1201
1201
1202
		except portage.exception.AmbiguousPackageName as e:
1202
		except portage.exception.AmbiguousPackageName as e:
Lines 1224-1230 Link Here
1224
		return 1
1224
		return 1
1225
1225
1226
	def _add_pkg_dep_string(self, pkg, dep_root, dep_priority, dep_string,
1226
	def _add_pkg_dep_string(self, pkg, dep_root, dep_priority, dep_string,
1227
		allow_unsatisfied, ignore_blockers=False):
1227
		allow_unsatisfied, ignore_blockers=False, metadata_store=None):
1228
		depth = pkg.depth + 1
1228
		depth = pkg.depth + 1
1229
		debug = "--debug" in self._frozen_config.myopts
1229
		debug = "--debug" in self._frozen_config.myopts
1230
		strict = pkg.type_name != "installed"
1230
		strict = pkg.type_name != "installed"
Lines 1268-1278 Link Here
1268
			if not atom.blocker and vardb.match(atom):
1268
			if not atom.blocker and vardb.match(atom):
1269
				mypriority.satisfied = True
1269
				mypriority.satisfied = True
1270
1270
1271
			if not self._add_dep(Dependency(atom=atom,
1271
			if metadata_store is not None and atom in metadata_store:
1272
				blocker=atom.blocker, child=child, depth=depth, parent=pkg,
1272
				if not self._add_dep(Dependency(atom=atom,
1273
				priority=mypriority, root=dep_root),
1273
					blocker=atom.blocker, child=child, depth=depth, parent=pkg,
1274
				allow_unsatisfied=allow_unsatisfied):
1274
					priority=mypriority, root=dep_root),
1275
				return 0
1275
					allow_unsatisfied=allow_unsatisfied, inducing_use=metadata_store[atom]):
1276
					return 0
1277
			else:
1278
				if not self._add_dep(Dependency(atom=atom,
1279
					blocker=atom.blocker, child=child, depth=depth, parent=pkg,
1280
					priority=mypriority, root=dep_root),
1281
					allow_unsatisfied=allow_unsatisfied):
1282
					return 0
1276
1283
1277
		selected_atoms.pop(pkg)
1284
		selected_atoms.pop(pkg)
1278
1285

Return to bug 310613