Changes from Version 1 of CompareProviders

skvidal (IP:
05/21/10 15:10:14 (8 years ago)



  • CompareProviders

    v0 v1  
     1When yum is depsolving and it finds that a requirement is provided for by more than one pkg it has to make a choice about which pkg to install. At one point in time it decided by choosing the 'first' one. That was too arbitrary so in casting around for a solution the yum developer used the scheme that Anaconda had used for a while which was to use the pkg with the shortest name. If the pkgs had the same 
     2length name then it took the one that sorted first, alphabetically. 
     4This became a problem b/c, while it was deterministic it was a pain to keep up with. In 2008 the yum developers started working on a 
     5scoring system to judge which pkg to pick when multiple pkgs provided a dep. The method is in and is called _compare_providers() 
     7Obviously if you only have one pkg (or multiple versions of the same pkg) then yum just picks the highest version of that pkg which provides the requirement. 
     9Here is what _compare_providers() will do - as of roughly yum 3.2.28: 
     110. each pkg starts out with a score of 0. 
     131. if any of the providers is a newer version of something we have installed then increase their score by 5 
     152. if any of the providers are not the newest version of themselves then decrease their score by 1024 
     173. if any of the providers are obsoleted by another provider, decrease the obsoleted provider's score by 1024 
     194. check the arch distance between the requiring pkg and each of the providers. The pkg with the smallest arch distance 
     20   gets a 5 added to their score. Do the same check but comparing the pkg arch distance to the system arch, not the requiring pkg arch 
     225. compare the sourcerpm  on each provider to the requiring pkg's source rpm. If they share a sourcerpm add 20 to the score 
     246. check the base pkg for each subpkg. If the base pkg is installed on the system add 5 to the provider's score. 
     267. check the prefix of the pkg to the requiring pkg prefix (perl-foo and perl-lib) for each common character in the prefix add 2 points to the provider's score. 
     288. if, at this point, we have pkgs with an equal score - look at the deplist (one layer deep) and see what they would pull in that is NOT already installed. Add 1 to the score of the pkg with the least new deps to be pulled in. 
     309. if all else fails and we STILL have  two pkgs with the same score - take the leaders from the list and compare their name length. Subtract the length of the number of character's in the pkgs name from its score. 
     3210. return the list of providers, sorted best to worst.