Skip to content

Commit

Permalink
Remove files before installing them. (#2885)
Browse files Browse the repository at this point in the history
Remove files before installing them.

This should avoid a failure with "file busy" if for example an
installed binary is running, as described in Issue #2883.

Signed-off-by: Bernhard Schommer <[email protected]>
  • Loading branch information
bschommer authored and rgrinberg committed Nov 14, 2019
1 parent f9f8960 commit b3eb89f
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
2.0.0 (unreleased)
------------------

- Remove existing destination files in `install` before installing the new
ones. (#2885, fixes #2883, @bschommer)

- The `action` field in the `alias` stanza is not available starting `lang dune
2.0`. The `alias` field in the `rule` stanza is a replacement. (#2846, fixes
2681, @rgrinberg)
Expand Down
1 change: 1 addition & 0 deletions bin/install_uninstall.ml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ let install_uninstall ~what =
in
let dir = Path.parent_exn dst in
if what = "install" then (
Ops.remove_if_exists dst;
Printf.eprintf "Installing %s\n%!"
(Path.to_string_maybe_quoted dst);
Ops.mkdir_p dir;
Expand Down
11 changes: 11 additions & 0 deletions test/blackbox-tests/test-cases/install-dry-run/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,37 @@
Installing OPAM_PREFIX/lib/mylib/mylib.cmxs
Installing OPAM_PREFIX/lib/mylib/mylib.ml
Installing OPAM_PREFIX/lib/mylib/opam
Removing (if it exists) OPAM_PREFIX/lib/mylib/META
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/META to OPAM_PREFIX/lib/mylib/META (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/dune-package
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/dune-package to OPAM_PREFIX/lib/mylib/dune-package (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib$ext_lib
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib$ext_lib to OPAM_PREFIX/lib/mylib/mylib$ext_lib (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.cma
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.cma to OPAM_PREFIX/lib/mylib/mylib.cma (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.cmi
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.cmi to OPAM_PREFIX/lib/mylib/mylib.cmi (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.cmt
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.cmt to OPAM_PREFIX/lib/mylib/mylib.cmt (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.cmx
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.cmx to OPAM_PREFIX/lib/mylib/mylib.cmx (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.cmxa
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.cmxa to OPAM_PREFIX/lib/mylib/mylib.cmxa (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.cmxs
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.cmxs to OPAM_PREFIX/lib/mylib/mylib.cmxs (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/mylib.ml
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/mylib.ml to OPAM_PREFIX/lib/mylib/mylib.ml (executable: false)
Removing (if it exists) OPAM_PREFIX/lib/mylib/opam
Creating directory OPAM_PREFIX/lib/mylib
Copying _build/install/default/lib/mylib/opam to OPAM_PREFIX/lib/mylib/opam (executable: false)

Expand Down
Loading

0 comments on commit b3eb89f

Please sign in to comment.