Debian Codegraph @

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

raw
1 Test behavior with directory symlinks.
2
3 $ make_lockdir
4
5 --------------------------------------------------------------------------------
6
7 Case 1: No .install file, directory symlink in %{lib}, engine rejects it.
8
9 $ make_lockpkg foo <<EOF
10 > (version 0.0.1)
11 > (build
12 > (system "\
13 > mkdir -p %{lib}/%{pkg-self:name} \
14 > && printf 'content\n' > %{lib}/%{pkg-self:name}/file.txt \
15 > && mkdir -p %{lib}/%{pkg-self:name}/real_subdir \
16 > && ln -s real_subdir %{lib}/%{pkg-self:name}/subdir_link \
17 > && touch %{lib}/%{pkg-self:name}/META"))
18 > EOF
19
20 CR-someday Alizter: Maybe in this case it actually makes sense to resolve the directory symlink somehow.
21
22 $ build_pkg foo 2>&1 | sanitize_pkg_digest foo.0.0.1
23 Error: Error trying to read targets after a rule was run:
24 - default/.pkg/foo.0.0.1-DIGEST_HASH/target/lib/foo/subdir_link: Unexpected file kind "S_DIR" (directory)
25 -> required by
26 _build/_private/default/.pkg/foo.0.0.1-DIGEST_HASH/target
27 [1]
28
29 --------------------------------------------------------------------------------
30
31 Case 2: .install file explicitly includes directory symlink.
32
33 CR-someday Alizter: What should happen in this case? Seems we didn't catch the
34 error correctly. Engine bug? Let's try to repro later.
35
36 $ make_lockpkg foo <<EOF
37 > (version 0.0.1)
38 > (build
39 > (system "\
40 > mkdir -p real_subdir \
41 > && printf 'content\n' > real_subdir/file.txt \
42 > && ln -s real_subdir subdir_link \
43 > && printf 'lib: [\"real_subdir/file.txt\" \"subdir_link\"]\n' > foo.install"))
44 > EOF
45
46 $ build_pkg foo 2>&1 | sanitize_pkg_digest foo.0.0.1 | sed -E 's#\.sandbox/[^/]+#.sandbox/SANDBOX#g'
47 Error:
48 link(_build/.sandbox/SANDBOX/_private/default/.pkg/foo.0.0.1-DIGEST_HASH/target/lib/foo/subdir_link): Operation not permitted
49 -> required by
50 _build/_private/default/.pkg/foo.0.0.1-DIGEST_HASH/target
51 [1]
52
53 --------------------------------------------------------------------------------
54
55 Case 3: .install file excludes the directory symlink.
56
57 $ make_lockpkg foo <<EOF
58 > (version 0.0.1)
59 > (build
60 > (system "\
61 > mkdir -p real_subdir \
62 > && printf 'content\n' > real_subdir/file.txt \
63 > && ln -s file.txt real_subdir/link.txt \
64 > && ln -s real_subdir subdir_link \
65 > && printf 'lib: [\"real_subdir/file.txt\" \"real_subdir/link.txt\"]\n' > foo.install"))
66 > EOF
67
68 $ build_pkg foo
69
70 The directory symlink is not in the installed targets, so the engine does not
71 reject it. Only the real directory contents are installed:
72
73 $ ls $(get_build_pkg_dir foo)/target/lib/foo
74 file.txt
75 link.txt
76
77 The file symlink is converted to a hardlink:
78
79 $ dune_cmd stat kind $(get_build_pkg_dir foo)/target/lib/foo/link.txt
80 regular file
81
82 $ dune_cmd stat hardlinks $(get_build_pkg_dir foo)/target/lib/foo/link.txt
83 2