Basically the idea is that we pass auto_fix=False to the cache
and then use resolve_by_keep() to revert any removals that cause
additional removals.
This is easier than it sounds however, as we need to pay special
attention to forced_obsoletes. As can be seen in the code, forced
obsoletes also remove additional dependencies (they do not check
the changes made by mark_delete() and revert it).
So we solve this with a two stage approach:
1. We mark the forced obsoletes for removal with auto_fix turned
on. This will keep the behavior for them the same. If one of
them can't be removed, we end up reverting it.
For this, we need to keep the code to create and restore the
snapshot.
2. We mark the other packages for removal without auto_fix and
then call ProblemResolver.resolve_by_keep() to fix any broken
packages by keeping them back.
This brings runtime from multiple seconds down to half a second
for a bare lxd container:
2024-04-29 10:34:35,549 DEBUG Start checking for obsolete pkgs
2024-04-29 10:34:35,912 DEBUG Finish checking for obsolete pkgs
It used to be over 11s before:
2024-04-29 10:28:59,382 DEBUG Start checking for obsolete pkgs
2024-04-29 10:29:11,855 DEBUG Finish checking for obsolete pkgs
Do not write automatically installed bit in simulation
The previous fix was incomplete, while it correctly marked
the packages as automatically installed on the first run,
the simulation ran and then we recalculated the changes.
Since the simulation was writing out the extended_states
for the post-upgrade state, the extended_states files lost
the auto bit for the removed packages, so the next run, when
we recalulcate the changes, didn't see the auto bit anymore,
and packages end up manually installed.
Transition the automatically installed bit to t64 libraries
We accidentally marked t64 replacements as manually installed
with the initial version. Fix this by transitioning the automatically
installed bit from the installed library package.
An alternative approach would be to always mark them automatically
installed, but this better preserves user intent.
That being said, we need to quirk this for 24.10 to fix up any
installs that we broke automatic tracking off.
DistUpgrade.cfg.jammy: Add systemd-resolved to PostUpgradeInstall
More and more reports coming in of systemd-resolved failing to install,
but we can't reproduce it, and the logging has gaps - we don't seem to
have Debug::pkgDepCache::Marker on where systemd is being upgraded, so
we don't see why the Recommends is not marked for install.
Adding it to PostUpgradeInstall is the easy way out here.
DistUpgradeQuirks: keep {netfilter,iptables}-persistent instead of ufw
This replaces commit 7907bea8f6
("DistUpgrade.cfg.jammy: keep {netfilter,iptables}-persistent installed").
Using KeepInstalledPkgs meant that ufw was kept around too, which is not
what we wanted. Just add a new quirk for this: on upgrades from jammy,
if netfilter-persistent and/or iptables-persistent are installed
alongside ufw, keep the former package(s) and remove ufw.