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

Collapse All | Expand All

(-)portage.orig/pym/portage.py (+88 lines)
Lines 4072-4077 Link Here
4072
4072
4073
	def cpv_exists(self,mycpv):
4073
	def cpv_exists(self,mycpv):
4074
		return self.cpvdict.has_key(mycpv)
4074
		return self.cpvdict.has_key(mycpv)
4075
4076
	def cpv_all(self):
4077
		return self.cpvdict.keys()
4075
	
4078
	
4076
	def cp_list(self,mycp,use_cache=1):
4079
	def cp_list(self,mycp,use_cache=1):
4077
		if not self.cpdict.has_key(mycp):
4080
		if not self.cpdict.has_key(mycp):
Lines 4418-4425 Link Here
4418
				myd = ""
4421
				myd = ""
4419
			results.append(myd)
4422
			results.append(myd)
4420
		return results
4423
		return results
4424
4425
	def revdeps(self, mycpv, buildtimedeps=0):
4426
		"Returns a list of first-level reverse dependencies on cpv."
4427
4428
		myfdb = fakedbapi()
4429
		for i in self.cpv_all():
4430
			myfdb.cpv_inject(i)
4431
		myfdb.cpv_remove(mycpv)
4432
		myvdb=self
4433
4434
		if buildtimedeps:
4435
			self.depvars = ["RDEPEND","DEPEND","PDEPEND"]
4436
		else:
4437
			self.depvars = ["RDEPEND","PDEPEND"]
4421
		
4438
		
4439
		# Start with some local helper functions. Defined here since they really aren't useful
4440
		# elsewhere.
4441
		def potential_revdeps(cpv):
4442
			mycp=pkgsplit(cpv)[0]
4443
			#print "'"+cpv+"'"
4444
			#print myvdb.aux_get(cpv, ["PROVIDE"])
4445
			myprovide=myvdb.aux_get(cpv, ["PROVIDE"])[0].split()
4446
			#print cpv,"provides", myprovide
4447
			
4448
			myret=[]
4449
			for x in myvdb.cpv_all():
4450
				myrawdep=string.join(myvdb.aux_get(x, myvdb.depvars), " ")
4451
				if string.find(myrawdep, mycp) != -1:
4452
					myret.append( (x,myrawdep) )
4453
				for p in myprovide:
4454
					if string.find(myrawdep, p) != -1:
4455
						myret.append( (x,myrawdep) )
4456
			#print "potentials for %s: " % cpv, [ x[0] for x in myret]
4457
			return myret
4458
4459
		def parse_dep(cpv, dep):
4460
			""" Returns 1 if cpv and nothing else installed satisfies a requirement of depstring.
4461
			Takes a paren_ and use_reduced list or single atom for dep. """
4462
			if type(dep) is list:
4463
				if len(dep) == 0:
4464
					return 0
4465
				elif dep[0] == "||":
4466
					# Any one of the items is enough to satisfy
4467
					mylist = dep[1:]
4468
					cpv_satisfies=0
4469
					for myatom in mylist:
4470
						if parse_dep(cpv, myatom):
4471
							cpv_satisfies=1
4472
					if not cpv_satisfies:
4473
						return 0
4474
					#else:
4475
					#	print cpv,"matches",dep
4476
					for myother in myfdb.cpv_all():
4477
						for myatom in mylist:
4478
							if parse_dep(cpv, myatom):
4479
								return 0
4480
					return 1
4481
				else:
4482
					# Not a || list; we handle each atom individually.
4483
					for myatom in dep:
4484
						if parse_dep(cpv, myatom):
4485
							return 1
4486
					return 0
4487
			else:
4488
				# A simple atom. First, check it isn't a !depend...
4489
				if dep[0] == "!":
4490
					return 0
4491
				# If cpv and nothing else matches the dep, return 1
4492
				if cpv not in myvdb.match(dep):
4493
					#print cpv,"doesn't match",dep
4494
					return 0
4495
				if len(myfdb.match(dep)) == 0:
4496
					return 1
4497
				#else:
4498
				#	print "another matches", dep
4499
				return 0
4422
4500
4501
		myrevdeps = []
4502
		for myp,mydep in potential_revdeps(mycpv):
4503
			myuse = self.aux_get(myp, ["USE"])[0].split()
4504
			mydep = portage_dep.paren_reduce(mydep)
4505
			mydep = portage_dep.dep_opconvert(mydep)
4506
			mydep = portage_dep.use_reduce(mydep,myuse)
4507
			if parse_dep(mycpv, mydep):
4508
				myrevdeps.append(myp)
4509
		return myrevdeps
4510
			
4423
class vartree(packagetree):
4511
class vartree(packagetree):
4424
	"this tree will scan a var/db/pkg database located at root (passed to init)"
4512
	"this tree will scan a var/db/pkg database located at root (passed to init)"
4425
	def __init__(self,root="/",virtual=None,clone=None,categories=None):
4513
	def __init__(self,root="/",virtual=None,clone=None,categories=None):

Return to bug 2938