Allow to run flatpak update with sudo (#738)

This change adds the option `flatpak.use_sudo` that allows to update
the system-wide installation with sudo. When set to `true` the
system-wide installation will be updated with sudo. If set to `false`
(default) the update will be run as regular user.

This solves the problem where running `flatpak update` on a remote
system fails if run as regular user.

Fixes #737.
This commit is contained in:
Eberhard Beilharz
2021-06-30 12:37:41 +02:00
committed by GitHub
parent 74292ef6d2
commit 2cd1ea6845
4 changed files with 39 additions and 6 deletions

View File

@@ -161,6 +161,13 @@ pub struct Firmware {
upgrade: Option<bool>,
}
#[derive(Deserialize, Default, Debug)]
#[serde(deny_unknown_fields)]
#[allow(clippy::upper_case_acronyms)]
pub struct Flatpak {
use_sudo: Option<bool>,
}
#[derive(Deserialize, Default, Debug)]
#[serde(deny_unknown_fields)]
pub struct Brew {
@@ -221,6 +228,7 @@ pub struct ConfigFile {
npm: Option<NPM>,
firmware: Option<Firmware>,
vagrant: Option<Vagrant>,
flatpak: Option<Flatpak>,
}
fn config_directory(base_dirs: &BaseDirs) -> PathBuf {
@@ -747,6 +755,15 @@ impl Config {
.unwrap_or(false)
}
#[cfg(target_os = "linux")]
pub fn flatpak_use_sudo(&self) -> bool {
self.config_file
.flatpak
.as_ref()
.and_then(|flatpak| flatpak.use_sudo)
.unwrap_or(false)
}
#[cfg(target_os = "linux")]
str_value!(linux, emerge_sync_flags);