Skip to content

Commit

Permalink
Exposed unmodified functionality from dockerfile-opam
Browse files Browse the repository at this point in the history
  • Loading branch information
benmandrew committed Apr 11, 2023
1 parent b0a119d commit e3af0ba
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib_spec_opam/distro.ml
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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 ]
Expand All @@ -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)
Expand All @@ -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) =
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
59 changes: 59 additions & 0 deletions lib_spec_opam/distro.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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. *)

Expand All @@ -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. *)
Expand All @@ -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. *)
Expand Down Expand Up @@ -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 <https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images> *)

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 ->
Expand All @@ -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] *)
Expand All @@ -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 <https://en.wikipedia.org/wiki/Windows_10_version_history#Channels> *)

val active_distros : Ocaml_version.arch -> t list
(** [active_distros arch] returns the list of currently supported
distributions in the opam build infrastructure. Distributions
Expand Down

0 comments on commit e3af0ba

Please sign in to comment.