From b77bbf57dde088724dfa7d02d1a305513ccd511f Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Tue, 21 Jul 2020 10:05:57 +0300 Subject: [PATCH] Don't require sudo for ostree (fix #479) (#480) --- src/steps/os/linux.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 66ebdb6e..83b95076 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -227,14 +227,24 @@ fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> { } fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> { + if let Some(ostree) = Path::new("/usr/bin/rpm-ostree").if_exists() { + let mut command = ctx.run_type().execute(ostree); + command.arg("upgrade"); + if ctx.config().yes() { + command.arg("-y"); + } + + return command.check_run(); + } + if let Some(sudo) = &ctx.sudo() { let mut command = ctx.run_type().execute(&sudo); command - .arg(Path::new("/usr/bin/dnf").if_exists().unwrap_or_else(|| { - Path::new("/usr/bin/yum") + .arg( + Path::new("/usr/bin/dnf") .if_exists() - .unwrap_or_else(|| Path::new("/usr/bin/rpm-ostree")) - })) + .unwrap_or_else(|| Path::new("/usr/bin/yum")), + ) .arg("upgrade"); if let Some(args) = ctx.config().dnf_arguments() {