View | Details | Raw Unified
Collapse All | Expand All

(-) portage.firstpatch/bin/emerge (-30 / +13 lines)
 Lines 356-375    Link Here 
	add=[]
	add=[]
	sub=[]
	sub=[]
	if "--update" in myopts or myaction in ("system", "world"):
	if "--update" in myopts or myaction in ("system", "world"):
		add.extend(["selective","empty"])
		add.extend(["empty"])
	if "--emptytree" in myopts:
	if "--emptytree" in myopts:
		add.extend(["empty"])
		add.extend(["empty"])
		sub.extend(["selective"])
		sub.extend(["selective"])
	if "--nodeps" in myopts:
	if "--nodeps" in myopts:
		sub.extend(["recurse"])
		sub.extend(["recurse"])
	if "--noreplace" in myopts:
		add.extend(["selective"])
	if "--deep" in myopts:
	if "--deep" in myopts:
		add.extend(["deep"])
		add.extend(["deep"])
	if "--selective" in myopts:
		add.extend(["selective"])
	if myaction in ["world","system"]:
		add.extend(["selective"])
	elif myaction in ["depclean"]:
	elif myaction in ["depclean"]:
		add.extend(["empty"])
		add.extend(["empty"])
		sub.extend(["selective"])
		sub.extend(["selective"])
 Lines 679-685    Link Here 
					"--getbinpkg" in self.myopts,
					"--getbinpkg" in self.myopts,
					"--getbinpkgonly" in self.myopts)
					"--getbinpkgonly" in self.myopts)
	def create(self,mybigkey,myparent=None,addme=1,myuse=None,hard_dep=True,arg=None):
	def create(self,mybigkey,myparent=None,addme=1,myuse=None,soft_dep=False,arg=None):
		"""
		"""
		Fills the digraph with nodes comprised of packages to merge.
		Fills the digraph with nodes comprised of packages to merge.
		mybigkey is the package spec of the package to merge.
		mybigkey is the package spec of the package to merge.
 Lines 697-707    Link Here 
			if addme and jbigkey != myparent:
			if addme and jbigkey != myparent:
				# Refuse to make a node depend on itself so that the we don't
				# Refuse to make a node depend on itself so that the we don't
				# don't create a bogus circular dependency in self.altlist().
				# don't create a bogus circular dependency in self.altlist().
				self.digraph.addnode(jbigkey, myparent, hard_dep=hard_dep)
				self.digraph.addnode(jbigkey, myparent, soft_dep=soft_dep)
			return 1
			return 1
		jbigkey = " ".join(mybigkey) + " nomerge"
		jbigkey = " ".join(mybigkey) + " nomerge"
		if self.digraph.hasnode(jbigkey):
		if self.digraph.hasnode(jbigkey):
			self.digraph.addnode(jbigkey, myparent, hard_dep=hard_dep)
			self.digraph.addnode(jbigkey, myparent, soft_dep=soft_dep)
			return 1
			return 1
		
		
		self.spinner.update()
		self.spinner.update()
 Lines 724-730    Link Here 
				if self.mydbapi[parent_root].match(mykey) or \
				if self.mydbapi[parent_root].match(mykey) or \
					self.trees[parent_root]["vartree"].dbapi.match(mykey):
					self.trees[parent_root]["vartree"].dbapi.match(mykey):
					mybigkey.append(myparent.split()[2])
					mybigkey.append(myparent.split()[2])
					self.digraph.addnode(" ".join(mybigkey), myparent, hard_dep)
					self.digraph.addnode(" ".join(mybigkey), myparent, soft_dep=soft_dep)
			return 1
			return 1
		else:
		else:
			mydbapi = self.trees[myroot][self.pkg_tree_map[mytype]].dbapi
			mydbapi = self.trees[myroot][self.pkg_tree_map[mytype]].dbapi
 Lines 783-789    Link Here 
		""" At this point, we have either hit a blocker and returned, found the package in the
		""" At this point, we have either hit a blocker and returned, found the package in the
		    depgraph already and returned, or we are here.  Whether we are merging or not; we must
		    depgraph already and returned, or we are here.  Whether we are merging or not; we must
		    add the package to the depgraph; so we do that here. """
		    add the package to the depgraph; so we do that here. """
		self.digraph.addnode(string.join(mybigkey),myparent,hard_dep=hard_dep)
		self.digraph.addnode(string.join(mybigkey),myparent,soft_dep=soft_dep)
		
		
		""" This section determines whether we go deeper into dependencies or not.
		""" This section determines whether we go deeper into dependencies or not.
		    We want to go deeper on a few occasions:
		    We want to go deeper on a few occasions:
 Lines 816-839    Link Here 
		""" We have retrieve the dependency information, now we need to recursively
		""" We have retrieve the dependency information, now we need to recursively
		    process them.  DEPEND gets processed for root = "/", {R,P}DEPEND in myroot. """
		    process them.  DEPEND gets processed for root = "/", {R,P}DEPEND in myroot. """
		
		
		mydep={}
		mp=string.join(mybigkey)
		mp=string.join(mybigkey)
		try:
		try:
			if myroot=="/":
			if not self.select_dep("/",edepend["DEPEND"],myparent=mp,myuse=myuse):
				mydep["/"]=edepend["DEPEND"]+" "+edepend["RDEPEND"]
				return 0
				if not self.select_dep("/",edepend["DEPEND"],myparent=mp,myuse=myuse):
			if not self.select_dep(myroot,edepend["RDEPEND"],myparent=mp,myuse=myuse,soft_deps=True):
					return 0
				return 0
				if not self.select_dep("/",edepend["RDEPEND"],myparent=mp,myuse=myuse,soft_deps=True):
					return 0
			else:
				mydep["/"]=edepend["DEPEND"]
				mydep[myroot]=edepend["RDEPEND"]
				if not self.select_dep("/",mydep["/"],myparent=mp,myuse=myuse):
					return 0
				if not self.select_dep(myroot,mydep[myroot],myparent=mp,myuse=myuse,soft_deps=True):
					return 0
	
			if edepend.has_key("PDEPEND") and edepend["PDEPEND"]:
			if edepend.has_key("PDEPEND") and edepend["PDEPEND"]:
				# Post Depend -- Add to the list without a parent, as it depends
				# Post Depend -- Add to the list without a parent, as it depends
				# on a package being present AND must be built after that package.
				# on a package being present AND must be built after that package.
 Lines 1189-1197    Link Here 
			if myparent:
			if myparent:
				#we are a dependency, so we want to be unconditionally added
				#we are a dependency, so we want to be unconditionally added
				hard_dep = not soft_deps and len(vardb.match(x)) == 0
				soft_dep = soft_deps or vardb.match(x)
				if not self.create(selected_pkg[0:3], myparent,
				if not self.create(selected_pkg[0:3], myparent,
					myuse=selected_pkg[-1], hard_dep=hard_dep, arg=arg):
					myuse=selected_pkg[-1], soft_dep=soft_dep, arg=arg):
					return 0
					return 0
			else:
			else:
				#if mysource is not set, then we are a command-line dependency and should not be added
				#if mysource is not set, then we are a command-line dependency and should not be added
 Lines 1217-1223    Link Here 
		while (not mygraph.empty()):
		while (not mygraph.empty()):
			mycurkey=mygraph.firstzero()
			mycurkey=mygraph.firstzero()
			if not mycurkey:
			if not mycurkey:
				installables = mygraph.leaf_nodes(include_soft_deps=False)
				installables = mygraph.leaf_nodes(ignore_soft_deps=True)
				if not installables:
				if not installables:
					print "!!! Error: circular dependencies:"
					print "!!! Error: circular dependencies:"
					print
					print
(-) portage.firstpatch/pym/portage.py (-17 / +35 lines)
 Lines 315-328    Link Here 
	def __init__(self):
	def __init__(self):
		"""Create an empty digraph"""
		"""Create an empty digraph"""
		
		
		# { node : ( { child : hard_dep } , { parent : hard_dep } ) }
		# { node : ( { child : soft_dep } , { parent : soft_dep } ) }
		self.nodes = {}
		self.nodes = {}
		self.order = []
		self.order = []
	def add(self, node, parent, hard_dep=True):
	def add(self, node, parent, soft_dep=False):
		"""Adds the specified node with the specified parent. If the dep
		"""Adds the specified node with the specified parent.
		is a hard-dep and the node already has a relationship to the parent
		
		the relationship is ensured to be hard."""
		If the dep is a soft-dep and the node already has a hard
		relationship to the parent, the relationship is left as hard."""
		
		
		if node not in self.nodes:
		if node not in self.nodes:
			self.nodes[node] = ({}, {})
			self.nodes[node] = ({}, {})
 Lines 336-351    Link Here 
			self.order.append(parent)
			self.order.append(parent)
		
		
		if parent in self.nodes[node][1]:
		if parent in self.nodes[node][1]:
			if hard_dep:
			if not soft_dep:
				self.nodes[node][1][parent] = True
				self.nodes[node][1][parent] = False
		else:
		else:
			self.nodes[node][1][parent] = hard_dep
			self.nodes[node][1][parent] = soft_dep
		
		
		if node in self.nodes[parent][0]:
		if node in self.nodes[parent][0]:
			if hard_dep:
			if not soft_dep:
				self.nodes[parent][0][node] = True
				self.nodes[parent][0][node] = False
		else:
		else:
			self.nodes[parent][0][node] = hard_dep
			self.nodes[parent][0][node] = soft_dep
	def remove(self, node):
	def remove(self, node):
		"""Removes the specified node from the digraph, also removing
		"""Removes the specified node from the digraph, also removing
 Lines 368-387    Link Here 
		return node in self.nodes
		return node in self.nodes
	def all_nodes(self):
	def all_nodes(self):
		"""Return a list of all nodes in the graph"""
		return self.order[:]
		return self.order[:]
	def child_nodes(self, node):
	def child_nodes(self, node):
		"""Return all children of the specified node"""
		return self.nodes[node][0].keys()
		return self.nodes[node][0].keys()
	
	def parent_nodes(self, node):
	def parent_nodes(self, node):
		"""Return all parents of the specified node"""
		return self.nodes[node][1].keys()
		return self.nodes[node][1].keys()
	def leaf_nodes(self, include_soft_deps=False):
	def leaf_nodes(self, ignore_soft_deps=False):
		"""Return all nodes that have no children
		
		If ignore_soft_deps is True, soft deps are not counted as
		children in calculations."""
		
		leaf_nodes = []
		leaf_nodes = []
		for node in self.order:
		for node in self.order:
			is_leaf_node = True
			is_leaf_node = True
			for child in self.nodes[node][0]:
			for child in self.nodes[node][0]:
				if include_soft_deps or self.nodes[node][0][child]:
				if not (ignore_soft_deps and self.nodes[node][0][child]):
					is_leaf_node = False
					is_leaf_node = False
					break
					break
			if is_leaf_node:
			if is_leaf_node:
 Lines 400-414    Link Here 
	# Backward compatibility
	# Backward compatibility
	addnode = add
	addnode = add
	delnode = remove
	allnodes = all_nodes
	allnodes = all_nodes
	allzeros = leaf_nodes
	allzeros = leaf_nodes
	hasnode = contains
	hasnode = contains
	empty = is_empty
	empty = is_empty
	copy = clone
	copy = clone
	def delnode(self, node):
		try:
			self.remove(node)
		except KeyError:
			pass
	def firstzero(self):
	def firstzero(self):
		leaf_nodes = self.leaf_nodes(include_soft_deps=True)
		leaf_nodes = self.leaf_nodes()
		if leaf_nodes:
		if leaf_nodes:
			return leaf_nodes[0]
			return leaf_nodes[0]
		return None
		return None
 Lines 441-447    Link Here 
	
	
	def debug_print(self):
	def debug_print(self):
		for node in self.nodes:
		for node in self.nodes:
			print node,"depends on"
			print node,
			if self.nodes[node][0]:
				print "depends on"
			else:
				print "(no children)"
			for child in self.nodes[node][0]:
			for child in self.nodes[node][0]:
				print "  ",child,
				print "  ",child,
				if self.nodes[node][0][child]:
				if self.nodes[node][0][child]: