diff --git a/CHANGES.md b/CHANGES.md index 4646835e..77f14148 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,6 @@ unreleased ---------- -- Optimize Linux package install. (@MisterDA #147) - Various LCU Updates (@mtelvers #144 #136 #135) - Support mounts, networks, and security parameters in RUN commands, add buildkit_syntax helper function. diff --git a/src-opam/linux.ml b/src-opam/linux.ml index e049e58c..16516933 100644 --- a/src-opam/linux.ml +++ b/src-opam/linux.ml @@ -32,24 +32,10 @@ let sudo_nopasswd = "ALL=(ALL:ALL) NOPASSWD:ALL" (** RPM rules *) module RPM = struct let update = run "yum update -y" - - let install fmt = - ksprintf - (fun s -> update @@ run "yum install -y %s && yum clean all" s |> crunch) - fmt + let install fmt = ksprintf (run "yum install -y %s && yum clean all") fmt let groupinstall fmt = - ksprintf (fun s -> run "yum groupinstall -y %s && yum clean all" s) fmt - - let dev_packages ?extra () = - let install = ksprintf (run "yum install -y %s") in - update - @@ install - "sudo passwd bzip2 patch rsync nano gcc-c++ git tar curl xz \ - libX11-devel which m4 diffutils findutils%s" - (match extra with None -> "" | Some x -> " " ^ x) - @@ groupinstall "\"Development Tools\"" - |> crunch + ksprintf (run "yum groupinstall -y %s && yum clean all") fmt let add_user ?uid ?gid ?(sudo = false) username = let uid = match uid with Some u -> sprintf "-u %d " u | None -> "" in @@ -72,27 +58,33 @@ module RPM = struct @@ env [ ("HOME", home) ] @@ workdir "%s" home @@ run "mkdir .ssh" @@ run "chmod 700 .ssh" + let dev_packages ?extra () = + groupinstall "\"Development Tools\"" + @@ install + "sudo passwd bzip2 patch rsync nano gcc-c++ git tar curl xz \ + libX11-devel which m4 diffutils findutils%s" + (match extra with None -> "" | Some x -> " " ^ x) + let install_system_ocaml = install "ocaml ocaml-camlp4-devel ocaml-ocamldoc" end (** Debian rules *) module Apt = struct let update = - run "apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" + run "apt-get -y update" + @@ run "DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" let install fmt = ksprintf (fun s -> - update - @@ run "DEBIAN_FRONTEND=noninteractive apt-get -y install %s" s - @@ run "rm -rf /var/lib/apt/lists/*" - |> crunch) + update @@ run "DEBIAN_FRONTEND=noninteractive apt-get -y install %s" s) fmt let dev_packages ?extra () = - copy_heredoc - ~src:[ heredoc ~strip:true "\tAcquire::Retries \"5\";" ] - ~dst:"/etc/apt/apt.conf.d/mirror-retry" () + update + @@ copy_heredoc + ~src:[ heredoc ~strip:true "\tAcquire::Retries \"5\";" ] + ~dst:"/etc/apt/apt.conf.d/mirror-retry" () @@ install "build-essential curl git rsync sudo unzip nano libcap-dev \ libx11-dev%s" @@ -125,12 +117,7 @@ end (** Alpine rules *) module Apk = struct let update = run "apk update && apk upgrade" - - let install fmt = - ksprintf - (fun s -> - update @@ run "apk add %s && rm -f /var/cache/apk/*" s |> crunch) - fmt + let install fmt = ksprintf (fun s -> update @@ run "apk add %s" s) fmt let dev_packages ?extra () = install @@ -160,7 +147,7 @@ module Apk = struct @@ user "%s" username @@ workdir "%s" home @@ run "mkdir .ssh" @@ run "chmod 700 .ssh" - let install_system_ocaml = install "ocaml camlp4" + let install_system_ocaml = run "apk add ocaml camlp4" let add_repository ?tag url = run "<<-EOF cat >> /etc/apk/repositories\n\t%s\nEOF" @@ -183,25 +170,15 @@ module Zypper = struct let install fmt = ksprintf - (fun s -> - update - @@ run "zypper install --force-resolution -y %s" s - @@ run "zypper clean --all" - |> crunch) + (fun s -> update @@ run "zypper install --force-resolution -y %s" s) fmt let dev_packages ?extra () = - let install fmt = - ksprintf (run "zypper install --force-resolution -y %s") fmt - in - update - @@ install "-t pattern devel_C_C++" + install "-t pattern devel_C_C++" @@ install "sudo git unzip curl gcc-c++ libcap-devel xz libX11-devel bzip2 which \ - rsync gzip%s" - (match extra with None -> "" | Some x -> " " ^ x) - @@ run "zypper clean --all" - |> crunch + rsync gzip" + @@ maybe (install "%s") extra let add_user ?uid ?gid ?(sudo = false) username = let home = "/home/" ^ username in @@ -227,9 +204,7 @@ end (** Pacman rules *) module Pacman = struct let update = run "pacman -Syu --noconfirm" - - let install fmt = - ksprintf (fun s -> run "pacman -Syu --noconfirm %s && pacman -Scc" s) fmt + let install fmt = ksprintf (fun s -> run "pacman -Syu --noconfirm %s" s) fmt let dev_packages ?extra () = install @@ -255,5 +230,5 @@ module Pacman = struct @@ user "%s" username @@ workdir "%s" home @@ run "mkdir .ssh" @@ run "chmod 700 .ssh" - let install_system_ocaml = install "ocaml ocaml-compiler-libs" + let install_system_ocaml = run "pacman add ocaml ocaml-compiler-libs" end diff --git a/src-opam/opam.ml b/src-opam/opam.ml index 4dec48f5..60a2ef96 100644 --- a/src-opam/opam.ml +++ b/src-opam/opam.ml @@ -350,14 +350,14 @@ let yum_opam2 ?(labels = []) ?arch ~yum_workaround ~enable_powertools header ?arch distro @@ label (("distro_style", "rpm") :: labels) @@ run "yum --version || dnf install -y yum" - @@ workaround + @@ 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 ?arch distro @@ run "yum --version || dnf install -y yum" - @@ workaround + @@ workaround @@ Linux.RPM.update @@ bubblewrap_and_dev_packages distro @@ copy_opams ~src:"/usr/bin" ~dst:"/usr/bin" opam_branches @@ (if enable_powertools then