simpleclient: Preserve the "#auto" install marker through local depen… - #19
Open
AlexB7 wants to merge 1 commit into
Open
simpleclient: Preserve the "#auto" install marker through local depen…#19AlexB7 wants to merge 1 commit into
AlexB7 wants to merge 1 commit into
Conversation
…dency resolution. SimpleAPTClient.install_packages() locally resolves dependencies with python-apt to discover which extra packages a request will pull in (e.g. a kernel image pulled in by a meta package), then flattens those names into the same list sent to the worker. Since none of those names carried the "#auto" suffix that aptworker._mark_packages_for_installation() looks for (and that _check_package_names() already validates at the D-Bus boundary), every package in the flattened list ended up marked as manually installed regardless of whether it was actually requested by the caller or merely a resolved dependency - defeating the purpose of the "#auto" convention and leaving "apt autoremove" unable to reclaim packages like superseded kernels (linuxmint/mintupdate#938). Now, package names already tagged "#auto" by the caller are honored (the tag is stripped only for the local apt.Cache() lookups, which would otherwise fail), and newly-discovered dependency packages that weren't explicitly requested are tagged "#auto" themselves before being handed to the worker. Note this affects every SimpleAPTClient.install_packages() consumer: dependency packages are now recorded as automatically installed, matching standard apt semantics, where previously the flattening step left them permanently manual. Callers that want a dependency pinned as manual can still request it explicitly by name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
randomnoise
reviewed
Aug 14, 2026
| # (e.g. a kernel image pulled in by a meta package): flag it | ||
| # as automatic so it stays eligible for autoremoval, same as | ||
| # a normal "apt install"/"apt upgrade" would leave it. | ||
| packages.append(pkg.name + "#auto") |
Contributor
There was a problem hiding this comment.
Unfortunately, exact duplicate of
Author
There was a problem hiding this comment.
Unfortunately, exact duplicate of
Yes but with some more logic and it's needed for linuxmint/mintupdate#1081.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: linuxmint/mintupdate#938 and linuxmint/mintupdate#1078
Summary
Companion fix to a mintupdate change (https://github.com/linuxmint/mintupdate, branch: autoremove-kernel-fix) that fixes
apt autoremovenever cleaning up old kernels installed via mintupdate. PR linuxmint/mintupdate#1081Root cause
aptworker._mark_packages_for_installation()already supports an opt-in convention for callers: a package name suffixed with#auto(e.g."linux-image-6.17.0-41-generic#auto") is installed withfrom_user=False, i.e. recorded as automatically installed rather than manually installed. This is what lets a caller install a specific package by name while still leaving it eligible forapt autoremovelater, matching how apt would treat it if it had been pulled in as a dependency instead.SimpleAPTClient.install_packages()undermines this. Before handing the package list to the worker over D-Bus, it does a localapt.Cache()dependency resolution pass to discover any additional packages a request will pull in (e.g. a kernel image pulled in by a meta package upgrade), and appends their bare names to the samepackageslist:None of these names carry the
#autosuffix, so every package in the flattened list — both the ones the caller explicitly asked for and the ones only pulled in as a dependency — ends up marked manually installed by the worker. This defeats the purpose of the#autoconvention entirely: even a caller that tags its own request with#autogets nothing, since the local resolver strips out whatever wasn't an exact literal package name in the original list in the first place, and anything it discovers is re-added without the tag.History
The flattening step was introduced in 18d255f ("simpleclient: Use python-apt resolver when installing pkgs", 2024-09-11), days before mintupdate 7.0.0 switched its installs from synaptic to aptkit. The combination is what regressed kernel autoremoval for mintupdate users: under synaptic (and under aptkit without the flattening), dependency packages were marked automatically installed by the resolver, so superseded kernels remained autoremovable. The "#auto" convention itself predates the fork - it was inherited from aptdaemon in the initial aptkit import (April 2022) and validated at the D-Bus boundary all along, but no client ever used it.
Fix
requested_namesby stripping any#autosuffix before doing the localapt.Cache()lookups (apt itself doesn't know about the suffix convention), so callers can pass pre-tagged names throughinstall_packages()without breaking the resolution step.cache.get_changes()but not in the caller's original request) are now tagged#autothemselves before being appended, since by definition they were resolved rather than explicitly requested — matching what a normalapt install/apt upgradewould leave them as.Behavior change for all SimpleAPTClient consumers
Note that the second part affects every caller of
SimpleAPTClient.install_packages()(mintinstall, driver manager, ...), not just mintupdate: dependency packages pulled in alongside a requested package are now recorded as automatically installed, where previously the flattening step left them manually installed. This moves aptkit toward standard apt semantics — after a plainapt install foo, foo's dependencies are marked auto and become autoremovable once nothing needs them — so e.g. libraries installed alongside an application can now be reclaimed byapt autoremoveafter the application is removed, instead of lingering forever. Callers that genuinely want a dependency pinned as manual can still request it explicitly by name.Testing
Manually tested as part of the mintupdate branch above: with this change plus the mintupdate-side tagging,
apt-mark showautoshows newly-installed kernel packages as automatic (previously all showed as manual), andapt-get autoremove --dry-run/apt autoremovecorrectly identify and reclaim superseded kernel packages while leaving the running kernel untouched.No test suite exists in this repo to extend.
Claude Fable 5 was used to fix these issues.