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 tree we'll be checking availability against |
3340 |
if use_binaries: |
3341 |
mydbapi = trees[myroot]["bintree"].dbapi |
3342 |
else: |
3343 |
mydbapi = trees[myroot]["porttree"].dbapi |
3344 |
|
3345 |
# Sort the deps into preferred (installed) and other |
3346 |
# with values of [[required_atom], availablility] |
3331 |
for (dep, satisfied) in zip(deps, satisfieds): |
3347 |
for (dep, satisfied) in zip(deps, satisfieds): |
3332 |
if isinstance(dep, list): |
3348 |
if isinstance(dep, list): |
3333 |
atoms = dep_zapdeps(dep, satisfied, myroot, |
3349 |
atoms = dep_zapdeps(dep, satisfied, myroot, |
3334 |
use_binaries=use_binaries, trees=trees) |
3350 |
use_binaries=use_binaries, trees=trees) |
3335 |
else: |
3351 |
else: |
3336 |
atoms = [dep] |
3352 |
atoms = [dep] |
3337 |
missing_atoms = [atom for atom in atoms if not trees[myroot]["vartree"].dbapi.match(atom)] |
|
|
3338 |
|
3353 |
|
3339 |
if not missing_atoms: |
3354 |
all_installed = True |
3340 |
if isinstance(dep, list): |
3355 |
for atom in atoms: |
3341 |
return atoms # Sorted out by the recursed dep_zapdeps call |
3356 |
if not trees[myroot]["vartree"].dbapi.match(dep_getkey(atom)): |
3342 |
else: |
3357 |
all_installed = False |
3343 |
target = dep_getkey(dep) # An installed package that's not yet in the graph |
|
|
3344 |
break |
3358 |
break |
3345 |
|
3359 |
|
3346 |
if not target: |
3360 |
all_available = True |
3347 |
if use_binaries: |
3361 |
for atom in atoms: |
3348 |
missing_atoms = [atom for atom in atoms if not trees[myroot]["bintree"].dbapi.match(atom)] |
3362 |
if not mydbapi.match(atom): |
3349 |
else: |
3363 |
all_available = False |
3350 |
missing_atoms = [atom for atom in atoms if not trees[myroot]["porttree"].dbapi.xmatch("match-visible", atom)] |
3364 |
break |
3351 |
if not missing_atoms: |
3365 |
|
3352 |
target = (dep, satisfied) |
3366 |
if all_installed: |
3353 |
|
3367 |
preferred.append([atoms, all_available]) |
3354 |
if not target: |
|
|
3355 |
if isinstance(deps[0], list): |
3356 |
return dep_zapdeps(deps[0], satisfieds[0], myroot, |
3357 |
use_binaries=use_binaries, trees=trees) |
3358 |
else: |
3368 |
else: |
3359 |
return [deps[0]] |
3369 |
other.append([atoms, all_available]) |
3360 |
|
3370 |
|
3361 |
if isinstance(target, tuple): # Nothing matching installed |
3371 |
# preferred now contains a) and c) from the order above with |
3362 |
if isinstance(target[0], list): # ... and the first available was a sublist |
3372 |
# the masked flag differentiating the two. other contains b) |
3363 |
return dep_zapdeps(target[0], target[1], myroot, |
3373 |
# and d) so adding other to preferred will give us a suitable |
3364 |
use_binaries=use_binaries, trees=trees) |
3374 |
# list to iterate over. |
3365 |
else: # ... and the first available was a single atom |
3375 |
preferred.extend(other) |
3366 |
target = dep_getkey(target[0]) |
3376 |
|
|
|
3377 |
for allow_masked in (False, True): |
3378 |
for (atoms, all_available) in preferred: |
3379 |
if all_available or allow_masked: |
3380 |
return atoms |
3367 |
|
3381 |
|
3368 |
relevant_atoms = [dep for dep in deps if not isinstance(dep, list) and dep_getkey(dep) == target] |
3382 |
assert(False) # This point should not be reachable |
3369 |
|
3383 |
|
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 |
|
3384 |
|
3388 |
def dep_expand(mydep, mydb=None, use_cache=1, settings=None): |
3385 |
def dep_expand(mydep, mydb=None, use_cache=1, settings=None): |
3389 |
if not len(mydep): |
3386 |
if not len(mydep): |