Linux: System: Fix rpm-ostree detection (#816)

On a rpm-ostree based system, topgrade would previously fail to detect
the rpm-ostree executable and fall back to yum instead, which isn't
available. This was caused by constructing a Path instance with
`Path::new`, rather than querying the underlying OS for a path to the
rpm-ostree executable.

Make the `system` update step use `which` to determine if an executable
called "rpm-ostree" is available on the system and get the correct path
to the executable.
This commit is contained in:
Funky185540
2021-12-26 10:42:09 +01:00
committed by GitHub
parent 7d42ba4e52
commit 81fb880155

View File

@@ -157,7 +157,7 @@ fn upgrade_alpine_linux(ctx: &ExecutionContext) -> Result<()> {
}
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
let _ = if let Some(ostree) = Path::new("rpm-ostree").if_exists() {
if let Some(ostree) = which("rpm-ostree") {
if ctx.config().rpm_ostree() {
let mut command = ctx.run_type().execute(ostree);
command.arg("upgrade");