Don’t trust the wiki, it describes the initial design from a long time ago. The string itself changed, and we actually seed a RNG since quite a long time, even in the Python code in update-manager.
To be concrete, what happens in APT is that we take the string <source package>-<source version>-<machine id>
, seed a std::minstd_rand
RNG and then use std::uniform_int_distribution<unsigned int> dist(0, 100)
to create a value between 0 and 100 which we then compare with the percentage:
std::string seedStr = std::string(Ver.SourcePkgName()) + "-" + Ver.SourceVerStr() + "-" + machineID;
std::seed_seq seed(seedStr.begin(), seedStr.end());
std::minstd_rand rand(seed);
std::uniform_int_distribution<unsigned int> dist(0, 100);
return dist(rand) > Ver.PhasedUpdatePercentage();
This might yield different values from update-manager due to differences in seeding and RNG implementation between Python and gcc’s libstdc++.
However apt’s one is implemented a level lower and can’t be overriden by update-manager anyway, so it’s safe.
Or between different C++ standard libraries, even, I suppose. I don’t know how much the behavior of minstd_rng
and others are standardized.
I don’t know for sure why we stopped using md5sum, that was decades ago, but it certainly simplifies the math rather than having to use ** 128
(and rng seeding presumably is faster than md5 too?).