Debian Codegraph @

test/Dockerfile.file-quirks

raw
1 # This Dockerfile is used to test that pull deals with quirky files, e.g.
2 # replacement by different types (issues #819 and #825)`. Scope is “skip”
3 # because we pull the image to test it; see test/build/50_pull.bats.
4 #
5 # To build and push:
6 #
7 # $ VERSION=$(date +%Y-%m-%d) # or other date as appropriate
8 # $ sudo docker login # if needed
9 # $ sudo docker build -t file-quirks -f Dockerfile.file-quirks .
10 # $ sudo docker tag file-quirks:latest charliecloud/file-quirks:$VERSION
11 # $ sudo docker images | fgrep file-quirks
12 # $ sudo docker push charliecloud/file-quirks:$VERSION
13 #
14 # ch-test-scope: skip
15
16 FROM alpine:3.17
17 WORKDIR /test
18
19
20 ## Replace symlink with symlink.
21
22 # Set up a symlink & targets.
23 RUN echo target1 > ss_target1 \
24 && echo target2 > ss_target2 \
25 && ln -s ss_target1 ss_link
26 # link and target should both contain “target1”
27 RUN ls -l \
28 && for i in ss_*; do printf '%s : ' $i; cat $i; done
29 # Overwrite it with a new symlink.
30 RUN rm ss_link \
31 && ln -s ss_target2 ss_link
32 # Now link should still be a symlink but contain “target2”.
33 RUN ls -l \
34 && for i in ss_*; do printf '%s : ' $i; cat $i; done
35
36
37 ## Replace symlink with regular file (issue #819).
38
39 # Set up a symlink.
40 RUN echo target > sf_target \
41 && ln -s sf_target sf_link
42 # Link and target should both contain “target”.
43 RUN ls -l \
44 && for i in sf_*; do printf '%s : ' $i; cat $i; done
45 # Overwrite it with a regular file.
46 RUN rm sf_link \
47 && echo regular > sf_link
48 # Now link should be a regular file and contain “regular”.
49 RUN ls -l \
50 && for i in sf_*; do printf '%s : ' $i; cat $i; done
51
52
53 ## Replace regular file with symlink.
54
55 # Set up two regular files.
56 RUN echo regular > fs_link \
57 && echo target > fs_target
58 # Link should be a regular file and contain “regular”.
59 RUN ls -l \
60 && for i in fs_*; do printf '%s : ' $i; cat $i; done
61 # Overwrite it with a symlink.
62 RUN rm fs_link \
63 && ln -s fs_target fs_link
64 # Now link should be a symlink; both should contain “target”.
65 RUN ls -l \
66 && for i in fs_*; do printf '%s : ' $i; cat $i; done
67
68
69 ## Replace symlink with directory.
70
71 # Set up a symlink.
72 RUN echo target > sd_target \
73 && ln -s sd_target sd_link
74 # link and target should both contain “target”.
75 RUN ls -l \
76 && for i in sd_*; do printf '%s : ' $i; cat $i; done
77 # Overwrite it with a directory.
78 RUN rm sd_link \
79 && mkdir sd_link
80 # Now link should be a directory.
81 RUN ls -l
82
83
84 ## Replace directory with symlink.
85
86 # I think this is what’s in image ppc64le.neo4j/2.3.5, as reported in issue
87 # #825, but it doesn’t cause the same infinite recursion.
88
89 # Set up a directory and a target.
90 RUN mkdir ds_link \
91 && echo target > ds_target
92 # It should be a directory.
93 RUN ls -l
94 # Overwrite it with a symlink.
95 RUN rmdir ds_link \
96 && ln -s ds_target ds_link
97 # Now link should be a symlink; both should contain “target”.
98 RUN ls -l \
99 && for i in ds_*; do printf '%s : ' $i; cat $i; done
100
101
102 ## Replace regular file with directory.
103
104 # Set up a file.
105 RUN echo regular > fd_member
106 # It should be a file.
107 RUN ls -l \
108 && for i in fd_*; do printf '%s : ' $i; cat $i; done
109 # Overwrite it with a directory.
110 RUN rm fd_member \
111 && mkdir fd_member
112 # Now it should be a directory.
113 RUN ls -l
114
115
116 ## Replace directory with regular file.
117
118 # Set up a directory.
119 RUN mkdir df_member
120 # It should be a directory.
121 RUN ls -l
122 # Overwrite it with a file.
123 RUN rmdir df_member \
124 && echo regular > df_member
125 # Now it should be a file.
126 RUN ls -l \
127 && for i in df_*; do printf '%s : ' $i; cat $i; done
128
129
130 ## Symlink with cycle (https://bugs.python.org/file37774).
131
132 # Set up a symlink pointing to itself.
133 RUN ln -s link_self link_self
134 # List.
135 RUN ls -l
136
137
138 ## Broken symlinks (https://bugs.python.org/file37774).
139
140 # Set up a symlink pointing to (1) a nonexistent file and (2) a directory that
141 # only exists in the image.
142 RUN ln -s doesnotexist link_b0rken \
143 && ln -s /test link_imageonly
144 # List.
145 RUN ls -l
146
147
148 ## Symlinks with too many up-levels (#2144).
149
150 RUN echo uptarget > uptarget \
151 && ln -s /../test/uptarget /test/uplink-abs1 \
152 && ln -s /../../test/uptarget /test/uplink-abs2 \
153 && ln -s ../../usr/../test/uptarget /test/uplink-over1 \
154 && ln -s ../../test/uptarget /test/uplink-rel1 \
155 && ln -s ../../../test/uptarget /test/uplink-rel2 \
156 && ln -s ../usr/../../test/uptarget /test/uplink-over2 \
157 && ln -s ../test/uptarget /test/uplink-valid1 \
158 && ln -s ../usr/../test/uptarget /test/uplink-valid2
159 RUN ls -l
160
161 ## Symlink pointing to its own containing directory (#2150).
162
163 RUN ln -s . link-dot-rel \
164 && ln -s /test link-dot-abs
165 RUN ls -l