From a53bbb0a984bb4a6df51907aedaf14a5b2542353 Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 2 Sep 2021 12:07:02 +0100 Subject: [PATCH] Fallback on dnf if yum does not exist on RHEL-based systems (backports https://github.com/ocaml/opam/pull/4825) Co-authored-by: R. Boujbel --- master_changes.md | 16 ++++++++++++++++ src/state/opamSysInteract.ml | 14 +++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/master_changes.md b/master_changes.md index 78cfb2eac73..36f5bd6a849 100644 --- a/master_changes.md +++ b/master_changes.md @@ -53,6 +53,22 @@ New option/command/subcommand are prefixed with ◈. ## External dependencies * + * Set `DEBIAN_FRONTEND=noninteractive` for unsafe-yes confirmation level [#4735 @dra27 - partially fix #4731] [2.1.0~rc2 #4739] + * Fix depext alpine tagged repositories handling [#4763 @rjbou] [2.1.0~rc2 #4758] + * Homebrew: Add support for casks and full-names [#4801 @kit-ty-kate] + * Disable the detection of available packages on RHEL-based distributions. + This fixes an issue on RHEL-based distributions where yum list used to detect available + 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] + * Fix not recorded local switch handling, with format upgrade [#4763 @rjbou] [2.1.0~rc2 #4715] + * Set opam root version to 2.1 [#4763 @rjbou] [2.1.0~rc2 #4715] + * Fix 2.1~alpha2 to 2.1 format upgrade with reinit [#4763 @rjbou - fix #4748] [2.1.0~rc2 #4750] + * Fix bypass-check handling on reinit [#4750 @rjbou] [#4763 @rjbou] [2.1.0~rc2 #4750 #4756] ## Sandbox * diff --git a/src/state/opamSysInteract.ml b/src/state/opamSysInteract.ml index bdd7594c8eb..69349f502da 100644 --- a/src/state/opamSysInteract.ml +++ b/src/state/opamSysInteract.ml @@ -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 @@ -635,11 +643,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); @@ -704,7 +712,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"])