Skip to content

Commit

Permalink
Fallback on dnf if yum does not exist on RHEL-based systems
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate authored and rjbou committed Nov 10, 2021
1 parent 29949fe commit f7e46bb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/state/opamSysInteract.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ let family =
) in
fun () -> Lazy.force family

let yum_cmd = lazy begin
if OpamSystem.resolve_command "yum" <> None then
"yum"
else if OpamSystem.resolve_command "dnf" <> None then
"dnf"
else
failwith "Could not find either yum or dnf to install external dependencies"
end

let packages_status packages =
let (+++) pkg set = OpamSysPkg.Set.add (OpamSysPkg.of_string pkg) set in
Expand Down Expand Up @@ -632,11 +640,11 @@ let install_packages_commands_t sys_packages =
let epel_release = "epel-release" in
let install_epel rest =
if List.mem epel_release packages then
["yum", "install"::yes ["-y"] [epel_release]] @ rest
[Lazy.force yum_cmd, "install"::yes ["-y"] [epel_release]] @ rest
else rest
in
install_epel
["yum", "install"::yes ["-y"]
[Lazy.force yum_cmd, "install"::yes ["-y"]
(OpamStd.String.Set.of_list packages
|> OpamStd.String.Set.remove epel_release
|> OpamStd.String.Set.elements);
Expand Down Expand Up @@ -701,7 +709,7 @@ let update () =
match family () with
| Alpine -> Some ("apk", ["update"])
| Arch -> Some ("pacman", ["-Sy"])
| Centos -> Some ("yum", ["makecache"])
| Centos -> Some (Lazy.force yum_cmd, ["makecache"])
| Debian -> Some ("apt-get", ["update"])
| Gentoo -> Some ("emerge", ["--sync"])
| Homebrew -> Some ("brew", ["update"])
Expand Down

0 comments on commit f7e46bb

Please sign in to comment.