Make firmware upgrade configurable (#739)
This change adds an option, firmware.upgrade, that if set to `false` only checks for and displays available firmware updates. If set to `true` (default) the user is offered to run the firmware upgrade.
This commit is contained in:
committed by
GitHub
parent
5ec1f4d2d6
commit
74292ef6d2
@@ -85,3 +85,7 @@
|
|||||||
[npm]
|
[npm]
|
||||||
# Use sudo if the NPM directory isn't owned by the current user
|
# Use sudo if the NPM directory isn't owned by the current user
|
||||||
#use_sudo = true
|
#use_sudo = true
|
||||||
|
|
||||||
|
[firmware]
|
||||||
|
# Offer to update firmware; if false just check for and display available updates
|
||||||
|
#upgrade = true
|
||||||
|
|||||||
@@ -154,6 +154,13 @@ pub struct NPM {
|
|||||||
use_sudo: Option<bool>,
|
use_sudo: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default, Debug)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
|
pub struct Firmware {
|
||||||
|
upgrade: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Brew {
|
pub struct Brew {
|
||||||
@@ -212,6 +219,7 @@ pub struct ConfigFile {
|
|||||||
git: Option<Git>,
|
git: Option<Git>,
|
||||||
windows: Option<Windows>,
|
windows: Option<Windows>,
|
||||||
npm: Option<NPM>,
|
npm: Option<NPM>,
|
||||||
|
firmware: Option<Firmware>,
|
||||||
vagrant: Option<Vagrant>,
|
vagrant: Option<Vagrant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,6 +738,15 @@ impl Config {
|
|||||||
.unwrap_or(false)
|
.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")]
|
#[cfg(target_os = "linux")]
|
||||||
str_value!(linux, emerge_sync_flags);
|
str_value!(linux, emerge_sync_flags);
|
||||||
|
|
||||||
|
|||||||
@@ -521,13 +521,17 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.arg("refresh")
|
.arg("refresh")
|
||||||
.check_run_with_codes(&[2])?;
|
.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().firmware_upgrade() {
|
||||||
if ctx.config().yes() {
|
updmgr.arg("update");
|
||||||
upgrade.arg("-y");
|
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<()> {
|
pub fn flatpak_update(run_type: RunType) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user