diff --git a/config.example.toml b/config.example.toml index 7b6b6512..815baff5 100644 --- a/config.example.toml +++ b/config.example.toml @@ -16,6 +16,9 @@ # Arguments to pass Git when pulling Repositories #git_arguments = "--rebase --autostash" +# Arguments to pass yay when updating packages +#yay_arguments = "--nodevel" + # Do not set the terminal title #set_title = false # Commands to run before anything diff --git a/src/config.rs b/src/config.rs index 001906d3..32daf9a7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -61,6 +61,7 @@ pub struct ConfigFile { git_arguments: Option, set_title: Option, assume_yes: Option, + yay_arguments: Option, } impl ConfigFile { @@ -286,4 +287,13 @@ impl Config { pub fn yes(&self) -> bool { self.config_file.assume_yes.unwrap_or(self.opt.yes) } + + /// Extra yay arguments + #[cfg(target_os = "linux")] + pub fn yay_arguments(&self) -> &str { + match &self.config_file.yay_arguments { + Some(args) => args.as_str(), + None => "--devel", + } + } } diff --git a/src/main.rs b/src/main.rs index a3e3fc79..38bed327 100644 --- a/src/main.rs +++ b/src/main.rs @@ -158,7 +158,7 @@ fn run() -> Result<(), Error> { execute( &mut report, "System update", - || distribution.upgrade(&sudo, config.cleanup(), run_type, config.yes()), + || distribution.upgrade(&sudo, run_type, &config), config.no_retry(), )?; } diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 791cba1a..da496547 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -1,3 +1,4 @@ +use crate::config::Config; use crate::error::{Error, ErrorKind}; use crate::executor::RunType; use crate::terminal::{print_separator, print_warning}; @@ -75,11 +76,14 @@ impl Distribution { } #[must_use] - pub fn upgrade(self, sudo: &Option, cleanup: bool, run_type: RunType, yes: bool) -> Result<(), Error> { + pub fn upgrade(self, sudo: &Option, run_type: RunType, config: &Config) -> Result<(), Error> { print_separator("System update"); + let yes = config.yes(); + let cleanup = config.cleanup(); + match self { - Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, run_type, yes), + Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, run_type, yes, &config.yay_arguments()), Distribution::CentOS | Distribution::Fedora => upgrade_redhat(&sudo, run_type, yes), Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type, yes), Distribution::Gentoo => upgrade_gentoo(&sudo, run_type), @@ -118,7 +122,13 @@ pub fn show_pacnew() { } } -fn upgrade_arch_linux(sudo: &Option, cleanup: bool, run_type: RunType, yes: bool) -> Result<(), Error> { +fn upgrade_arch_linux( + sudo: &Option, + cleanup: bool, + run_type: RunType, + yes: bool, + yay_arguments: &str, +) -> Result<(), Error> { let pacman = which("powerpill").unwrap_or_else(|| PathBuf::from("/usr/bin/pacman")); let path = { @@ -135,7 +145,7 @@ fn upgrade_arch_linux(sudo: &Option, cleanup: bool, run_type: RunType, .arg("--pacman") .arg(pacman) .arg("-Syu") - .arg("--devel") + .args(yay_arguments.split_whitespace()) .env("PATH", path); if yes {