From c8f1d84e40ded7e0c6eba35cb9b57d2508ee5960 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 7 Aug 2024 13:37:51 +0100 Subject: [PATCH 1/2] Add curl to the list of required cygwin packages to avoid issues with Windows' curl --- master_changes.md | 1 + src/client/opamInitDefaults.ml | 1 + 2 files changed, 2 insertions(+) diff --git a/master_changes.md b/master_changes.md index 2a005c0d86f..3d8aff490a8 100644 --- a/master_changes.md +++ b/master_changes.md @@ -17,6 +17,7 @@ users) ## Plugins ## Init + * Add curl to the list of required cygwin packages to avoid issues with Windows' curl [#6142 @kit-ty-kate - fix #6120] ## Config report diff --git a/src/client/opamInitDefaults.ml b/src/client/opamInitDefaults.ml index 6b5a7017fbf..af184a360e4 100644 --- a/src/client/opamInitDefaults.ml +++ b/src/client/opamInitDefaults.ml @@ -154,6 +154,7 @@ let required_packages_for_cygwin = "tar"; "unzip"; "rsync"; + "curl"; ] |> List.map OpamSysPkg.of_string let init_scripts () = [ From 7031fb35c94dcaf4df07a8cb90e6f7f27f8cedae Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 7 Aug 2024 16:28:56 +0100 Subject: [PATCH 2/2] Run Cygwin's setup.exe on Windows when calling opam init --reinit --- src/state/opamSysInteract.ml | 93 +++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/src/state/opamSysInteract.ml b/src/state/opamSysInteract.ml index a3d6f3f9b45..ed37250743f 100644 --- a/src/state/opamSysInteract.ml +++ b/src/state/opamSysInteract.ml @@ -321,50 +321,55 @@ module Cygwin = struct let fstab = cygwin_root / "etc" // "fstab" in let cygcheck = cygwin_bin // cygcheckexe in let local_cygwin_setupexe = cygsetup () in - if OpamFilename.exists cygcheck then - OpamConsole.warning "Cygwin already installed in root %s" - (OpamFilename.Dir.to_string cygwin_root) - else - (* rjbou: dry run ? there is no dry run on install, from where this - function is called *) - (OpamProcess.Job.run @@ - (* download setup.exe *) - download_setupexe local_cygwin_setupexe @@+ fun () -> - (* launch install *) - let args = [ - "--root"; OpamFilename.Dir.to_string cygwin_root; - "--arch"; "x86_64"; - "--only-site"; - "--site"; mirror; - "--local-package-dir"; - OpamFilename.Dir.to_string (internal_cygcache ()); - "--no-admin"; - "--no-desktop"; - "--no-replaceonreboot"; - "--no-shortcuts"; - "--no-startmenu"; - "--no-write-registry"; - "--no-version-check"; - "--quiet-mode"; "noinput"; - ] @ - match packages with - | [] -> [] - | spkgs -> - [ "--packages"; - OpamStd.List.concat_map "," OpamSysPkg.to_string spkgs ] - in - let args = - if Unix.has_symlink () then - "--symlink-type" :: "native" :: args - else - args - in - OpamSystem.make_command - (OpamFilename.to_string local_cygwin_setupexe) - args @@> fun r -> - OpamSystem.raise_on_process_error r; - set_fstab_noacl fstab; - Done ()) + let not_already_installed = + if OpamFilename.exists cygcheck then + (log "Cygwin already installed in root %s" + (OpamFilename.Dir.to_string cygwin_root); + false) + else + true + in + (* rjbou: dry run ? there is no dry run on install, from where this + function is called *) + OpamProcess.Job.run @@ + (* download setup.exe *) + download_setupexe local_cygwin_setupexe @@+ fun () -> + (* launch install *) + let args = [ + "--root"; OpamFilename.Dir.to_string cygwin_root; + "--arch"; "x86_64"; + "--only-site"; + "--site"; mirror; + "--local-package-dir"; + OpamFilename.Dir.to_string (internal_cygcache ()); + "--no-admin"; + "--no-desktop"; + "--no-replaceonreboot"; + "--no-shortcuts"; + "--no-startmenu"; + "--no-write-registry"; + "--no-version-check"; + "--quiet-mode"; "noinput"; + ] @ + match packages with + | [] -> [] + | spkgs -> + [ "--packages"; + OpamStd.List.concat_map "," OpamSysPkg.to_string spkgs ] + in + let args = + if Unix.has_symlink () then + "--symlink-type" :: "native" :: args + else + args + in + OpamSystem.make_command + (OpamFilename.to_string local_cygwin_setupexe) + args @@> fun r -> + OpamSystem.raise_on_process_error r; + if not_already_installed then + set_fstab_noacl fstab; + Done () let analysis_cache = Hashtbl.create 17