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

(-)pym/portage.py (-11 / +48 lines)
Lines 3945-3950 Link Here
3945
	# d) is the first item
3945
	# d) is the first item
3946
3946
3947
	preferred = []
3947
	preferred = []
3948
	possible_upgrades = []
3948
	other = []
3949
	other = []
3949
3950
3950
	# Alias the trees we'll be checking availability against
3951
	# Alias the trees we'll be checking availability against
Lines 3983-3999 Link Here
3983
		# an installed package. If they will then don't prefer them
3984
		# an installed package. If they will then don't prefer them
3984
		# over other atoms.
3985
		# over other atoms.
3985
		is_downgrade = False
3986
		is_downgrade = False
3986
		if all_installed and all_available:
3987
		versions = {}
3988
		if all_installed or all_available:
3987
			for atom in atoms:
3989
			for atom in atoms:
3988
				mykey = dep_getkey(atom)
3990
				mykey = dep_getkey(atom)
3991
				avail_pkg = best(mydbapi.match(atom))
3992
				if not avail_pkg:
3993
					continue
3994
				avail_slot = mydbapi.aux_get(avail_pkg, ["SLOT"])[0]
3995
				versions["%s:%s" % (mykey, avail_slot)] = avail_pkg
3996
				avail_split = catpkgsplit(avail_pkg)[1:]
3989
				inst_pkgs = vardb.match(mykey)
3997
				inst_pkgs = vardb.match(mykey)
3990
				if not inst_pkgs:
3998
				if not inst_pkgs:
3991
					# This must be a new-style virtual that isn't really
3992
					# installed yet (they have zero cost to install).
3993
					continue
3999
					continue
3994
				avail_pkg = best(mydbapi.match(atom))
3995
				avail_slot = mydbapi.aux_get(avail_pkg, ["SLOT"])[0]
3996
				avail_split = catpkgsplit(avail_pkg)[1:]
3997
				for pkg in inst_pkgs:
4000
				for pkg in inst_pkgs:
3998
					if avail_slot != vardb.aux_get(pkg, ["SLOT"])[0]:
4001
					if avail_slot != vardb.aux_get(pkg, ["SLOT"])[0]:
3999
						continue
4002
						continue
Lines 4003-4013 Link Here
4003
				if is_downgrade:
4006
				if is_downgrade:
4004
					break
4007
					break
4005
4008
4006
		if all_installed and not is_downgrade:
4009
		this_choice = (atoms, versions, all_available)
4007
			preferred.append((atoms, all_available))
4010
		if not is_downgrade:
4008
		else:
4011
			if all_installed:
4009
			other.append((atoms, all_available))
4012
				preferred.append(this_choice)
4013
				continue
4014
			elif all_available:
4015
				possible_upgrades.append(this_choice)
4016
				continue
4017
		other.append(this_choice)
4010
4018
4019
	# Compare the "all_installed" choices against the "all_available" choices
4020
	# for possible missed upgrades.  The main purpose of this code is to find
4021
	# upgrades of new-style virtuals since _expand_new_virtuals() expands them
4022
	# into || ( highest version ... lowest version ).  We want to prefer the
4023
	# highest all_available version of the new-style virtual when there is a
4024
	# lower all_installed version.
4025
	for possible_upgrade in list(possible_upgrades):
4026
		atoms, versions, all_available = possible_upgrade
4027
		myslots = set(versions)
4028
		for other_choice in preferred:
4029
			o_atoms, o_versions, o_all_available = other_choice
4030
			intersecting_slots = myslots.intersection(o_versions)
4031
			if not intersecting_slots:
4032
				continue
4033
			is_downgrade = False
4034
			for myslot in intersecting_slots:
4035
				myversion = versions[myslot]
4036
				o_version = o_versions[myslot]
4037
				if myversion != o_version and \
4038
					o_version == best([myversion, o_version]):
4039
					is_downgrade = True
4040
					break
4041
			if not is_downgrade:
4042
				o_index = preferred.index(other_choice)
4043
				preferred.insert(o_index, possible_upgrade)
4044
				possible_upgrades.remove(possible_upgrade)
4045
				break
4046
	preferred.extend(possible_upgrades)
4047
4011
	# preferred now contains a) and c) from the order above with
4048
	# preferred now contains a) and c) from the order above with
4012
	# the masked flag differentiating the two. other contains b)
4049
	# the masked flag differentiating the two. other contains b)
4013
	# and d) so adding other to preferred will give us a suitable
4050
	# and d) so adding other to preferred will give us a suitable
Lines 4015-4021 Link Here
4015
	preferred.extend(other)
4052
	preferred.extend(other)
4016
4053
4017
	for allow_masked in (False, True):
4054
	for allow_masked in (False, True):
4018
		for atoms, all_available in preferred:
4055
		for atoms, versions, all_available in preferred:
4019
			if all_available or allow_masked:
4056
			if all_available or allow_masked:
4020
				return atoms
4057
				return atoms
4021
4058

Return to bug 159360