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

Collapse All | Expand All

(-)pym.orig/portage.py (-15 / +93 lines)
Lines 916-921 Link Here
916
			self.dirVirtuals = copy.deepcopy(clone.dirVirtuals)
916
			self.dirVirtuals = copy.deepcopy(clone.dirVirtuals)
917
			self.treeVirtuals = copy.deepcopy(clone.treeVirtuals)
917
			self.treeVirtuals = copy.deepcopy(clone.treeVirtuals)
918
			self.features = copy.deepcopy(clone.features)
918
			self.features = copy.deepcopy(clone.features)
919
920
			self.licensedict = copy.deepcopy(clone.licensedict)
921
			self.plicensedict = copy.deepcopy(clone.plicensedict)
919
		else:
922
		else:
920
923
921
			# backupenv is for calculated incremental variables.
924
			# backupenv is for calculated incremental variables.
Lines 1181-1186 Link Here
1181
1184
1182
			self.pusedict = {}
1185
			self.pusedict = {}
1183
			self.pkeywordsdict = {}
1186
			self.pkeywordsdict = {}
1187
			self.plicensedict = {}
1184
			self.punmaskdict = {}
1188
			self.punmaskdict = {}
1185
			abs_user_config = os.path.join(config_root,
1189
			abs_user_config = os.path.join(config_root,
1186
				USER_CONFIG_PATH.lstrip(os.path.sep))
1190
				USER_CONFIG_PATH.lstrip(os.path.sep))
Lines 1233-1238 Link Here
1233
					if not self.pkeywordsdict.has_key(cp):
1237
					if not self.pkeywordsdict.has_key(cp):
1234
						self.pkeywordsdict[cp] = {}
1238
						self.pkeywordsdict[cp] = {}
1235
					self.pkeywordsdict[cp][key] = pkgdict[key]
1239
					self.pkeywordsdict[cp][key] = pkgdict[key]
1240
				
1241
				#package.license
1242
				licdict = grabdict_package(
1243
					os.path.join(abs_user_config, "package.license"),
1244
					recursive=1)
1245
				for key in licdict.keys():
1246
					cp = dep_getkey(key)
1247
					if not self.plicensedict.has_key(cp):
1248
						self.plicensedict[cp] = {}
1249
					self.plicensedict[cp][key] = licdict[key]
1236
1250
1237
				#package.unmask
1251
				#package.unmask
1238
				pkgunmasklines = grabfile_package(
1252
				pkgunmasklines = grabfile_package(
Lines 1326-1331 Link Here
1326
1340
1327
			self.regenerate()
1341
			self.regenerate()
1328
			self.features = portage_util.unique_array(self["FEATURES"].split())
1342
			self.features = portage_util.unique_array(self["FEATURES"].split())
1343
			
1344
			self.licensedict = {}
1345
			for license in self["ACCEPT_LICENSE"].split():
1346
				self.licensedict[license] = True
1329
1347
1330
			if "gpg" in self.features:
1348
			if "gpg" in self.features:
1331
				if not os.path.exists(self["PORTAGE_GPG_DIR"]) or \
1349
				if not os.path.exists(self["PORTAGE_GPG_DIR"]) or \
Lines 1507-1512 Link Here
1507
		self.modifying()
1525
		self.modifying()
1508
		if self.mycpv == mycpv:
1526
		if self.mycpv == mycpv:
1509
			return
1527
			return
1528
		has_changed = False
1510
		self.mycpv = mycpv
1529
		self.mycpv = mycpv
1511
		cp = dep_getkey(mycpv)
1530
		cp = dep_getkey(mycpv)
1512
		pkginternaluse = ""
1531
		pkginternaluse = ""
Lines 1523-1529 Link Here
1523
				best_match = best_match_to_list(self.mycpv, cpdict.keys())
1542
				best_match = best_match_to_list(self.mycpv, cpdict.keys())
1524
				if best_match:
1543
				if best_match:
1525
					defaults.append(cpdict[best_match])
1544
					defaults.append(cpdict[best_match])
1526
		self.configdict["defaults"]["USE"] = " ".join(defaults)
1545
		defaults = " ".join(defaults)
1546
		if defaults != self.configdict["defaults"]["USE"]:
1547
			self.configdict["defaults"]["USE"] = defaults
1548
			has_changed = True
1527
		useforce = []
1549
		useforce = []
1528
		for i in xrange(len(self.profiles)):
1550
		for i in xrange(len(self.profiles)):
1529
			useforce.append(self.useforce_list[i])
1551
			useforce.append(self.useforce_list[i])
Lines 1532-1538 Link Here
1532
				best_match = best_match_to_list(self.mycpv, cpdict.keys())
1554
				best_match = best_match_to_list(self.mycpv, cpdict.keys())
1533
				if best_match:
1555
				if best_match:
1534
					useforce.append(cpdict[best_match])
1556
					useforce.append(cpdict[best_match])
1535
		self.useforce = set(stack_lists(useforce, incremental=True))
1557
		useforce = set(stack_lists(useforce, incremental=True))
1558
		if useforce.symmetric_difference(self.useforce):
1559
			self.useforce = useforce
1560
			has_changed = True
1536
		usemask = []
1561
		usemask = []
1537
		for i in xrange(len(self.profiles)):
1562
		for i in xrange(len(self.profiles)):
1538
			usemask.append(self.usemask_list[i])
1563
			usemask.append(self.usemask_list[i])
Lines 1541-1557 Link Here
1541
				best_match = best_match_to_list(self.mycpv, cpdict.keys())
1566
				best_match = best_match_to_list(self.mycpv, cpdict.keys())
1542
				if best_match:
1567
				if best_match:
1543
					usemask.append(cpdict[best_match])
1568
					usemask.append(cpdict[best_match])
1544
		self.usemask = set(stack_lists(usemask, incremental=True))
1569
		usemask = set(stack_lists(usemask, incremental=True))
1570
		if usemask.symmetric_difference(self.usemask):
1571
			self.usemask = usemask
1572
			has_changed = True
1573
		oldpuse = self.puse
1545
		self.puse = ""
1574
		self.puse = ""
1546
		if self.pusedict.has_key(cp):
1575
		if self.pusedict.has_key(cp):
1547
			self.pusekey = best_match_to_list(self.mycpv, self.pusedict[cp].keys())
1576
			self.pusekey = best_match_to_list(self.mycpv, self.pusedict[cp].keys())
1548
			if self.pusekey:
1577
			if self.pusekey:
1549
				self.puse = " ".join(self.pusedict[cp][self.pusekey])
1578
				self.puse = " ".join(self.pusedict[cp][self.pusekey])
1579
		if oldpuse != self.puse:
1580
			has_changed = True
1550
		self.configdict["pkg"]["PKGUSE"] = self.puse[:] # For saving to PUSE file
1581
		self.configdict["pkg"]["PKGUSE"] = self.puse[:] # For saving to PUSE file
1551
		self.configdict["pkg"]["USE"]    = self.puse[:] # this gets appended to USE
1582
		self.configdict["pkg"]["USE"]    = self.puse[:] # this gets appended to USE
1552
		# CATEGORY is essential for doebuild calls
1583
		# CATEGORY is essential for doebuild calls
1553
		self.configdict["pkg"]["CATEGORY"] = mycpv.split("/")[0]
1584
		self.configdict["pkg"]["CATEGORY"] = mycpv.split("/")[0]
1554
		self.reset(keeping_pkg=1,use_cache=use_cache)
1585
		if has_changed:
1586
			self.reset(keeping_pkg=1,use_cache=use_cache)
1555
1587
1556
	def setinst(self,mycpv,mydbapi):
1588
	def setinst(self,mycpv,mydbapi):
1557
		self.modifying()
1589
		self.modifying()
Lines 3424-3432 Link Here
3424
	return_all_deps=False):
3456
	return_all_deps=False):
3425
	"""Takes an unreduced and reduced deplist and removes satisfied dependencies.
3457
	"""Takes an unreduced and reduced deplist and removes satisfied dependencies.
3426
	Returned deplist contains steps that must be taken to satisfy dependencies."""
3458
	Returned deplist contains steps that must be taken to satisfy dependencies."""
3427
	if trees is None:
3459
3428
		global db
3429
		trees = db
3430
	writemsg("ZapDeps -- %s\n" % (use_binaries), 2)
3460
	writemsg("ZapDeps -- %s\n" % (use_binaries), 2)
3431
	if not reduced or unreduced == ["||"] or \
3461
	if not reduced or unreduced == ["||"] or \
3432
		(not return_all_deps and dep_eval(reduced)):
3462
		(not return_all_deps and dep_eval(reduced)):
Lines 3447-3452 Link Here
3447
	deps = unreduced[1:]
3477
	deps = unreduced[1:]
3448
	satisfieds = reduced[1:]
3478
	satisfieds = reduced[1:]
3449
3479
3480
	if trees is None:
3481
		# We don't have trees to check availability against, so we
3482
		# just default to the first choice.
3483
		if isinstance(deps[0], list):
3484
			atoms = dep_zapdeps(deps[0], satisfieds[0], myroot,
3485
				use_binaries=use_binaries, trees=trees,
3486
				return_all_deps=return_all_deps)
3487
		else:
3488
			atoms = [deps[0]]
3489
		return atoms
3490
3450
	# Our preference order is for an the first item that:
3491
	# Our preference order is for an the first item that:
3451
	# a) contains all unmasked packages with the same key as installed packages
3492
	# a) contains all unmasked packages with the same key as installed packages
3452
	# b) contains all unmasked packages
3493
	# b) contains all unmasked packages
Lines 3551-3557 Link Here
3551
		mydep, mydb=mydb, use_cache=use_cache, settings=settings) + postfix
3592
		mydep, mydb=mydb, use_cache=use_cache, settings=settings) + postfix
3552
3593
3553
def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
3594
def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
3554
	use_cache=1, use_binaries=0, myroot="/", trees=None, return_all_deps=False):
3595
	use_cache=1, use_binaries=0, myroot="/", trees=None, str_matches=None,
3596
	return_all_deps=False):
3555
	"""Takes a depend string and parses the condition."""
3597
	"""Takes a depend string and parses the condition."""
3556
3598
3557
	#check_config_instance(mysettings)
3599
	#check_config_instance(mysettings)
Lines 3608-3614 Link Here
3608
		#dependencies were reduced to nothing
3650
		#dependencies were reduced to nothing
3609
		return [1,[]]
3651
		return [1,[]]
3610
	mysplit2=mysplit[:]
3652
	mysplit2=mysplit[:]
3611
	mysplit2=dep_wordreduce(mysplit2,mysettings,mydbapi,mode,use_cache=use_cache)
3653
	mysplit2=dep_wordreduce(mysplit2,mysettings,mydbapi,mode,str_matches=str_matches,use_cache=use_cache)
3612
	if mysplit2 is None:
3654
	if mysplit2 is None:
3613
		return [0,"Invalid token"]
3655
		return [0,"Invalid token"]
3614
3656
Lines 3629-3647 Link Here
3629
	writemsg("mydict:   %s\n" % (mydict), 1)
3671
	writemsg("mydict:   %s\n" % (mydict), 1)
3630
	return [1,mydict.keys()]
3672
	return [1,mydict.keys()]
3631
3673
3632
def dep_wordreduce(mydeplist,mysettings,mydbapi,mode,use_cache=1):
3674
def dep_wordreduce(mydeplist,mysettings,mydbapi,mode,str_matches=None,use_cache=1):
3633
	"Reduces the deplist to ones and zeros"
3675
	"Reduces the deplist to ones and zeros"
3634
	mypos=0
3676
	mypos=0
3635
	deplist=mydeplist[:]
3677
	deplist=mydeplist[:]
3636
	while mypos<len(deplist):
3678
	while mypos<len(deplist):
3637
		if type(deplist[mypos])==types.ListType:
3679
		if type(deplist[mypos])==types.ListType:
3638
			#recurse
3680
			#recurse
3639
			deplist[mypos]=dep_wordreduce(deplist[mypos],mysettings,mydbapi,mode,use_cache=use_cache)
3681
			deplist[mypos]=dep_wordreduce(deplist[mypos],mysettings,mydbapi,mode,
3682
				str_matches=str_matches,use_cache=use_cache)
3640
		elif deplist[mypos]=="||":
3683
		elif deplist[mypos]=="||":
3641
			pass
3684
			pass
3642
		else:
3685
		else:
3643
			mykey = dep_getkey(deplist[mypos])
3686
			mykey = dep_getkey(deplist[mypos])
3644
			if mysettings and mysettings.pprovideddict.has_key(mykey) and \
3687
			if str_matches is not None:
3688
				mykey = deplist[mypos]
3689
				deplist[mypos]=(mykey in str_matches)
3690
			elif mysettings and mysettings.pprovideddict.has_key(mykey) and \
3645
			        match_from_list(deplist[mypos], mysettings.pprovideddict[mykey]):
3691
			        match_from_list(deplist[mypos], mysettings.pprovideddict[mykey]):
3646
				deplist[mypos]=True
3692
				deplist[mypos]=True
3647
			else:
3693
			else:
Lines 3846-3852 Link Here
3846
					rValue.append("package.mask")
3892
					rValue.append("package.mask")
3847
3893
3848
	# keywords checking
3894
	# keywords checking
3849
	mygroups, eapi = portdb.aux_get(mycpv, ["KEYWORDS", "EAPI"])
3895
	mygroups, mylicense, eapi = portdb.aux_get(mycpv, ["KEYWORDS", "LICENSE", "EAPI"])
3850
	if not eapi_is_supported(eapi):
3896
	if not eapi_is_supported(eapi):
3851
		return ["required EAPI %s, supported EAPI %s" % (eapi, portage_const.EAPI)]
3897
		return ["required EAPI %s, supported EAPI %s" % (eapi, portage_const.EAPI)]
3852
	mygroups = mygroups.split()
3898
	mygroups = mygroups.split()
Lines 3881-3886 Link Here
3881
3927
3882
	if kmask:
3928
	if kmask:
3883
		rValue.append(kmask+" keyword")
3929
		rValue.append(kmask+" keyword")
3930
3931
	licdict = settings.plicensedict
3932
	plicenses = settings["ACCEPT_LICENSE"].split()
3933
	if licdict.has_key(cp):
3934
		matches = match_to_list(mycpv, pkgdict[cp].keys())
3935
		for match in matches:
3936
			plicenses.extend(licdict[cp][match])
3937
	
3938
	settings.setcpv(mycpv)
3939
	if dep_check(mylicense, None, settings, str_matches=plicenses)[1]:
3940
		license_req = []
3941
		mylicense = mylicense.split()
3942
		for license in mylicense:
3943
			if license in ("(", ")", "||") or license not in plicenses:
3944
				license_req.append(license)
3945
		rValue.append(" ".join(license_req) + " license(s)")
3946
	
3884
	return rValue
3947
	return rValue
3885
3948
3886
class packagetree:
3949
class packagetree:
Lines 5331-5346 Link Here
5331
		newlist=[]
5394
		newlist=[]
5332
5395
5333
		pkgdict = self.mysettings.pkeywordsdict
5396
		pkgdict = self.mysettings.pkeywordsdict
5397
		licdict = self.mysettings.plicensedict
5334
		for mycpv in mylist:
5398
		for mycpv in mylist:
5335
			#we need to update this next line when we have fully integrated the new db api
5399
			#we need to update this next line when we have fully integrated the new db api
5336
			auxerr=0
5400
			auxerr=0
5337
			keys = None
5401
			keys = None
5338
			try:
5402
			try:
5339
				keys, eapi = self.aux_get(mycpv, ["KEYWORDS", "EAPI"])
5403
				keys, license, eapi = self.aux_get(mycpv, ["KEYWORDS", "LICENSE", "EAPI"])
5340
			except KeyError:
5404
			except KeyError:
5341
				pass
5405
				pass
5342
			except portage_exception.PortageException, e:
5406
			except portage_exception.PortageException, e:
5343
				writemsg("!!! Error: aux_get('%s', ['KEYWORDS', 'EAPI'])\n" % mycpv,
5407
				writemsg("!!! Error: aux_get('%s', ['KEYWORDS', 'LICENSE', 'EAPI'])\n" % mycpv,
5344
					noiselevel=-1)
5408
					noiselevel=-1)
5345
				writemsg("!!! %s\n" % str(e),
5409
				writemsg("!!! %s\n" % str(e),
5346
					noiselevel=-1)
5410
					noiselevel=-1)
Lines 5377-5382 Link Here
5377
					hasstable = True
5441
					hasstable = True
5378
			if not match and ((hastesting and "~*" in pgroups) or (hasstable and "*" in pgroups)):
5442
			if not match and ((hastesting and "~*" in pgroups) or (hasstable and "*" in pgroups)):
5379
				match=1
5443
				match=1
5444
			if "*" not in self.mysettings.licensedict:
5445
				if "?" in license:
5446
					self.mysettings.setcpv(mycpv)
5447
				reqd = dep_check(license, None, self.mysettings, str_matches=self.mysettings.licensedict)[1]
5448
				if reqd:
5449
					plicenses = []
5450
					if licdict.has_key(cp):
5451
						matches = match_to_list(mycpv, licdict[cp].keys())
5452
						for atom in matches:
5453
							plicenses.extend(licdict[cp][atom])
5454
					for license in reqd:
5455
						if license not in plicenses:
5456
							match = 0
5457
							break
5380
			if match and eapi_is_supported(eapi):
5458
			if match and eapi_is_supported(eapi):
5381
				newlist.append(mycpv)
5459
				newlist.append(mycpv)
5382
		return newlist
5460
		return newlist

Return to bug 17367