Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from yum to DNF for Fedora, CentOS and OracleLinux #127

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
----------

- Switch from yum to DNF for Fedora, CentOS and OracleLinux. (@MisterDA, #???)
- Add Fedora 36. (@MisterDA #125)
- Add Ubuntu 22.10. (@MisterDA #124)
- Support STOPSIGNAL instruction. (@MisterDA #121, review by @avsm)
Expand Down
8 changes: 4 additions & 4 deletions src-opam/distro.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1093,16 +1093,16 @@ let latest_tag_of_distro (t : t) =
tag_of_distro latest

type package_manager =
[ `Apt | `Yum | `Apk | `Zypper | `Pacman | `Cygwin | `Windows ]
[ `Apt | `Dnf | `Apk | `Zypper | `Pacman | `Cygwin | `Windows ]
[@@deriving sexp]

let package_manager (t : t) =
match t with
| `Ubuntu _ -> `Apt
| `Debian _ -> `Apt
| `CentOS _ -> `Yum
| `Fedora _ -> `Yum
| `OracleLinux _ -> `Yum
| `CentOS _ -> `Dnf
Copy link
Contributor

@edwintorok edwintorok Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ALL CentOS supports DNF. CentOS 7 (which is what I'm currently using the docker containers for, still in support upstream until 2024) does not have DNF, but just Yum, so might be useful to retain 'Yum' as a package manager and just add DNF.
(Although Yum is still present as an alias in newer versions of Fedora, although unsure for how long)

| `Fedora _ -> `Dnf
| `OracleLinux _ -> `Dnf
| `Alpine _ -> `Apk
| `Archlinux _ -> `Pacman
| `OpenSUSE _ -> `Zypper
Expand Down
2 changes: 1 addition & 1 deletion src-opam/distro.mli
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ val human_readable_short_string_of_distro : t -> string
type package_manager =
[ `Apk (** Alpine Apk *)
| `Apt (** Debian Apt *)
| `Yum (** Fedora Yum *)
| `Dnf (** Fedora DNF *)
| `Zypper (** OpenSUSE Zypper *)
| `Pacman (** Archlinux Pacman *)
| `Cygwin (** Cygwin package manager *)
Expand Down
6 changes: 3 additions & 3 deletions src-opam/linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ let sudo_nopasswd = "ALL=(ALL:ALL) NOPASSWD:ALL"

(** RPM rules *)
module RPM = struct
let update = run "yum update -y"
let install fmt = ksprintf (run "yum install -y %s && yum clean all") fmt
let update = run "dnf update -y"
let install fmt = ksprintf (run "dnf install -y %s && dnf clean all") fmt

let groupinstall fmt =
ksprintf (run "yum groupinstall -y %s && yum clean all") fmt
ksprintf (run "dnf groupinstall -y %s && dnf clean all") fmt

let add_user ?uid ?gid ?(sudo = false) username =
let uid = match uid with Some u -> sprintf "-u %d " u | None -> "" in
Expand Down
8 changes: 4 additions & 4 deletions src-opam/linux.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ val run_as_user : string -> ('a, unit, string, t) format4 -> 'a
(** Rules for RPM-based distributions *)
module RPM : sig
val update : t
(** [update] will run [yum update -y] *)
(** [update] will run [dnf update -y] *)

val install : ('a, unit, string, t) format4 -> 'a
(** [install fmt] will run [yum install] on the supplied package list. *)
(** [install fmt] will run [dnf install] on the supplied package list. *)

val groupinstall : ('a, unit, string, t) format4 -> 'a
(** [groupinstall fmt] will run [yum groupinstall] on the supplied package list. *)
(** [groupinstall fmt] will run [dnf groupinstall] on the supplied package list. *)

val add_user : ?uid:int -> ?gid:int -> ?sudo:bool -> string -> t
(** [add_user username] will install a new user with name [username] and a locked
Expand All @@ -49,7 +49,7 @@ module RPM : sig
[passwd] and [git]. Extra packages may also be optionally supplied via [extra]. *)

val install_system_ocaml : t
(** Install the system OCaml packages via Yum *)
(** Install the system OCaml packages via DNF *)
end

(** Rules for Apt-based distributions *)
Expand Down
12 changes: 5 additions & 7 deletions src-opam/opam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let bubblewrap_and_dev_packages distro =
match D.package_manager distro with
| `Apk -> Linux.Apk.dev_packages
| `Apt -> Linux.Apt.dev_packages
| `Yum -> Linux.RPM.dev_packages
| `Dnf -> Linux.RPM.dev_packages
| `Zypper -> Linux.Zypper.dev_packages
| `Pacman -> Linux.Pacman.dev_packages
| `Cygwin | `Windows -> assert false
Expand Down Expand Up @@ -281,7 +281,7 @@ let apt_opam2 ?(labels = []) ?arch distro ~opam_hashes () =

[enable_powertools] enables the PowerTools repository on CentOS 8 and above.
This is needed to get most of *-devel packages frequently used by opam packages. *)
let yum_opam2 ?(labels = []) ?arch ~yum_workaround ~enable_powertools
let dnf_opam2 ?(labels = []) ?arch ~yum_workaround ~enable_powertools
~opam_hashes distro () =
let opam_master_hash, opam_branches = create_opam_branches opam_hashes in
let img, tag = D.base_distro_tag ?arch distro in
Expand All @@ -292,19 +292,17 @@ let yum_opam2 ?(labels = []) ?arch ~yum_workaround ~enable_powertools
in
header ?arch distro
@@ label (("distro_style", "rpm") :: labels)
@@ run "yum --version || dnf install -y yum"
@@ workaround @@ Linux.RPM.update
@@ Linux.RPM.dev_packages ~extra:"which tar curl xz libcap-devel openssl" ()
@@ Linux.Git.init ()
@@ maybe_build_bubblewrap_from_source distro
@@ install_opams ~prefix:"/usr" opam_master_hash opam_branches
@@ from ~tag img
@@ run "yum --version || dnf install -y yum"
@@ workaround @@ Linux.RPM.update
@@ bubblewrap_and_dev_packages distro
@@ copy_opams ~src:"/usr/bin" ~dst:"/usr/bin" opam_branches
@@ (if enable_powertools then
run "yum config-manager --set-enabled powertools" @@ Linux.RPM.update
run "dnf config-manager --set-enabled powertools" @@ Linux.RPM.update
else empty)
@@ run
"sed -i.bak '/LC_TIME LC_ALL LANGUAGE/aDefaults env_keep += \
Expand Down Expand Up @@ -393,15 +391,15 @@ let gen_opam2_distro ?win10_revision ?winget ?(clone_opam_repo = true) ?arch
match D.package_manager d with
| `Apk -> apk_opam2 ?labels ?arch ~opam_hashes d ()
| `Apt -> apt_opam2 ?labels ?arch ~opam_hashes d ()
| `Yum ->
| `Dnf ->
let yum_workaround = match d with `CentOS `V7 -> true | _ -> false in
let enable_powertools =
match d with
| `CentOS (`V6 | `V7) -> false
| `CentOS _ -> true
| _ -> false
in
yum_opam2 ?labels ?arch ~yum_workaround ~enable_powertools ~opam_hashes
dnf_opam2 ?labels ?arch ~yum_workaround ~enable_powertools ~opam_hashes
d ()
| `Zypper -> zypper_opam2 ?labels ?arch ~opam_hashes d ()
| `Pacman -> pacman_opam2 ?labels ?arch ~opam_hashes d ()
Expand Down