Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions src-opam/dockerfile_distro.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ let distro_arches ov (d:t) =
| `Alpine (`V3_6 | `V3_7 | `V3_8 | `V3_9 | `V3_10 | `V3_11 | `V3_12 | `V3_13), ov when OV.(compare Releases.v4_05_0 ov) = -1 -> [ `X86_64; `Aarch64 ]
| `Ubuntu (`V18_04|`V20_04|`V20_10|`V21_04), ov when OV.(compare Releases.v4_05_0 ov) = -1 -> [ `X86_64; `Aarch64; `Ppc64le ]
| `Fedora (`V33|`V34), ov when OV.(compare Releases.v4_08_0 ov) = -1 -> [ `X86_64; `Aarch64 ]
(* 2021-04-19: should be 4.03 but there's a linking failure until 4.06. *)
| `Windows (`Msvc, _), ov when OV.(compare Releases.v4_06_0 ov) = 1 -> []
| _ -> [ `X86_64 ]


Expand Down
16 changes: 6 additions & 10 deletions src-opam/dockerfile_opam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ let pacman_opam2 ?(labels=[]) ?arch ~hash_opam_2_0 ~hash_opam_master distro () =
(* Cygwin based Dockerfile *)
let cygwin_opam2 ?(labels=[]) ?arch ~hash_opam_2_0 ~hash_opam_master distro () =
let img, tag = D.base_distro_tag ?arch distro in
let cyg = Windows.Cygwin.{ default with args = "--allow-test-packages" :: default.args } in
header ?arch distro @@ label (("distro_style", "cygwin") :: labels)
@@ user "ContainerAdministrator"
@@ Windows.Cygwin.(let extra, t = cygwin_packages () in setup ~extra () @@ t)
@@ Windows.Cygwin.(setup ~cyg ~extra:(cygwin_packages ()) ())
@@ Windows.Cygwin.Git.init ()
@@ install_opam_from_source_cygwin ~add_default_link:false ~branch:"2.0" ~hash:hash_opam_2_0 ()
@@ install_opam_from_source_cygwin ~add_default_link:false ~enable_0install_solver:true ~branch:"master" ~hash:hash_opam_master ()
Expand All @@ -238,19 +239,14 @@ let cygwin_opam2 ?(labels=[]) ?arch ~hash_opam_2_0 ~hash_opam_master distro () =
@@ copy ~from:"0" ~src:["/usr/local/bin/opam-2.0"] ~dst:"/usr/bin/opam-2.0" ()
@@ copy ~from:"0" ~src:["/usr/local/bin/opam-master"] ~dst:"/usr/bin/opam-2.1" ()
@@ run "ln /usr/bin/opam-2.0 /usr/bin/opam"
@@ Windows.Cygwin.(let extra, t = cygwin_packages () in setup ~extra () @@ t)
@@ Windows.Cygwin.(setup ~cyg ~extra:(cygwin_packages ()) ())
@@ Windows.Cygwin.Git.init ()

(* TODO: Compile opam-2.0 and 2.1 instead of downloading binaries,
add an option to enable 0install-solver,
and pass ~hash_opam_2_0 ~hash_opam_master like the cygwin one *)
(* Native Windows, WinGet, Cygwin based Dockerfiles *)
let windows_opam2 ?winget ?(labels=[]) ?arch distro () =
(* GNU Linker 2.36 may be breaking OCaml *)
let cyg = { Windows.Cygwin.default with
site = "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2021/04/09/072945";
args = Windows.Cygwin.default.args @ ["-X"] }
in
let version = match distro with `Windows (_, v) -> v | _ -> assert false in
(match winget with
| None -> Windows.Winget.install_from_release ~version ()
Expand All @@ -268,13 +264,13 @@ let windows_opam2 ?winget ?(labels=[]) ?arch distro () =
"Microsoft.VisualStudio.Component.Windows10SDK.18362"]
| _ -> invalid_arg "Invalid distribution"
in
let extra, t' = Windows.Cygwin.ocaml_for_windows_packages ~cyg ~extra () in
let extra, t' = Windows.Cygwin.ocaml_for_windows_packages ~extra () in
Windows.install_vc_redist () @@ t
@@ Windows.Cygwin.setup ~cyg ~extra ~winsymlinks_native:true () @@ t'
@@ Windows.Cygwin.setup ~extra () @@ t'
end
@@ Windows.Winget.setup ?from:winget ()
@@ Windows.Winget.dev_packages ~version ()
@@ Windows.Cygwin.Git.init ~cyg ()
@@ Windows.Cygwin.Git.init ()
@@ Windows.cleanup ()

let gen_opam2_distro ?winget ?(clone_opam_repo=true) ?arch ?labels ~hash_opam_2_0 ~hash_opam_master d =
Expand Down
41 changes: 21 additions & 20 deletions src-opam/dockerfile_windows.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module Cygwin = struct
let install ?(cyg=default) fmt =
ksprintf (cygwin ~cyg "--packages %s") fmt

let setup ?(cyg=default) ?(winsymlinks_native=false) ?(extra=[]) () =
let setup ?(cyg=default) ?(winsymlinks_native=true) ?(extra=[]) () =
(if winsymlinks_native then env [("CYGWIN", "winsymlinks:native")] else empty)
@@ add ~src:["https://www.cygwin.com/setup-x86_64.exe"] ~dst:{|C:\cygwin-setup-x86_64.exe|} ()
@@ install_cygsympathy_from_source cyg
Expand All @@ -124,19 +124,15 @@ module Cygwin = struct
let update ?(cyg=default) () =
run {|%s %s --root %s --site %s --upgrade-also|} cygsetup (String.concat " " cyg.args) cyg.root cyg.site

let cygwin_packages ?(cyg=default) ?(extra=[]) ?(flexdll_version="0.39-1") () =
let packages = "make" :: "diffutils" :: "ocaml" :: "gcc-core" :: "git"
:: "patch" :: "m4" :: "cygport" :: extra in
let t =
(* 2021-03-19: flexdll 0.39 is required, but is in Cygwin testing *)
add ~src:["http://mirrors.kernel.org/sourceware/cygwin/x86_64/release/flexdll/flexdll-" ^ flexdll_version ^ ".tar.xz"]
~dst:(cyg.root ^ {|\flexdll.tar.xz|}) ()
@@ run_sh ~cyg "cd / && tar -xJf flexdll.tar.xz && rm flexdll.tar.xz"
in
packages, t
let cygwin_packages ?(extra=[]) ?(flexdll_version="0.39-1") () =
(* 2021-03-19: flexdll 0.39 is required, but is in Cygwin testing *)
"make" :: "diffutils" :: "ocaml" :: "gcc-core" :: "git" :: "patch" :: "m4"
:: "cygport" :: ("flexdll="^flexdll_version) :: extra

let mingw_packages ?(extra=[]) () = "make" :: "diffutils" :: "mingw64-x86_64-gcc-core" :: extra
let msvc_packages ?(extra=[]) () = "make" :: "diffutils" :: extra
(* GNU ld (found in binutils) 2.36 broke OCaml. Stay with 2.35 until
a fix is available in OCaml. *)
let mingw_packages ?(extra=[]) () = "mingw64-x86_64-binutils=2.35.2-1" :: "make" :: "diffutils" :: "mingw64-x86_64-gcc-core" :: extra
let msvc_packages ?(extra=[]) () = "mingw64-x86_64-binutils=2.35.2-1" :: "make" :: "diffutils" :: extra

let ocaml_for_windows_packages ?cyg ?(extra=[]) ?(version="0.0.0.2") () =
let packages = "make" :: "diffutils" :: "mingw64-x86_64-gcc-g++" :: "vim" :: "git"
Expand All @@ -156,7 +152,6 @@ end

module Winget = struct
let winget = "winget-builder"
let winget_version = "v-0.2.10771-preview"

let header ?(version=`V20H2) () =
let tag = match version with
Expand All @@ -167,7 +162,7 @@ module Winget = struct
| `V20H2 -> "20H2"
in
parser_directive (`Escape '`')
@@ from ~alias:winget ~tag "mcr.microsoft.com/windows/servercore"
@@ from ~alias:winget ~tag "mcr.microsoft.com/windows"
@@ user "ContainerAdministrator"

let footer path =
Expand All @@ -176,7 +171,7 @@ module Winget = struct
@@ run {|move "C:\TEMP\winget-cli\%s\resources.pri" "C:\Program Files\winget-cli\"|} path
|> crunch

let build_from_source ?(arch=`X86_64) ?version ?(winget_version=winget_version) ?(vs_version="16") () =
let build_from_source ?(arch=`X86_64) ?version ?(winget_version="master") ?(vs_version="16") () =
header ?version ()
@@ install_vc_redist ~vs_version ()
@@ install_visual_studio_build_tools ~vs_version [
Expand All @@ -195,11 +190,17 @@ module Winget = struct
@@ run_vc ~arch {|cd C:\TEMP\winget-cli && msbuild -p:Configuration=Release src\AppInstallerCLI.sln|}
@@ footer {|src\x64\Release\AppInstallerCLI|}

let install_from_release ?version ?(winget_version=winget_version) () =
let dst = {|C:\TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.zip|} in
let install_from_release ?version ?winget_version () =
let file = "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe." in
let src =
let src = "https://github.com/microsoft/winget-cli/releases/" in
match winget_version with
| None -> src ^ "latest/download/" ^ file ^ "appxbundle"
| Some ver -> src ^ "download/" ^ ver ^ "/" ^ file ^ "appxbundle"
in
let dst = {|C:\TEMP\|} ^ file ^ "zip" in
header ?version ()
@@ add ~src:["https://github.com/microsoft/winget-cli/releases/download/" ^ winget_version ^ "/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle"]
~dst ()
@@ add ~src:[src] ~dst ()
@@ run_powershell {|Expand-Archive -LiteralPath %s -DestinationPath C:\TEMP\winget-cli -Force|} dst
@@ run {|ren C:\TEMP\winget-cli\AppInstaller_x64.appx AppInstaller_x64.zip|}
@@ run_powershell {|Expand-Archive -LiteralPath C:\TEMP\winget-cli\AppInstaller_x64.zip -DestinationPath C:\TEMP\winget-cli\ -Force|}
Expand Down
14 changes: 8 additions & 6 deletions src-opam/dockerfile_windows.mli
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ module Cygwin : sig
(** The default Cygwin root, mirror, and arguments. *)

val setup : ?cyg:cyg -> ?winsymlinks_native:bool -> ?extra:string list -> unit -> t
(** Setup Cygwin with CygSymPathy and msvs-tools, and [extra]
Cygwin packages.
(** Setup Cygwin with CygSymPathy and msvs-tools, and [extra] Cygwin
packages. Sets the [CYGWIN=winsymlinks:native] environment
variable by default.
@see <https://github.com/metastack/cygsympathy>
@see <https://github.com/metastack/msvs-tools> *)

Expand All @@ -76,8 +77,8 @@ module Cygwin : sig
val update : ?cyg:cyg -> unit -> t
(** Update Cygwin packages. *)

val cygwin_packages : ?cyg:cyg -> ?extra:string list ->
?flexdll_version:string -> unit -> string list * t
val cygwin_packages : ?extra:string list -> ?flexdll_version:string -> unit
-> string list
(** [cygwin_packages ?extra ()] will install the base development
tools for the OCaml Cygwin port. Extra packages may also bep
Comment thread
avsm marked this conversation as resolved.
Outdated
optionally supplied via [extra]. *)
Expand Down Expand Up @@ -120,12 +121,13 @@ module Winget : sig
val build_from_source :
?arch:Ocaml_version.arch -> ?version:[ `V1809 | `V1903 | `V1909 | `V2004 | `V20H2 ] ->
?winget_version:string -> ?vs_version:string -> unit -> t
(** Build winget from source (in a separate Docker image). *)
(** Build winget from source (in a separate Docker image). The
optional [winget_version] specifies a Git reference. *)

val install_from_release :
?version:[ `V1809 | `V1903 | `V1909 | `V2004 | `V20H2 ] -> ?winget_version:string -> unit -> t
(** Install winget from a released build (first in a separate Docker
image). *)
image). The optional [winget_version] specifies a Git tag. *)

val setup : ?from:string -> unit -> t
(** Setup winget, copied from the [from] Docker image. Disable
Expand Down