1 # Process this file with autom4te to create testsuite. -*- Autotest -*-
3 # Test suite for GNU tar.
4 # Copyright 2017-2024 Free Software Foundation, Inc.
6 # This file is part of GNU tar.
8 # GNU tar is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU tar is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 AT_SETUP([keep-directory-symlink])
22 AT_KEYWORDS([extrac20 extract old-files keep-old-files])
30 mkdir -p $dir/root/dir $dir/root/dirsymlink
31 touch $dir/root/dirsymlink/file$i
32 test $i != a && touch $dir/root/dirsymlink/file.conflict
33 tar cf archive$i.tar -C $dir root
42 mkdir -p $dir/root/dir
43 ln -s dir $dir/root/dirsymlink
44 test $round = normal && cd $dir >/dev/null
49 test $round = normal && cd .. >/dev/null
54 # Expand to '-f ../$1' or '-f $1 -C $dir' depending on $round variable
57 if test $round = normal
65 for round in normal dir
67 # Check that 'dirsymlink' replaces 'dir'
68 prep without_option_$round
69 tar -x `file_spec archivea.tar` || exit 1
70 tar -x `file_spec archiveb.tar` || exit 1
73 # Keep directory symlink must keep root/dirsymlink
74 prep with_option_$round
75 tar -x --keep-directory-symlink `file_spec archivea.tar` || exit 1
76 tar -x --keep-directory-symlink `file_spec archiveb.tar` || exit 1
80 tar -x --keep-directory-symlink `file_spec archivea.tar` --keep-old-files || exit 1
81 tar -x --keep-directory-symlink `file_spec archiveb.tar` --keep-old-files || exit 1
82 tar -x --keep-directory-symlink `file_spec archivec.tar` --keep-old-files && exit 1
87 [== without_option_normal ==
92 out/root/dirsymlink/file.conflict
93 out/root/dirsymlink/filea
94 out/root/dirsymlink/fileb
95 == with_option_normal ==
99 out/root/dir/file.conflict
103 == collision_normal ==
107 out/root/dir/file.conflict
112 == without_option_dir ==
117 out/root/dirsymlink/file.conflict
118 out/root/dirsymlink/filea
119 out/root/dirsymlink/fileb
120 == with_option_dir ==
124 out/root/dir/file.conflict
132 out/root/dir/file.conflict
138 [== without_option_normal ==
139 == with_option_normal ==
140 == collision_normal ==
141 tar: root/dirsymlink/file.conflict: Cannot open: File exists
142 tar: Exiting with failure status due to previous errors
143 == without_option_dir ==
144 == with_option_dir ==
146 tar: root/dirsymlink/file.conflict: Cannot open: File exists
147 tar: Exiting with failure status due to previous errors