Skip to content

libopkg: pkg_hash: rework criteria for dependent package selection

Eneas U de Queiroz requested to merge cotequeiroz/opkg-lede:pkg-selection into master

This PR reworks the dependency package selection score system.

The first two commits attempt to add some order to the way they are currently chosen, by prioritizing packages chosen "by hand" and by preferring packages listed in the command line arguments over new packages chosen automatically.

The third commit adds matching the package without ABI suffix, and establishes a hierarchy among the criteria, prioritizing user choices (i.e. package names given in as command line arguments), then developer choices (chosen package names), and resort to alphabetical order as a last resort.

When resolving dependencies, packages listed in the cli may not have the ABI version, and they should have a higher priority over anything picked automatically.

Use powers of two when computing the score to avoid ties due to different criteria, and so that it reflects what was matched.

The resulting priorities after this change are:

  • base score is 0
USER CHOICE CRITERIA
  • packages "picked by hand" (local file given in the cli) have absolute priority, ending the search regardless of score
  • package whose full name is in the cli: score += 4
  • package whose name stripped of ABI matches one in the cli: score += 2
DEVELOPER CRITERIA
  • package whose full name matches the dependency name: score += 1
  • in case of a tie, the last package that was looked at is chosen (equivalent to being first in alphabetical order)

Signed-off-by: Eneas U de Queiroz cotequeiroz@gmail.com


@Ansuel, I searched hard, found a bit of time to look into this, and it wasn't so complicated after all.

This was tested with the Image Builder, and on Linksys E8450 (mediatek/mt7622, aarch64_cortex-a53).

I tried not to change things so much--aside from restoring the "picked by hand" case, I just created tie-breakers. However, I still have some questions about the necessity of some of this. For example: if more than one dependency is listed in the cli, does it matter which package is chosen? I imagine it would be equivalent of the picked-by-hand case, so it would be simpler and faster to end the search. It could make a difference if one were to install clashing packages with --force-overwrite in the same invocation, but I can't see a scenario where this would be useful.

I'll see if I can scan the cmdline when the package data is loaded, and set provided_by_hand. Don't wait for it, though. It would be on its own commit anyway, and I can always open a new PR.

Edited by Eneas U de Queiroz

Merge request reports