Skip to content

Commit

Permalink
Merge pull request #4825 from kit-ty-kate/yum-dnf
Browse files Browse the repository at this point in the history
Fallback on dnf if yum does not exist on RHEL-based systems
  • Loading branch information
kit-ty-kate authored Nov 19, 2021
2 parents 8b26e50 + 97ea954 commit 8dc565d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ users)
and installed packages would wait for user input without showing any output and/or fail
in some cases [#4791 @kit-ty-kate - fixes #4790]
* Archlinux: handle virtual package detection [#4831 @rjbou - partial fix #4759]
* Fallback on dnf if yum does not exist on RHEL-based systems [#4825 @kit-ty-kate]

## Format upgrade
* Fix format upgrade when there is missing local switches in the config file [#4763 @rjbou - fix #4713] [2.1.0~rc2 #4715]
Expand Down
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
raise (OpamSystem.Command_not_found "yum or dnf")
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 8dc565d

Please sign in to comment.