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

Collapse All | Expand All

(-)portage.py.orig (-45 / +65 lines)
Lines 3323-3389 Link Here
3323
				unresolved.append(dep)
3323
				unresolved.append(dep)
3324
		return unresolved
3324
		return unresolved
3325
3325
3326
	# We're at a ( || atom ... ) type level
3326
	# We're at a ( || atom ... ) type level and need to make a choice
3327
	deps = unreduced[1:]
3327
	deps = unreduced[1:]
3328
	satisfieds = reduced[1:]
3328
	satisfieds = reduced[1:]
3329
3329
3330
	target = None
3330
	# Our preference order is for an the first item that:
3331
	# a) contains all unmasked packages with the same key as installed packages
3332
	# b) contains all unmasked packages
3333
	# c) contains masked installed packages
3334
	# d) is the first item
3335
3336
	preferred = []
3337
	other = []
3338
3339
	# Alias the trees we'll be checking availability against
3340
	vardb = trees[myroot]["vartree"].dbapi
3341
	if use_binaries:
3342
		mydbapi = trees[myroot]["bintree"].dbapi
3343
	else:
3344
		mydbapi = trees[myroot]["porttree"].dbapi
3345
3346
	# Sort the deps into preferred (installed) and other
3347
	# with values of [[required_atom], availablility]
3331
	for (dep, satisfied) in zip(deps, satisfieds):
3348
	for (dep, satisfied) in zip(deps, satisfieds):
3332
		if isinstance(dep, list):
3349
		if isinstance(dep, list):
3333
			atoms = dep_zapdeps(dep, satisfied, myroot,
3350
			atoms = dep_zapdeps(dep, satisfied, myroot,
3334
				use_binaries=use_binaries, trees=trees)
3351
				use_binaries=use_binaries, trees=trees)
3335
		else:
3352
		else:
3336
			atoms = [dep]
3353
			atoms = [dep]
3337
		missing_atoms = [atom for atom in atoms if not trees[myroot]["vartree"].dbapi.match(atom)]
3338
3354
3339
		if not missing_atoms:
3355
		all_installed = True
3340
			if isinstance(dep, list):
3356
		for atom in atoms:
3341
				return atoms  # Sorted out by the recursed dep_zapdeps call
3357
			if not vardb.match(dep_getkey(atom)):
3342
			else:
3358
				all_installed = False
3343
				target = dep_getkey(dep) # An installed package that's not yet in the graph
3344
				break
3359
				break
3345
3360
3346
		if not target:
3361
		all_available = True
3347
			if use_binaries:
3362
		for atom in atoms:
3348
				missing_atoms = [atom for atom in atoms if not trees[myroot]["bintree"].dbapi.match(atom)]
3363
			if not mydbapi.match(atom):
3349
			else:
3364
				all_available = False
3350
				missing_atoms = [atom for atom in atoms if not trees[myroot]["porttree"].dbapi.xmatch("match-visible", atom)]
3365
				break
3351
			if not missing_atoms:
3366
3352
				target = (dep, satisfied)
3367
		# Check if the set of atoms will result in a downgrade of
3353
3368
		# an installed package. If they will then don't prefer them
3354
	if not target:
3369
		# over other atoms.
3355
		if isinstance(deps[0], list):
3370
		if all_installed and all_available:
3356
			return dep_zapdeps(deps[0], satisfieds[0], myroot,
3371
			for atom in atoms:
3357
				use_binaries=use_binaries, trees=trees)
3372
				inst_pkgs = vardb.match(dep_getkey(atom))
3373
				avail_pkg = best(mydbapi.match(atom))
3374
				avail_slot = mydbapi.aux_get(avail_pkg, ["SLOT"])[0]
3375
				avail_split = pkgsplit(avail_pkg.split("/")[1])
3376
				is_okay = False
3377
				for pkg in inst_pkgs:
3378
					inst_split = pkgsplit(pkg.split("/")[1])
3379
					inst_slot = vardb.aux_get(pkg, ["SLOT"])[0]
3380
					if inst_slot != avail_slot:
3381
						continue
3382
					if pkgcmp(avail_split, inst_split) >= 0:
3383
						is_okay = True
3384
						break
3385
				if not is_okay:
3386
					all_installed = False
3387
					break
3388
3389
		if all_installed:
3390
			preferred.append([atoms, all_available])
3358
		else:
3391
		else:
3359
			return [deps[0]]
3392
			other.append([atoms, all_available])
3360
3393
3361
	if isinstance(target, tuple): # Nothing matching installed
3394
	# preferred now contains a) and c) from the order above with
3362
		if isinstance(target[0], list): # ... and the first available was a sublist
3395
	# the masked flag differentiating the two. other contains b)
3363
			return dep_zapdeps(target[0], target[1], myroot,
3396
	# and d) so adding other to preferred will give us a suitable
3364
				use_binaries=use_binaries, trees=trees)
3397
	# list to iterate over.
3365
		else: # ... and the first available was a single atom
3398
	preferred.extend(other)
3366
			target = dep_getkey(target[0])
3399
3400
	for allow_masked in (False, True):
3401
		for (atoms, all_available) in preferred:
3402
			if all_available or allow_masked:
3403
				return atoms
3367
3404
3368
	relevant_atoms = [dep for dep in deps if not isinstance(dep, list) and dep_getkey(dep) == target]
3405
	assert(False) # This point should not be reachable
3369
3406
3370
	available_pkgs = {}
3371
	for atom in relevant_atoms:
3372
		if use_binaries:
3373
			pkg_list = trees[myroot]["bintree"].dbapi.match(atom)
3374
		else:
3375
			pkg_list = trees[myroot]["porttree"].dbapi.xmatch("match-visible", atom)
3376
		if not pkg_list:
3377
			continue
3378
		pkg = best(pkg_list)
3379
		available_pkgs[pkg] = atom
3380
3381
	if not available_pkgs:
3382
		return [relevant_atoms[0]] # All masked
3383
3384
	target_pkg = best(available_pkgs.keys())
3385
	suitable_atom = available_pkgs[target_pkg]
3386
	return [suitable_atom]
3387
3407
3388
def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
3408
def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
3389
	if not len(mydep):
3409
	if not len(mydep):

Return to bug 143908