Debian Codegraph @

test/blackbox-tests/test-cases/pkg/install-symlinks/symlink-outside-target.t

raw
1 Test symlinks pointing to files outside the target directory.
2
3 CR-someday Alizter: This behavior is questionable. We convert the symlink to a
4 hardlink pointing to an external file, which ties the build output to external
5 content. If the external file changes, the target would be stale. Consider
6 whether we should leave such symlinks as-is, copy the file, or error instead.
7
8 $ export DUNE_CACHE=enabled
9 $ export DUNE_CACHE_ROOT=$PWD/_cache
10
11 $ make_lockdir
12 $ mkdir outside_dir
13 $ echo 'outside content' > outside_dir/external_file.txt
14
15 Create a package with a symlink pointing outside target:
16
17 $ make_lockpkg foo <<EOF
18 > (version 0.0.1)
19 > (build
20 > (system "\
21 > true BUILDING_FOO_PACKAGE \
22 > && mkdir -p %{lib}/%{pkg-self:name} \
23 > && ln -s $PWD/outside_dir/external_file.txt %{lib}/%{pkg-self:name}/external.txt \
24 > && touch %{lib}/%{pkg-self:name}/META"))
25 > EOF
26
27 $ cat > dune-project <<EOF
28 > (lang dune 3.22)
29 > (package
30 > (name x)
31 > (allow_empty)
32 > (depends foo))
33 > EOF
34
35 $ build_pkg foo
36
37 $ count_trace BUILDING_FOO_PACKAGE
38 1
39
40 The symlink is resolved to a hardlink to the external file:
41
42 $ dune_cmd stat kind $(get_build_pkg_dir foo)/target/lib/foo/external.txt
43 regular file
44
45 The content is accessible:
46
47 $ cat $(get_build_pkg_dir foo)/target/lib/foo/external.txt
48 outside content
49
50 Since the symlink was resolved to a hardlink, caching works:
51
52 $ rm -rf _build
53 $ build_pkg foo
54 $ count_trace BUILDING_FOO_PACKAGE
55 0