3 # Test `imagex update' and `imagex extract'.
7 srcdir="${srcdir:-.}/.."
8 srcdir="$(cd $srcdir; pwd)"
9 . "$srcdir/tests/tests-common.sh"
11 TEST_SUBDIR=tmpdir_test-imagex-update_and_extract
18 echo "--------------------------------------------------------------------"
20 echo "--------------------------------------------------------------------"
24 msg "TEST FAILED (See above)"
32 imagex capture in.dir test.wim --compress=none
37 imagex apply test.wim out.dir
41 cp $srcdir/src/add_image.c file
45 msg "Testing deleting nonexisting file from WIM image, without --force (errors expected)"
46 ! imagex update test.wim << EOF
50 msg "Testing deleting nonexisting file from WIM image, with --force"
51 ! imagex update test.wim << EOF
52 delete --force /nonexistent
55 msg "Testing deleting root directory from WIM image, without --recursive (errors expected)"
56 ! imagex update test.wim << EOF
60 msg "Testing deleting root directory from WIM image, with --recursive"
61 imagex update test.wim << EOF
65 msg "Testing update command with invalid option (errors expected)"
66 ! imagex update test.wim << EOF
67 delete --invalid-option --recursive /
70 msg "Testing update command with too many arguments (errors expected)"
71 ! imagex update test.wim << EOF
72 delete --recursive --force / /anotherdir
75 msg "Testing invalid update command (errors expected)"
76 ! imagex update test.wim << EOF
80 msg "Testing update command file with comments and empty lines"
81 imagex update test.wim << EOF
92 msg "Testing update with --rebuild"
93 imagex update --rebuild test.wim < /dev/null
95 for flag in "" "--rebuild"; do
96 msg "Testing adding file to WIM image with flag \"$flag\""
97 imagex update test.wim $flag << EOF
101 ../tree-cmp file out.dir/file
103 msg "Testing deleting file from WIM image"
104 imagex update test.wim << EOF
108 [ ! -e out.dir/file ]
111 msg "Testing renaming file in WIM image"
112 imagex update test.wim << EOF
115 imagex update test.wim << EOF
119 ../tree-cmp file out.dir/newname && [ ! -e out.dir/file ]
122 msg "Testing adding, then renaming file in WIM image in one command"
123 imagex update test.wim << EOF
125 rename /file /newname
128 ../tree-cmp file out.dir/newname && [ ! -e out.dir/file ]
130 msg "Testing adding additional file to WIM image"
132 imagex update test.wim << EOF
135 imagex update test.wim << EOF
139 [ -e out.dir/1 ] && [ -e out.dir/file ]
141 msg "Testing extracting file from WIM image"
142 rm -rf out.dir && mkdir out.dir
143 imagex extract test.wim 1 /file --dest-dir=out.dir
144 ../tree-cmp file out.dir/file && [ ! -e out.dir/1 ]
146 msg "Testing extracting file from WIM image to stdout"
147 rm -rf out.dir && mkdir out.dir
148 ../../imagex extract test.wim 1 /file --to-stdout > out.dir/file
149 ../tree-cmp file out.dir/file && [ ! -e out.dir/1 ]
151 msg "Testing adding directories and files to WIM image"
152 rm -rf dir1 && mkdir dir1
153 rm -rf dir2 && mkdir dir2
163 imagex update test.wim 1 << EOF
165 add dir2 /prefix/dir2
167 rm -rf out.dir && mkdir out.dir
168 imagex extract test.wim 1 dir1 --dest-dir=out.dir
169 imagex extract test.wim 1 prefix/dir2 --dest-dir=out.dir
170 ../tree-cmp dir1 out.dir/dir1
171 ../tree-cmp dir2 out.dir/dir2
173 msg "Testing adding files to WIM image"
174 rm -rf in.dir && mkdir in.dir
175 imagex append in.dir test.wim "2"
176 cp $srcdir/src/*.c in.dir
177 imagex update test.wim 2 << EOF
183 imagex apply test.wim 2 out.dir
184 ../tree-cmp in.dir out.dir
186 msg "Testing adding file with space in it"
187 echo hello > "Some File"
189 imagex update test.wim 1 << EOF
190 add "Some File" 'Some Destination'
193 imagex apply test.wim 1 out.dir
194 ../tree-cmp "Some File" out.dir/"Some Destination"
196 msg "Testing path list extract"
199 echo otherfile > otherfile
201 imagex update test.wim 1 << EOF
204 add otherfile /otherfile
206 cat > pathlist << EOF
211 imagex extract test.wim 1 @pathlist --dest-dir=out.dir
212 ../tree-cmp hello1 out.dir/hello1
213 ../tree-cmp hello2 out.dir/hello2
214 [ ! -e out.dir/otherfile ]
216 msg "Testing path list extract (w/ wildcard)"
217 cat > pathlist << EOF
221 imagex extract test.wim 1 @pathlist --dest-dir=out.dir
222 ../tree-cmp hello1 out.dir/hello1
223 ../tree-cmp hello2 out.dir/hello2
224 [ ! -e out.dir/otherfile ]
226 cat > pathlist << EOF
230 msg "Testing path list extract (no wildcard, no match; error expected)"
231 ! imagex extract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
233 cat > pathlist << EOF
237 msg "Testing path list extract (wildcard, no match; error expected)"
238 ! imagex extract test.wim 1 @pathlist --dest-dir=out.dir
239 msg "Testing path list extract (wildcard, no match, nullglob; no error expected)"
240 imagex extract test.wim 1 @pathlist --dest-dir=out.dir --nullglob
242 msg "Testing path list extract (w/ wildcard)"
243 cat > pathlist << EOF
247 imagex extract test.wim 1 @pathlist --dest-dir=out.dir
248 ../tree-cmp hello1 out.dir/hello1
249 ../tree-cmp hello2 out.dir/hello2
250 ../tree-cmp otherfile out.dir/otherfile
252 msg "Testing path list extract (subdir files)"
254 imagex update test.wim 1 << EOF
255 add hello1 /topdir/subdir1/hello1
256 add hello2 /topdir/subdir2/hello2
257 add hello1 /topdir/hello1
259 cat > pathlist << EOF
260 /topdir/subdir?/hello*
263 imagex extract test.wim 1 @pathlist --dest-dir=out.dir
264 ../tree-cmp hello1 out.dir/topdir/subdir1/hello1
265 ../tree-cmp hello2 out.dir/topdir/subdir2/hello2
266 [ ! -e out.dir/topdir/hello1 ]
268 msg "Testing case insensitivity"
270 imagex update test.wim 1 << EOF
273 cat > pathlist << EOF
277 ! WIMLIB_IMAGEX_IGNORE_CASE=0 imagex extract test.wim 1 @pathlist --dest-dir=out.dir
278 ! WIMLIB_IMAGEX_IGNORE_CASE=0 imagex extract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
279 WIMLIB_IMAGEX_IGNORE_CASE=1 imagex extract test.wim 1 @pathlist --dest-dir=out.dir
280 WIMLIB_IMAGEX_IGNORE_CASE=1 imagex extract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
281 ../tree-cmp hello1 out.dir/HELLO1
282 [ ! -e out.dir/topdir/hello1 ]
285 echo "**********************************************************"
286 echo " imagex update/extract tests passed "
287 echo "**********************************************************"