Skip to content

Commit

Permalink
feat: allow to configure the apt upgrade method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thvitt committed Mar 24, 2024
1 parent 373cd3b commit eed298c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@
# Extra Home Manager arguments
# home_manager_arguments = ["--flake", "file"]

# subcommand to use for apt variants != nala (dist-upgrade (default) or upgrade)
# apt_command = "dist-upgrade"

[git]
# How many repos to pull at max in parallel
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ pub struct Linux {
nix_env_arguments: Option<String>,

#[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
apt_command: Option<String>,
apt_arguments: Option<String>,

enable_tlmgr: Option<bool>,
Expand Down Expand Up @@ -1228,6 +1229,15 @@ impl Config {
.unwrap_or("")
}

/// apt command: upgrade or dist-upgrade
pub fn apt_command(&self) -> &str {
self.config_file
.linux
.as_ref()
.and_then(|linux| linux.apt_command.as_deref())
.unwrap_or("dist-upgrade")
}

Check warning on line 1240 in src/config.rs

View check run for this annotation

Codecov / codecov/patch

src/config.rs#L1232-L1240

Added lines #L1232 - L1240 were not covered by tests
/// Extra apt arguments
pub fn apt_arguments(&self) -> Option<&str> {
self.config_file
Expand Down
3 changes: 2 additions & 1 deletion src/steps/os/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
if is_nala {
command.arg("upgrade");
} else {
command.arg("dist-upgrade");
let apt_command = ctx.config().apt_command();
command.arg(apt_command);

Check warning on line 522 in src/steps/os/linux.rs

View check run for this annotation

Codecov / codecov/patch

src/steps/os/linux.rs#L521-L522

Added lines #L521 - L522 were not covered by tests
};
if ctx.config().yes(Step::System) {
command.arg("-y");
Expand Down

0 comments on commit eed298c

Please sign in to comment.