diff --git a/config.example.toml b/config.example.toml index 2b72d046..3b1f6ced 100644 --- a/config.example.toml +++ b/config.example.toml @@ -85,3 +85,7 @@ [npm] # Use sudo if the NPM directory isn't owned by the current user #use_sudo = true + +[firmware] +# Offer to update firmware; if false just check for and display available updates +#upgrade = true diff --git a/src/config.rs b/src/config.rs index 60d0dc8e..186c35e2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -154,6 +154,13 @@ pub struct NPM { use_sudo: Option, } +#[derive(Deserialize, Default, Debug)] +#[serde(deny_unknown_fields)] +#[allow(clippy::upper_case_acronyms)] +pub struct Firmware { + upgrade: Option, +} + #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] pub struct Brew { @@ -212,6 +219,7 @@ pub struct ConfigFile { git: Option, windows: Option, npm: Option, + firmware: Option, vagrant: Option, } @@ -730,6 +738,15 @@ impl Config { .unwrap_or(false) } + #[cfg(target_os = "linux")] + pub fn firmware_upgrade(&self) -> bool { + self.config_file + .firmware + .as_ref() + .and_then(|firmware| firmware.upgrade) + .unwrap_or(false) + } + #[cfg(target_os = "linux")] str_value!(linux, emerge_sync_flags); diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 7c23bef2..e263704f 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -521,13 +521,17 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> { .arg("refresh") .check_run_with_codes(&[2])?; - let mut upgrade = ctx.run_type().execute(&fwupdmgr); + let mut updmgr = ctx.run_type().execute(&fwupdmgr); - upgrade.arg("update"); - if ctx.config().yes() { - upgrade.arg("-y"); + if ctx.config().firmware_upgrade() { + updmgr.arg("update"); + if ctx.config().yes() { + updmgr.arg("-y"); + } + } else { + updmgr.arg("get-updates"); } - upgrade.check_run_with_codes(&[2]) + updmgr.check_run_with_codes(&[2]) } pub fn flatpak_update(run_type: RunType) -> Result<()> {