Skip to content

mintupdate-cli.py: Don't remove packages when running with --yes - #1114

Open
Amadeus-22 wants to merge 1 commit into
linuxmint:masterfrom
Amadeus-22:automatic-upgrade-no-remove
Open

Amadeus-22 wants to merge 1 commit into
linuxmint:masterfrom
Amadeus-22:automatic-upgrade-no-remove

Conversation

@Amadeus-22

Copy link
Copy Markdown
Contributor

Fixes #1111

Problem

mintupdate-cli upgrade --yes, which the automatic upgrades run, passes --assume-yes to apt-get install. When an update Breaks or Conflicts with installed packages, apt-get resolves it by removing them and --assume-yes accepts that, so a repository caught between two uploads (Proton VPN in #1111) makes the automatic upgrade uninstall the app without anyone seeing it.

Fix

Pass --no-remove together with --assume-yes. apt-get then stops with E: Packages need to be removed but remove is disabled. (exit 100) and installs nothing; the next run installs the updates once the repository is consistent again. Interactive use (without --yes) is unchanged: apt-get lists the removals and asks. The --yes help text and man page say so.

A side effect: while such a conflict exists, the automatic upgrade installs nothing at all, not only the conflicting update. I think that is the safer default for an unattended run, but I can change it to hold back only the conflicting update if you prefer.

How tested

  • tests/test_cli_upgrade.py checks the apt-get arguments with and without --yes (/usr/bin/python3 -m unittest discover -s tests, 14 tests OK; the new test fails on master).
  • On Linux Mint 22.2, chrony Conflicts with the installed systemd-timesyncd:
    • apt-get install --simulate --assume-yes chrony removes systemd-timesyncd
    • apt-get install --simulate --assume-yes --no-remove chrony prints E: Packages need to be removed but remove is disabled. and exits 100

🤖 Generated with Claude Code

With --assume-yes apt-get accepts its own solution to a Breaks or
Conflicts, including removing installed packages. Automatic upgrades
run "mintupdate-cli upgrade --yes", so a package published before the
packages it breaks were updated made the automatic upgrade remove them
without anybody seeing it (linuxmint#1111).

Pass --no-remove along with --assume-yes. apt-get then aborts with
"Packages need to be removed but remove is disabled" and installs
nothing, and the next run picks the updates up once the repository is
consistent. Without --yes nothing changes: apt-get shows the removals
and asks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@martin152

Copy link
Copy Markdown

I reported #1111, and this covers what happened there. With --no-remove the 09:57 run would have stopped instead of removing the four Proton VPN packages, and since the matching app versions were in the repository shortly after, the next run should have upgraded them together. I checked the apt side here with your chrony example (Mint 22.3, apt 2.8.4). Without --no-remove the simulation removes systemd-timesyncd and exits 0, with it apt prints E: Packages need to be removed but remove is disabled. and exits 100.

One gap though. mintupdate-cli doesn't look at the return code of the apt-get call, and system_automatic_upgrades.py writes "Automatic Upgrade completed" either way, so the service still reports success (#1107). A conflict that clears by the next run, like the Proton one, costs a day. One that doesn't clear would stop every automatic upgrade, security updates included, and the only trace would be the error in /var/log/mintupdate.log.

@Amadeus-22

Copy link
Copy Markdown
Contributor Author

Thanks @martin152 for testing it on 22.3 and confirming the apt side.

The gap you describe is #1107, and #1115 addresses it: mintupdate-cli exits with apt-get's status, and system_automatic_upgrades.py logs -- Automatic Upgrade failed (exit N) and exits with that status, so mintupdate-automation-upgrade.service is marked failed instead of reporting success. With both merged, a conflict like the Proton one stops the run without removing anything, and it also shows up as a failed unit instead of only in /var/log/mintupdate.log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic upgrade removes installed packages to apply an update

2 participants