feat: allow to configure the apt upgrade method on debian
dist-upgrade, which was the hard-coded option, is allowed to remove packages in order to resolve dependency conflicts. This might cause quite a mess ... it is left as the default, but can be modified by the option apt_command.
Standards checklist:
- [x] The PR title is descriptive.
- [x] I have read
CONTRIBUTING.md - [x] The code compiles (
cargo build) - [x] The code passes rustfmt (
cargo fmt) - [x] The code passes clippy (
cargo clippy) - [x] The code passes tests (
cargo test) - [x] Optional: I have tested the code myself
For new steps
- [ ] Optional: Topgrade skips this step where needed
- [ ] Optional: The
--dry-runoption works with this step - [ ] Optional: The
--yesoption works with this step if it is supported by the underlying command
If you developed a feature or a bug fix for someone else and you do not have the means to test it, please tag this person here.
Codecov Report
Attention: Patch coverage is 0% with 11 lines in your changes are missing coverage. Please review.
Project coverage is 4.98%. Comparing base (
373cd3b) to head (eed298c).
| Files | Patch % | Lines |
|---|---|---|
| src/config.rs | 0.00% | 9 Missing :warning: |
| src/steps/os/linux.rs | 0.00% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #749 +/- ##
========================================
- Coverage 5.03% 4.98% -0.06%
========================================
Files 37 37
Lines 12085 12216 +131
========================================
Hits 609 609
- Misses 11476 11607 +131
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hi, thanks for your interest in contributing to Topgrade!
The CI failures are not related, please rebase your branch (against main) to get them resolved:)
dist-upgrade, which was the hard-coded option, is allowed to remove packages in order to resolve dependency conflicts. This might cause quite a mess
I can see this disaster, in your opinion, what is the appropriate default command to use? And, I am thinking, it is suitable for most users, then we can actually replace dist-upgrade with it
I can see this disaster, in your opinion, what is the appropriate default command to use? And, I am thinking, it is suitable for most users, then we can actually replace
dist-upgradewith it
upgrade certainly is the safer variant, OTOH I am using topgrade --yes on Debian testing, and they are just migrating to a 64bit datetime type, so I shouldn’t be too surprised :)
My use case for topgrade is 'keep the system relatively up-to-date without too much hassle', so for that, upgrade would be the better default. BTW it looks like it’s the default for nala anyway (nala’s equivalent to apt-get dist-upgrade is nala full-upgrade)
BTW it looks like it’s the default for nala anyway (nala’s equivalent to apt-get dist-upgrade is nala full-upgrade)
Thanks for the info!
I am thinking about:
-
use
apt upgradeas the default option (forapt-fastandapt-get) -
Make the subcommand for
nalaandapt-fast/apt-getconfigurableavailable options that can be specified in the config file:
- upgrade (can be used with
nala/apt-fast/apt-get) - dist-upgrade (ONLY available for
apt-fast/apt-get) - full-upgrade (ONLY available for
nala)
- upgrade (can be used with
-
If an invalid option is specified in the config file, print an error message and skip the step during step execution (i.e., we don't do check if the config is valid while loading configuration)
-
For the config entry name, we might want to use something like this, specifying:
- It is for Debian-like distros
- This is the "upgrade" sub-command
# The upgrade subcommand to use on Debian-like distros # For `apt-get` and `apt-fast`, one can use: # 1. "upgrade" # 2. "dist-upgrade" # # For `nala`, available options: # 1. "upgrade" # 2. "full-upgrade" debian_like_apt_upgrade_cmd = "value"
I would like to hear your thoughts on this since I am not a Debian user:)
The longer I think about it:
- I agree that upgrade should be the default as safest option.
nala full-upgrade≈apt-get dist-upgrade --autoremove- You can, in theory, have apt, apt-fast, and nala installed in parallel and use a different one of them each day, since they all work on the same package store.
I think it is a little confusing to configure the subcommand by hand but let the package manager be autodetected. So maybe the most sensible variant is to have the auto-detected tool with upgrade as default and just offer one configuration option that can be set to the whole command line, like debian_like_upgrade_cmdline = "apt-fast full-upgrade --autoremove"? The update command could just take the first word of this and run it with update, since that is all the same.
Alternatively, maybe a boolean option debian_like_dist_upgrade that, when true, selects dist-upgrade or full-upgrade depending on the detected package manager.
I think it is a little confusing to configure the subcommand by hand but let the package manager be autodetected. So maybe the most sensible variant is to have the auto-detected tool with upgrade as default and just offer one configuration option that can be set to the whole command line,
Yeah, I agree that it feels weird
like debian_like_upgrade_cmdline = "apt-fast full-upgrade --autoremove"?
Though I feel Topgrade should not do such things (let the user write the whole script) either