From e3af0ba6842146cc0f782e70eb9feea11788db17 Mon Sep 17 00:00:00 2001 From: benmandrew Date: Fri, 7 Apr 2023 16:31:26 +0200 Subject: [PATCH] Exposed unmodified functionality from dockerfile-opam --- lib_spec_opam/distro.ml | 33 ++++++++++++++++++++++ lib_spec_opam/distro.mli | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/lib_spec_opam/distro.ml b/lib_spec_opam/distro.ml index 29719a6b..2aeef903 100644 --- a/lib_spec_opam/distro.ml +++ b/lib_spec_opam/distro.ml @@ -1,6 +1,14 @@ module OV = Ocaml_version module D = Dockerfile_opam.Distro +type win10_release = D.win10_release [@@deriving sexp] +type win10_ltsc = D.win10_ltsc [@@deriving sexp] +type win_all = D.win_all [@@deriving sexp] +type win10_lcu = D.win10_lcu [@@deriving sexp] + +let win10_current_lcu = D.win10_current_lcu + +type win10_revision = D.win10_revision [@@deriving sexp] type distro = [ D.distro | `Macos of [ `V12 | `V13 ] ] [@@deriving sexp] type t = [ D.t | `Macos of [ `Latest | `V12 | `V13 ] ] [@@deriving sexp] type os_family = [ D.os_family | `Macos ] [@@deriving sexp] @@ -20,6 +28,11 @@ let opam_repository (os : os_family) = | #D.os_family as os -> D.opam_repository os | `Macos -> "https://github.com/ocaml/opam-repository.git" +let personality os_family arch = + match os_family with + | #D.os_family as os_family -> D.personality os_family arch + | `Macos -> None + type status = [ `Deprecated | `Active of [ `Tier1 | `Tier2 | `Tier3 ] @@ -30,6 +43,14 @@ type status = let macos_distros = [ `Macos `V12; `Macos `V13 ] let distros = (D.distros :> t list) @ macos_distros +type win10_release_status = D.win10_release_status + +let win10_release_status = D.win10_release_status + +type win10_docker_base_image = D.win10_docker_base_image + +let win10_latest_image = D.win10_latest_image + let resolve_alias (d : t) : distro = match d with | #D.t as d -> (D.resolve_alias d :> distro) @@ -44,6 +65,8 @@ let distro_status (d : t) : status = if (resolved : distro :> t) <> d then `Alias else `Active `Tier2 let latest_distros = (D.latest_distros :> t list) @ [ `Macos `Latest ] + +let win10_latest_release = D.win10_latest_release let master_distro = (D.master_distro :> t) let distro_arches ov (d : t) = @@ -90,6 +113,14 @@ let active_tier3_distros arch = let builtin_ocaml_of_distro (d : t) = match d with #D.t as d -> D.builtin_ocaml_of_distro d | `Macos _ -> None +let win10_release_to_string = D.win10_release_to_string + +let win10_release_of_string = D.win10_release_of_string + +let win10_revision_to_string = D.win10_revision_to_string + +let win10_revision_of_string = D.win10_revision_of_string + let tag_of_distro (d : t) = match d with | #D.t as d -> D.tag_of_distro d @@ -138,6 +169,8 @@ let package_manager (d : t) : package_manager = let bubblewrap_version (d : t) = match d with #D.t as d -> D.bubblewrap_version d | `Macos _ -> None +let win10_base_tag = D.win10_base_tag + let base_distro_tag ?win10_revision ?(arch = `X86_64) (d : t) = match d with | #D.t as d -> D.base_distro_tag ?win10_revision ~arch d diff --git a/lib_spec_opam/distro.mli b/lib_spec_opam/distro.mli index d744cccf..67fffdd7 100644 --- a/lib_spec_opam/distro.mli +++ b/lib_spec_opam/distro.mli @@ -2,6 +2,18 @@ open Dockerfile_opam +type win10_release = Distro.win10_release [@@deriving sexp] + +type win10_ltsc = Distro.win10_ltsc [@@deriving sexp] + +type win_all = Distro.win_all [@@deriving sexp] + +type win10_lcu = Distro.win10_lcu [@@deriving sexp] + +val win10_current_lcu : win10_lcu + +type win10_revision = Distro.win10_revision [@@deriving sexp] + type distro = [ Distro.distro | `Macos of [ `V12 | `V13 ] ] [@@deriving sexp] (** Supported Docker container distributions without aliases. *) @@ -22,6 +34,10 @@ val opam_repository : os_family -> string (** [opam_repository os_family] returns the git URL to the default Opam repository. *) +val personality : os_family -> Ocaml_version.arch -> string option +(** [personality os_family arch] returns the personality associated to + the architecture, if [os_family] is [`Linux]. *) + val is_same_distro : t -> t -> bool (** [is_same_distro d1 d2] returns whether [d1] is the same distro as [d2], regardless of their respective versions. *) @@ -39,6 +55,14 @@ val distros : t list val latest_distros : t list (** Enumeration of the latest stable (ideally LTS) supported distributions. *) +val win10_latest_release : win10_release +(** Latest Windows 10 release. *) + +val win10_latest_image : win10_release +(** Latest Windows 10 Docker image available. May differ from + {!win10_latest_release} if the Docker repository hasn't been + updated. *) + val master_distro : t (** The distribution that is the top-level alias for the [latest] tag in the [ocaml/opam2] Docker Hub build. *) @@ -84,6 +108,22 @@ val latest_tag_of_distro : t -> string regularly rewritten to point to any new releases of the distribution. *) +type win10_docker_base_image = Distro.win10_docker_base_image +(** Windows containers base images. + @see *) + +val win10_base_tag : + ?win10_revision:win10_lcu -> + win10_docker_base_image -> + win_all -> + string * string +(** [win10_base_tag base_image release] will return a tuple of Windows + container base image and tag for which the base image of a Windows + base image can be found (e.g. + [mcr.microsoft.com/windows/servercore],[ltsc2022] which maps to + [mcr.microsoft.com/windows/servercore:ltsc2022] on the Microsoft + Container Registry). *) + val base_distro_tag : ?win10_revision:Distro.win10_lcu -> ?arch:Ocaml_version.arch -> @@ -96,6 +136,17 @@ val base_distro_tag : and other OCaml tool Dockerfiles. [arch] defaults to [x86_64] and can vary the base user/repository since some architecture are built elsewhere. *) +val win10_release_to_string : win10_release -> string +(** [win10_release_to_string update] converts a Windows 10 version name to + string. *) + +val win10_release_of_string : string -> win_all option +(** [win10_release_of_string] converts a Windows 10 version name as + string to its internal representation. Ignores any KB number. *) + +val win10_revision_to_string : win10_revision -> string +val win10_revision_of_string : string -> win10_revision option + val distro_arches : Ocaml_version.t -> t -> Ocaml_version.arch list (** [distro_arches ov t] returns the list of architectures that distribution [t] is supported on for OCaml compiler version [ov] *) @@ -105,6 +156,14 @@ val distro_supported_on : Ocaml_version.arch -> Ocaml_version.t -> t -> bool combination of CPU [arch], compiler version [ov] is available on the distribution [distro]. *) +type win10_release_status = Distro.win10_release_status +(** Windows 10 release status. *) + +val win10_release_status : win_all -> win10_release_status +(** [win10_release_status v channel] returns the Microsoft support + status of the specified Windows 10 release. + @see *) + val active_distros : Ocaml_version.arch -> t list (** [active_distros arch] returns the list of currently supported distributions in the opam build infrastructure. Distributions