Skip to content

Instantly share code, notes, and snippets.

@julian-klode
Last active March 19, 2021 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julian-klode/49892ea9141e5510dc18c2bac428fe33 to your computer and use it in GitHub Desktop.
Save julian-klode/49892ea9141e5510dc18c2bac428fe33 to your computer and use it in GitHub Desktop.
APT solver questions

Given packages a and b with versions 1,2,3 (higher is more preferred), and a dependency A|B giving preference to A, how would you expect a dependency a|b to expand?

  1. A over B within each preference level:
    a (= 3) | b (= 3) | a (= 2) | b (= 2) | a (= 1) | b (= 1)
    
  2. any A over any B:
    a (= 3) | a (= 2) | a (= 1) | b (= 3) | b (= 2) | b (= 1)
    
  3. candidates first, any non-candidate A over non-candidate B
    a (= 3) | b (= 3) | a (= 2) | a (= 1) | b (= 2) | b (= 1)
    
    

In terms of optimization criteria, options 1 and 2 can be composed from easier criteria, namely one criterium version-preference that makes the solver prefer some versions more than others and a criterium ordering that makes it prefer As over Bs: option 1 first optimizes version-preference then ordering, whereas option 2 reverses that.

In contrast, option 3 is not composable from those criteria.

Considering which option is the best is hard, and there might not be a universal answer. One criterium to evaluate the default behavior could be how discoverable non-standard choices are to the user.

Let's look at aptitude. aptitude already allows non-optimal solutions, and when it picks a non-candidate version, it will warn you about that. From that perspective, option 1 and 3 yield the worst discoverability: If a (= 3) is not satisfiable it would fall back to b (= 3) and not generate any messaging. Option 2 is close to optimal in that regard: We'll try all choices of a that cause a message before trying the silent b (= 3) one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment