Skip to content

Commit e3af0ba

Browse files
committed
Exposed unmodified functionality from dockerfile-opam
1 parent b0a119d commit e3af0ba

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

lib_spec_opam/distro.ml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
module OV = Ocaml_version
22
module D = Dockerfile_opam.Distro
33

4+
type win10_release = D.win10_release [@@deriving sexp]
5+
type win10_ltsc = D.win10_ltsc [@@deriving sexp]
6+
type win_all = D.win_all [@@deriving sexp]
7+
type win10_lcu = D.win10_lcu [@@deriving sexp]
8+
9+
let win10_current_lcu = D.win10_current_lcu
10+
11+
type win10_revision = D.win10_revision [@@deriving sexp]
412
type distro = [ D.distro | `Macos of [ `V12 | `V13 ] ] [@@deriving sexp]
513
type t = [ D.t | `Macos of [ `Latest | `V12 | `V13 ] ] [@@deriving sexp]
614
type os_family = [ D.os_family | `Macos ] [@@deriving sexp]
@@ -20,6 +28,11 @@ let opam_repository (os : os_family) =
2028
| #D.os_family as os -> D.opam_repository os
2129
| `Macos -> "https://github.com/ocaml/opam-repository.git"
2230

31+
let personality os_family arch =
32+
match os_family with
33+
| #D.os_family as os_family -> D.personality os_family arch
34+
| `Macos -> None
35+
2336
type status =
2437
[ `Deprecated
2538
| `Active of [ `Tier1 | `Tier2 | `Tier3 ]
@@ -30,6 +43,14 @@ type status =
3043
let macos_distros = [ `Macos `V12; `Macos `V13 ]
3144
let distros = (D.distros :> t list) @ macos_distros
3245

46+
type win10_release_status = D.win10_release_status
47+
48+
let win10_release_status = D.win10_release_status
49+
50+
type win10_docker_base_image = D.win10_docker_base_image
51+
52+
let win10_latest_image = D.win10_latest_image
53+
3354
let resolve_alias (d : t) : distro =
3455
match d with
3556
| #D.t as d -> (D.resolve_alias d :> distro)
@@ -44,6 +65,8 @@ let distro_status (d : t) : status =
4465
if (resolved : distro :> t) <> d then `Alias else `Active `Tier2
4566

4667
let latest_distros = (D.latest_distros :> t list) @ [ `Macos `Latest ]
68+
69+
let win10_latest_release = D.win10_latest_release
4770
let master_distro = (D.master_distro :> t)
4871

4972
let distro_arches ov (d : t) =
@@ -90,6 +113,14 @@ let active_tier3_distros arch =
90113
let builtin_ocaml_of_distro (d : t) =
91114
match d with #D.t as d -> D.builtin_ocaml_of_distro d | `Macos _ -> None
92115

116+
let win10_release_to_string = D.win10_release_to_string
117+
118+
let win10_release_of_string = D.win10_release_of_string
119+
120+
let win10_revision_to_string = D.win10_revision_to_string
121+
122+
let win10_revision_of_string = D.win10_revision_of_string
123+
93124
let tag_of_distro (d : t) =
94125
match d with
95126
| #D.t as d -> D.tag_of_distro d
@@ -138,6 +169,8 @@ let package_manager (d : t) : package_manager =
138169
let bubblewrap_version (d : t) =
139170
match d with #D.t as d -> D.bubblewrap_version d | `Macos _ -> None
140171

172+
let win10_base_tag = D.win10_base_tag
173+
141174
let base_distro_tag ?win10_revision ?(arch = `X86_64) (d : t) =
142175
match d with
143176
| #D.t as d -> D.base_distro_tag ?win10_revision ~arch d

lib_spec_opam/distro.mli

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
open Dockerfile_opam
44

5+
type win10_release = Distro.win10_release [@@deriving sexp]
6+
7+
type win10_ltsc = Distro.win10_ltsc [@@deriving sexp]
8+
9+
type win_all = Distro.win_all [@@deriving sexp]
10+
11+
type win10_lcu = Distro.win10_lcu [@@deriving sexp]
12+
13+
val win10_current_lcu : win10_lcu
14+
15+
type win10_revision = Distro.win10_revision [@@deriving sexp]
16+
517
type distro = [ Distro.distro | `Macos of [ `V12 | `V13 ] ] [@@deriving sexp]
618
(** Supported Docker container distributions without aliases. *)
719

@@ -22,6 +34,10 @@ val opam_repository : os_family -> string
2234
(** [opam_repository os_family] returns the git URL to the default
2335
Opam repository. *)
2436

37+
val personality : os_family -> Ocaml_version.arch -> string option
38+
(** [personality os_family arch] returns the personality associated to
39+
the architecture, if [os_family] is [`Linux]. *)
40+
2541
val is_same_distro : t -> t -> bool
2642
(** [is_same_distro d1 d2] returns whether [d1] is the same distro as
2743
[d2], regardless of their respective versions. *)
@@ -39,6 +55,14 @@ val distros : t list
3955
val latest_distros : t list
4056
(** Enumeration of the latest stable (ideally LTS) supported distributions. *)
4157

58+
val win10_latest_release : win10_release
59+
(** Latest Windows 10 release. *)
60+
61+
val win10_latest_image : win10_release
62+
(** Latest Windows 10 Docker image available. May differ from
63+
{!win10_latest_release} if the Docker repository hasn't been
64+
updated. *)
65+
4266
val master_distro : t
4367
(** The distribution that is the top-level alias for the [latest] tag
4468
in the [ocaml/opam2] Docker Hub build. *)
@@ -84,6 +108,22 @@ val latest_tag_of_distro : t -> string
84108
regularly rewritten to point to any new releases of the
85109
distribution. *)
86110

111+
type win10_docker_base_image = Distro.win10_docker_base_image
112+
(** Windows containers base images.
113+
@see <https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images> *)
114+
115+
val win10_base_tag :
116+
?win10_revision:win10_lcu ->
117+
win10_docker_base_image ->
118+
win_all ->
119+
string * string
120+
(** [win10_base_tag base_image release] will return a tuple of Windows
121+
container base image and tag for which the base image of a Windows
122+
base image can be found (e.g.
123+
[mcr.microsoft.com/windows/servercore],[ltsc2022] which maps to
124+
[mcr.microsoft.com/windows/servercore:ltsc2022] on the Microsoft
125+
Container Registry). *)
126+
87127
val base_distro_tag :
88128
?win10_revision:Distro.win10_lcu ->
89129
?arch:Ocaml_version.arch ->
@@ -96,6 +136,17 @@ val base_distro_tag :
96136
and other OCaml tool Dockerfiles. [arch] defaults to [x86_64] and can vary
97137
the base user/repository since some architecture are built elsewhere. *)
98138

139+
val win10_release_to_string : win10_release -> string
140+
(** [win10_release_to_string update] converts a Windows 10 version name to
141+
string. *)
142+
143+
val win10_release_of_string : string -> win_all option
144+
(** [win10_release_of_string] converts a Windows 10 version name as
145+
string to its internal representation. Ignores any KB number. *)
146+
147+
val win10_revision_to_string : win10_revision -> string
148+
val win10_revision_of_string : string -> win10_revision option
149+
99150
val distro_arches : Ocaml_version.t -> t -> Ocaml_version.arch list
100151
(** [distro_arches ov t] returns the list of architectures that
101152
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
105156
combination of CPU [arch], compiler version [ov] is available
106157
on the distribution [distro]. *)
107158

159+
type win10_release_status = Distro.win10_release_status
160+
(** Windows 10 release status. *)
161+
162+
val win10_release_status : win_all -> win10_release_status
163+
(** [win10_release_status v channel] returns the Microsoft support
164+
status of the specified Windows 10 release.
165+
@see <https://en.wikipedia.org/wiki/Windows_10_version_history#Channels> *)
166+
108167
val active_distros : Ocaml_version.arch -> t list
109168
(** [active_distros arch] returns the list of currently supported
110169
distributions in the opam build infrastructure. Distributions

0 commit comments

Comments
 (0)