@@ -355,6 +355,11 @@ let copy_opams_windows opam_branches =
355355 aliases)
356356 empty opam_branches
357357
358+ (* Make native opam-2.2 the default opam.
359+ We no longer install fdopen's opam - native opam 2.2+ supports Windows directly. *)
360+ let setup_default_opam_windows =
361+ run {| copy C :\cygwin64\usr\local\bin\opam-2.2 .exe C :\cygwin64\bin\opam.exe| }
362+
358363(* Apk based Dockerfile *)
359364let apk_opam2 ?(labels = [] ) ?arch ~opam_hashes distro () =
360365 let opam_master_hash, opam_branches = create_opam_branches opam_hashes in
@@ -520,12 +525,13 @@ let windows_mingw_opam2 ?(labels = []) ~override_tag ~opam_hashes (distro : D.t)
520525 in
521526 (* 2022-10-12: Docker Engine 20.10.18 on Windows fails copying
522527 C:\cygwin64, so we cannot build Cygwin in a separate image. *)
523- let ocaml_for_windows =
524- let packages, setup = Windows.Cygwin. install_ocaml_for_windows () in
528+ (* We use native opam 2.2+ instead of fdopen's opam, but still need the
529+ Cygwin packages that install_ocaml_for_windows would provide. *)
530+ let cygwin_setup =
531+ let packages, _fdopen_opam_setup = Windows.Cygwin. install_ocaml_for_windows () in
525532 let packages = Windows.Cygwin. mingw_packages @ packages in
526533 Windows.Cygwin. install_cygwin ~aslr_off: (aslr_state distro) ~extra: packages
527534 ()
528- @@ setup
529535 in
530536 parser_directive (`Escape '`' )
531537 @@ comment " Autogenerated by OCaml-Dockerfile scripts"
@@ -534,8 +540,9 @@ let windows_mingw_opam2 ?(labels = []) ~override_tag ~opam_hashes (distro : D.t)
534540 @@ label ((" distro_style" , " windows" ) :: labels)
535541 @@ user " ContainerAdministrator"
536542 @@ Windows. sanitize_reg_path ()
537- @@ winget_setup @@ ocaml_for_windows
543+ @@ winget_setup @@ cygwin_setup
538544 @@ copy_opams_windows opam_branches
545+ @@ setup_default_opam_windows
539546 @@ Windows.Cygwin. setup () @@ Windows.Cygwin.Git. init ()
540547
541548(* Native Windows with MSVC and WinGet. *)
@@ -567,18 +574,21 @@ let windows_msvc_opam2 ?(labels = []) ~override_tag ~opam_hashes (distro : D.t)
567574 in
568575 (* 2022-10-12: Docker Engine 20.10.18 on Windows fails copying
569576 C:\cygwin64, so we cannot build Cygwin in a separate image. *)
570- let ocaml_for_windows =
571- let packages, setup = Windows.Cygwin. install_ocaml_for_windows () in
572- Windows.Cygwin. install packages @@ setup
577+ (* We use native opam 2.2+ instead of fdopen's opam, but still need the
578+ Cygwin packages that install_ocaml_for_windows would provide. *)
579+ let cygwin_packages =
580+ let packages, _fdopen_opam_setup = Windows.Cygwin. install_ocaml_for_windows () in
581+ Windows.Cygwin. install packages
573582 in
574583 parser_directive (`Escape '`' )
575584 @@ comment " Autogenerated by OCaml-Dockerfile scripts"
576585 @@ winget_image @@ cygwin_msvc_image @@ opams_image
577586 @@ Dockerfile. from " cygwin-msvc"
578587 @@ label ((" distro_style" , " windows" ) :: labels)
579588 @@ user " ContainerAdministrator"
580- @@ ocaml_for_windows @@ winget_setup
589+ @@ cygwin_packages @@ winget_setup
581590 @@ copy_opams_windows opam_branches
591+ @@ setup_default_opam_windows
582592 @@ Windows.Cygwin. setup () @@ Windows.Cygwin.Git. init ()
583593
584594let gen_opam2_distro ?override_tag ?(clone_opam_repo = true ) ?arch ?labels
0 commit comments