Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions aptkit/simpleclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ def install_packages(self, packages, use_apt_resolver=True):
# Use the resolver from python-apt
# it works better in complex scenarios
# mark the packages as mark_install
# Package names may carry an explicit "#auto" suffix (see
# aptworker._mark_packages_for_installation()) telling the worker to
# record them as automatically installed rather than manual. Strip it
# for the cache lookups below, since apt itself doesn't know about it.
requested_names = [name.partition("#")[0] for name in packages]
cache = apt.Cache()
for name in packages:
for name in requested_names:
try:
pkg = cache[name]
pkg.mark_install()
Expand All @@ -55,8 +60,12 @@ def install_packages(self, packages, use_apt_resolver=True):
# via cache.get_changes()
changes = cache.get_changes()
for pkg in changes:
if pkg.marked_install and pkg.name not in packages:
packages.append(pkg.name)
if pkg.marked_install and pkg.name not in requested_names:
# Not explicitly requested, just pulled in as a dependency
# (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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, exact duplicate of

Yes but with some more logic and it's needed for linuxmint/mintupdate#1081.


client = aptkit.client.AptClient()
client.install_packages(packages, reply_handler=self._simulate_trans, error_handler=self._on_error)
Expand Down