Don't require sudo for ostree (fix #479) (#480)

This commit is contained in:
Roey Darwish Dror
2020-07-21 10:05:57 +03:00
committed by GitHub
parent e3d2d11e8a
commit b77bbf57dd

View File

@@ -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() {