steps/linux/flatpak: Respect -y flag (#9)
when deciding whether the `-y` argument should be added to an operation. Previously the `-y` was implicitly assumed for regular updates but was ignored for the cleanup steps. Now, it is added as defined in the topgrade runtime configuration. Authored-by: Andreas Hartmann <hartan@7x.de> Approved-by: Thomas Schönauer <t.schoenauer@hgs-wt.at>
This commit is contained in:
@@ -502,44 +502,50 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
let flatpak = require("flatpak")?;
|
let flatpak = require("flatpak")?;
|
||||||
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
|
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
|
||||||
let cleanup = ctx.config().cleanup();
|
let cleanup = ctx.config().cleanup();
|
||||||
|
let yes = ctx.config().yes(Step::Flatpak);
|
||||||
let run_type = ctx.run_type();
|
let run_type = ctx.run_type();
|
||||||
print_separator("Flatpak User Packages");
|
print_separator("Flatpak User Packages");
|
||||||
|
|
||||||
run_type
|
let mut update_args = vec!["update", "--user"];
|
||||||
.execute(&flatpak)
|
if yes {
|
||||||
.args(&["update", "--user", "-y"])
|
update_args.push("-y");
|
||||||
.check_run()?;
|
}
|
||||||
|
run_type.execute(&flatpak).args(&update_args).check_run()?;
|
||||||
|
|
||||||
if cleanup {
|
if cleanup {
|
||||||
run_type
|
let mut cleanup_args = vec!["uninstall", "--user", "--unused"];
|
||||||
.execute(&flatpak)
|
if yes {
|
||||||
.args(&["uninstall", "--user", "--unused"])
|
cleanup_args.push("-y");
|
||||||
.check_run()?;
|
}
|
||||||
|
run_type.execute(&flatpak).args(&cleanup_args).check_run()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_separator("Flatpak System Packages");
|
print_separator("Flatpak System Packages");
|
||||||
if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() {
|
if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() {
|
||||||
run_type
|
let mut update_args = vec!["update", "--system"];
|
||||||
.execute(&sudo)
|
if yes {
|
||||||
.arg(&flatpak)
|
update_args.push("-y");
|
||||||
.args(&["update", "--system", "-y"])
|
}
|
||||||
.check_run()?;
|
run_type.execute(&sudo).arg(&flatpak).args(&update_args).check_run()?;
|
||||||
if cleanup {
|
if cleanup {
|
||||||
run_type
|
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||||
.execute(sudo)
|
if yes {
|
||||||
.arg(flatpak)
|
cleanup_args.push("-y");
|
||||||
.args(&["uninstall", "--system", "--unused"])
|
}
|
||||||
.check_run()?;
|
run_type.execute(sudo).arg(flatpak).args(&cleanup_args).check_run()?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
run_type
|
let mut update_args = vec!["update", "--system"];
|
||||||
.execute(&flatpak)
|
if yes {
|
||||||
.args(&["update", "--system", "-y"])
|
update_args.push("-y");
|
||||||
.check_run()?;
|
}
|
||||||
|
run_type.execute(&flatpak).args(&update_args).check_run()?;
|
||||||
if cleanup {
|
if cleanup {
|
||||||
run_type
|
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||||
.execute(flatpak)
|
if yes {
|
||||||
.args(&["uninstall", "--system", "--unused"])
|
cleanup_args.push("-y");
|
||||||
.check_run()?;
|
}
|
||||||
|
run_type.execute(flatpak).args(&cleanup_args).check_run()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user