Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/9282.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Copying mode for sandboxes will now follow symbolic links (#9282, @rgrinberg)
8 changes: 8 additions & 0 deletions src/dune_engine/sandbox.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Item = struct
type t =
| File
| Directory of { perms : int }
| Link
| Other of Unix.file_kind

let of_path path =
Expand All @@ -59,6 +60,7 @@ module Item = struct
match kind with
| S_DIR -> Directory { perms = (Path.Untracked.stat_exn path).st_perm }
| S_REG -> File
| S_LNK -> Link
| _ -> Other kind
;;
end
Expand All @@ -71,6 +73,12 @@ let copy_recursively =
in
let rec loop item ~src ~dst =
match (item : Item.t) with
| Link ->
(match Path.Untracked.stat_exn src with
| { Unix.st_kind = S_REG; _ } -> Io.copy_file ~chmod:chmod_file ~src ~dst ()
| { Unix.st_kind = S_DIR; st_perm = perms; _ } ->
loop (Directory { perms }) ~src ~dst
| { Unix.st_kind; _ } -> loop (Other st_kind) ~src ~dst)
| File -> Io.copy_file ~chmod:chmod_file ~src ~dst ()
| Directory { perms } ->
(match Path.Untracked.readdir_unsorted_with_kinds src with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,7 @@ Now we demonstrate that symlinks aren't supported:
> }

$ runtest "touch foo && ln -s foo bar"
File "dune", line 1, characters 0-63:
1 | (rule
2 | (alias foo)
3 | (action (echo test))
4 | (deps sub/targetdir))
Error: Failed to copy file _build/default/sub/targetdir/bar of kind "symbolic
link" while creating a copy sandbox
Hint: Re-run Dune to delete the stale artifact, or manually delete this file
[1]
test

$ runtest "mkdir bar && touch bar/somefileinbar && ln -s bar symlinktobar"
File "sub/dune", line 1, characters 0-151:
Expand Down