Skip to content

Commit 9ae636e

Browse files
committed
Run Cygwin's setup.exe on Windows when calling opam init --reinit
1 parent 489ddc5 commit 9ae636e

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

src/state/opamSysInteract.ml

+49-44
Original file line numberDiff line numberDiff line change
@@ -321,50 +321,55 @@ module Cygwin = struct
321321
let fstab = cygwin_root / "etc" // "fstab" in
322322
let cygcheck = cygwin_bin // cygcheckexe in
323323
let local_cygwin_setupexe = cygsetup () in
324-
if OpamFilename.exists cygcheck then
325-
OpamConsole.warning "Cygwin already installed in root %s"
326-
(OpamFilename.Dir.to_string cygwin_root)
327-
else
328-
(* rjbou: dry run ? there is no dry run on install, from where this
329-
function is called *)
330-
(OpamProcess.Job.run @@
331-
(* download setup.exe *)
332-
download_setupexe local_cygwin_setupexe @@+ fun () ->
333-
(* launch install *)
334-
let args = [
335-
"--root"; OpamFilename.Dir.to_string cygwin_root;
336-
"--arch"; "x86_64";
337-
"--only-site";
338-
"--site"; mirror;
339-
"--local-package-dir";
340-
OpamFilename.Dir.to_string (internal_cygcache ());
341-
"--no-admin";
342-
"--no-desktop";
343-
"--no-replaceonreboot";
344-
"--no-shortcuts";
345-
"--no-startmenu";
346-
"--no-write-registry";
347-
"--no-version-check";
348-
"--quiet-mode"; "noinput";
349-
] @
350-
match packages with
351-
| [] -> []
352-
| spkgs ->
353-
[ "--packages";
354-
OpamStd.List.concat_map "," OpamSysPkg.to_string spkgs ]
355-
in
356-
let args =
357-
if Unix.has_symlink () then
358-
"--symlink-type" :: "native" :: args
359-
else
360-
args
361-
in
362-
OpamSystem.make_command
363-
(OpamFilename.to_string local_cygwin_setupexe)
364-
args @@> fun r ->
365-
OpamSystem.raise_on_process_error r;
366-
set_fstab_noacl fstab;
367-
Done ())
324+
let not_already_installed =
325+
if OpamFilename.exists cygcheck then
326+
(log "Cygwin already installed in root %s"
327+
(OpamFilename.Dir.to_string cygwin_root);
328+
false)
329+
else
330+
true
331+
in
332+
(* rjbou: dry run ? there is no dry run on install, from where this
333+
function is called *)
334+
OpamProcess.Job.run @@
335+
(* download setup.exe *)
336+
download_setupexe local_cygwin_setupexe @@+ fun () ->
337+
(* launch install *)
338+
let args = [
339+
"--root"; OpamFilename.Dir.to_string cygwin_root;
340+
"--arch"; "x86_64";
341+
"--only-site";
342+
"--site"; mirror;
343+
"--local-package-dir";
344+
OpamFilename.Dir.to_string (internal_cygcache ());
345+
"--no-admin";
346+
"--no-desktop";
347+
"--no-replaceonreboot";
348+
"--no-shortcuts";
349+
"--no-startmenu";
350+
"--no-write-registry";
351+
"--no-version-check";
352+
"--quiet-mode"; "noinput";
353+
] @
354+
match packages with
355+
| [] -> []
356+
| spkgs ->
357+
[ "--packages";
358+
OpamStd.List.concat_map "," OpamSysPkg.to_string spkgs ]
359+
in
360+
let args =
361+
if Unix.has_symlink () then
362+
"--symlink-type" :: "native" :: args
363+
else
364+
args
365+
in
366+
OpamSystem.make_command
367+
(OpamFilename.to_string local_cygwin_setupexe)
368+
args @@> fun r ->
369+
OpamSystem.raise_on_process_error r;
370+
if not_already_installed then
371+
set_fstab_noacl fstab;
372+
Done ()
368373

369374
let analysis_cache = Hashtbl.create 17
370375

0 commit comments

Comments
 (0)