Skip to content

Commit

Permalink
Make --bypass-checks => --no-cygwin-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Jun 7, 2024
1 parent 7c32f92 commit 4697b20
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,14 @@ let cygwin_searches ?first () =
in
seq cygwin_searches

let rec cygwin_menu header =
let rec cygwin_menu ~bypass_checks header =
let string_of_kind = function
| `Msys2 -> "MSYS2"
| `Cygwin -> "Cygwin"
in
let start = Unix.gettimeofday () in
let test_mechanism (roots, count, mechanisms) search =
match test_mechanism header search with
match test_mechanism ~bypass_checks header search with
| Some ((kind, `Root root) as mechanism) ->
if OpamFilename.Dir.Set.mem root roots then
roots, count, mechanisms
Expand Down Expand Up @@ -1068,6 +1068,9 @@ let rec cygwin_menu header =
"Use tools found in PATH (%s installation at %s)"
(string_of_kind kind) root)::options
in
if bypass_checks then
options, path_option, None
else
(* Check whether cygcheck is still available in the initial environment.
This allows a warning to be displayed reminding the user to continue
running opam from a Cygwin/MSYS2 shell that has been manually started,
Expand Down Expand Up @@ -1167,11 +1170,11 @@ let rec cygwin_menu header =
Some (kind, `Root root)
| Error msg ->
OpamConsole.error "%s" msg;
cygwin_menu header
cygwin_menu ~bypass_checks header
end
| `Abort -> OpamStd.Sys.exit_because `Aborted

and test_mechanism header = function
and test_mechanism ~bypass_checks header = function
| (`Internal _) as mechanism -> Some (`Cygwin, mechanism)
| `Path ->
let cygcheck =
Expand All @@ -1195,7 +1198,7 @@ and test_mechanism header = function
| Error msg ->
OpamConsole.error_and_exit `Not_found "%s" msg
end
| `Menu -> cygwin_menu header
| `Menu -> cygwin_menu ~bypass_checks header

let string_of_cygwin_setup = function
| `internal pkgs ->
Expand Down Expand Up @@ -1257,7 +1260,8 @@ let initialise_msys2 root =
| `Quit ->
OpamStd.Sys.exit_because `Aborted

let determine_windows_configuration ?cygwin_setup ?git_location config =
let determine_windows_configuration ?cygwin_setup ?git_location
~bypass_checks config =
OpamStd.Option.iter
(log "Cygwin (from CLI): %a" (slog string_of_cygwin_setup)) cygwin_setup;
(* Check whether symlinks can be created. Developer Mode is not the only way
Expand Down Expand Up @@ -1361,6 +1365,13 @@ let determine_windows_configuration ?cygwin_setup ?git_location config =
tweakable - can pacman / Cygwin setup be used to adjust setup
(--no-cygwin-setup disables this)
*)
(* --bypass-checks => --no-cygwin-setup if nothing else was specified *)
let cygwin_setup =
if bypass_checks && cygwin_setup = None then
Some `no
else
cygwin_setup
in
let mechanisms, cygwin_tweakable =
match cygwin_setup with
| Some (`internal packages) ->
Expand Down Expand Up @@ -1389,7 +1400,8 @@ let determine_windows_configuration ?cygwin_setup ?git_location config =
(* Reduce mechanisms to a single mechanism (which may therefore display a
menu). *)
let kind, mechanism =
match OpamCompat.Seq.find_map (test_mechanism header) mechanisms with
let test_mechanism = test_mechanism ~bypass_checks header in
match OpamCompat.Seq.find_map test_mechanism mechanisms with
| Some result -> result
| None ->
Lazy.force header;
Expand Down Expand Up @@ -1586,7 +1598,8 @@ let reinit ?(init_config=OpamInitDefaults.init_config()) ~interactive
let config = update_with_init_config config init_config in
let config, mechanism, system_packages, msys2_check_root =
if Sys.win32 then
determine_windows_configuration ?cygwin_setup ?git_location config
determine_windows_configuration ?cygwin_setup ?git_location
~bypass_checks config
else
config, None, [], None
in
Expand Down Expand Up @@ -1673,7 +1686,8 @@ let init
in
let config, mechanism, system_packages, msys2_check_root =
if Sys.win32 then
determine_windows_configuration ?cygwin_setup ?git_location config
determine_windows_configuration ?cygwin_setup ?git_location
~bypass_checks config
else
config, None, [], None
in
Expand Down

0 comments on commit 4697b20

Please sign in to comment.