4
0

extrac20.at 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. #
  3. # Test suite for GNU tar.
  4. # Copyright 2017-2023 Free Software Foundation, Inc.
  5. # This file is part of GNU tar.
  6. # GNU tar is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. # GNU tar is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. AT_SETUP([keep-directory-symlink])
  17. AT_KEYWORDS([extrac20 extract old-files keep-old-files])
  18. AT_TAR_CHECK([
  19. AT_SORT_PREREQ
  20. for i in a b c
  21. do
  22. dir=in$i
  23. mkdir -p $dir/root/dir $dir/root/dirsymlink
  24. touch $dir/root/dirsymlink/file$i
  25. test $i != a && touch $dir/root/dirsymlink/file.conflict
  26. tar cf archive$i.tar -C $dir root
  27. done
  28. prep()
  29. {
  30. echo "== $1 =="
  31. echo "== $1 ==" >&2
  32. backup_dir=$1
  33. dir=out
  34. mkdir -p $dir/root/dir
  35. ln -s dir $dir/root/dirsymlink
  36. test $round = normal && cd $dir >/dev/null
  37. }
  38. clean()
  39. {
  40. test $round = normal && cd .. >/dev/null
  41. find $dir | sort
  42. mv $dir $backup_dir
  43. }
  44. # Expand to '-f ../$1' or '-f $1 -C $dir' depending on $round variable
  45. file_spec()
  46. {
  47. if test $round = normal
  48. then
  49. echo "-f ../$1"
  50. else
  51. echo "-f $1 -C $dir"
  52. fi
  53. }
  54. for round in normal dir
  55. do
  56. # Check that 'dirsymlink' replaces 'dir'
  57. prep without_option_$round
  58. tar -x `file_spec archivea.tar` || exit 1
  59. tar -x `file_spec archiveb.tar` || exit 1
  60. clean
  61. # Keep directory symlink must keep root/dirsymlink
  62. prep with_option_$round
  63. tar -x --keep-directory-symlink `file_spec archivea.tar` || exit 1
  64. tar -x --keep-directory-symlink `file_spec archiveb.tar` || exit 1
  65. clean
  66. prep collision_$round
  67. tar -x --keep-directory-symlink `file_spec archivea.tar` --keep-old-files || exit 1
  68. tar -x --keep-directory-symlink `file_spec archiveb.tar` --keep-old-files || exit 1
  69. tar -x --keep-directory-symlink `file_spec archivec.tar` --keep-old-files && exit 1
  70. clean
  71. done
  72. ],
  73. [0],
  74. [== without_option_normal ==
  75. out
  76. out/root
  77. out/root/dir
  78. out/root/dirsymlink
  79. out/root/dirsymlink/file.conflict
  80. out/root/dirsymlink/filea
  81. out/root/dirsymlink/fileb
  82. == with_option_normal ==
  83. out
  84. out/root
  85. out/root/dir
  86. out/root/dir/file.conflict
  87. out/root/dir/filea
  88. out/root/dir/fileb
  89. out/root/dirsymlink
  90. == collision_normal ==
  91. out
  92. out/root
  93. out/root/dir
  94. out/root/dir/file.conflict
  95. out/root/dir/filea
  96. out/root/dir/fileb
  97. out/root/dir/filec
  98. out/root/dirsymlink
  99. == without_option_dir ==
  100. out
  101. out/root
  102. out/root/dir
  103. out/root/dirsymlink
  104. out/root/dirsymlink/file.conflict
  105. out/root/dirsymlink/filea
  106. out/root/dirsymlink/fileb
  107. == with_option_dir ==
  108. out
  109. out/root
  110. out/root/dir
  111. out/root/dir/file.conflict
  112. out/root/dir/filea
  113. out/root/dir/fileb
  114. out/root/dirsymlink
  115. == collision_dir ==
  116. out
  117. out/root
  118. out/root/dir
  119. out/root/dir/file.conflict
  120. out/root/dir/filea
  121. out/root/dir/fileb
  122. out/root/dir/filec
  123. out/root/dirsymlink
  124. ],
  125. [== without_option_normal ==
  126. == with_option_normal ==
  127. == collision_normal ==
  128. tar: root/dirsymlink/file.conflict: Cannot open: File exists
  129. tar: Exiting with failure status due to previous errors
  130. == without_option_dir ==
  131. == with_option_dir ==
  132. == collision_dir ==
  133. tar: root/dirsymlink/file.conflict: Cannot open: File exists
  134. tar: Exiting with failure status due to previous errors
  135. ])
  136. AT_CLEANUP