diff --git a/src/client/opamMain.ml b/src/client/opamMain.ml index a1efea3e157..75f7ef67d37 100644 --- a/src/client/opamMain.ml +++ b/src/client/opamMain.ml @@ -49,6 +49,7 @@ let global_args = [ "--root" , Arg.String set_root_dir, (Printf.sprintf " Change root path (default is %s)" OpamGlobals.default_opam_dir); "--no-checksums", Arg.Clear OpamGlobals.verify_checksums, " Do not verify checksums on download"; + "--keep-build-dir", Arg.Set OpamGlobals.keep_build_dir, " Keep the build directory"; ] let parse_args fn () = diff --git a/src/client/opamSolution.ml b/src/client/opamSolution.ml index 5593003c85e..ad58dfd5431 100644 --- a/src/client/opamSolution.ml +++ b/src/client/opamSolution.ml @@ -148,7 +148,7 @@ let proceed_to_install t nv = OpamGlobals.exit 2; ) ); - if not !OpamGlobals.debug then + if not (!OpamGlobals.keep_build_dir || !OpamGlobals.debug) then OpamFilename.rmdir build_dir let pinned_path t nv = diff --git a/src/core/opamGlobals.ml b/src/core/opamGlobals.ml index 0e786fe7000..2ade97dac3d 100644 --- a/src/core/opamGlobals.ml +++ b/src/core/opamGlobals.ml @@ -23,6 +23,11 @@ let verbose = ref ( with _ -> false ) +let keep_build_dir = ref ( + try Sys.getenv "OPAMKEEPBUILDDIR" <> "" + with _ -> false +) + let base_packages = ref true let verify_checksums = ref true let yes = ref false