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:
committed by
GitHub
parent
74292ef6d2
commit
2cd1ea6845
@@ -534,18 +534,30 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
|
||||
updmgr.check_run_with_codes(&[2])
|
||||
}
|
||||
|
||||
pub fn flatpak_update(run_type: RunType) -> Result<()> {
|
||||
pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let flatpak = require("flatpak")?;
|
||||
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
|
||||
let run_type = ctx.run_type();
|
||||
print_separator("Flatpak User Packages");
|
||||
|
||||
run_type
|
||||
.execute(&flatpak)
|
||||
.args(&["update", "--user", "-y"])
|
||||
.check_run()?;
|
||||
run_type
|
||||
.execute(&flatpak)
|
||||
.args(&["update", "--system", "-y"])
|
||||
.check_run()
|
||||
|
||||
print_separator("Flatpak System Packages");
|
||||
if ctx.config().flatpak_use_sudo() {
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(flatpak)
|
||||
.args(&["update", "--system", "-y"])
|
||||
.check_run()
|
||||
} else {
|
||||
run_type
|
||||
.execute(&flatpak)
|
||||
.args(&["update", "--system", "-y"])
|
||||
.check_run()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user