Use flatpak --system to update flatpak (fix #107)

This commit is contained in:
Roey Darwish Dror
2019-01-16 11:28:37 +02:00
parent d8a9111c48
commit e9d76d185b
2 changed files with 6 additions and 25 deletions

View File

@@ -211,8 +211,7 @@ fn run() -> Result<(), Error> {
#[cfg(target_os = "linux")]
{
report.push_result(execute(|| linux::flatpak_user_update(run_type), opt.no_retry)?);
report.push_result(execute(|| linux::flatpak_global_update(&sudo, run_type), opt.no_retry)?);
report.push_result(execute(|| linux::flatpak_update(run_type), opt.no_retry)?);
report.push_result(execute(|| linux::run_snap(&sudo, run_type), opt.no_retry)?);
}

View File

@@ -274,7 +274,7 @@ pub fn run_fwupdmgr(run_type: RunType) -> Option<(&'static str, bool)> {
}
#[must_use]
pub fn flatpak_user_update(run_type: RunType) -> Option<(&'static str, bool)> {
pub fn flatpak_update(run_type: RunType) -> Option<(&'static str, bool)> {
if let Some(flatpak) = which("flatpak") {
print_separator("Flatpak User Packages");
@@ -283,33 +283,15 @@ pub fn flatpak_user_update(run_type: RunType) -> Option<(&'static str, bool)> {
.execute(&flatpak)
.args(&["update", "--user", "-y"])
.check_run()?;
Ok(())
}()
.is_ok();
return Some(("Flatpak User Packages", success));
}
None
}
#[must_use]
pub fn flatpak_global_update(sudo: &Option<PathBuf>, run_type: RunType) -> Option<(&'static str, bool)> {
if let Some(sudo) = sudo {
if let Some(flatpak) = which("flatpak") {
print_separator("Flatpak Global Packages");
let success = || -> Result<(), Error> {
run_type
.execute(&sudo)
.args(&[flatpak.to_str().unwrap(), "update", "-y"])
.execute(&flatpak)
.args(&["update", "--system", "-y"])
.check_run()?;
Ok(())
}()
.is_ok();
return Some(("Flatpak Global Packages", success));
}
return Some(("Flatpak User Packages", success));
}
None