From 13608b1736ced86df4f1a719f5fe77c03c52f717 Mon Sep 17 00:00:00 2001 From: Thorsten Vitt Date: Sat, 23 Mar 2024 18:46:52 +0100 Subject: [PATCH] feat: allow to configure the apt upgrade method 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. --- config.example.toml | 2 ++ src/config.rs | 10 ++++++++++ src/steps/os/linux.rs | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 07d96ae2..72576727 100644 --- a/config.example.toml +++ b/config.example.toml @@ -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 diff --git a/src/config.rs b/src/config.rs index d02038d9..bfd99ba2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -313,6 +313,7 @@ pub struct Linux { nix_env_arguments: Option, #[merge(strategy = crate::utils::merge_strategies::string_append_opt)] + apt_command: Option, apt_arguments: Option, enable_tlmgr: Option, @@ -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") + } + /// Extra apt arguments pub fn apt_arguments(&self) -> Option<&str> { self.config_file diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 6e8b2bd8..fd7a6255 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -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); }; if ctx.config().yes(Step::System) { command.arg("-y");