4
0

append02.at 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3, or (at your option)
  7. # any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. # 02110-1301, USA.
  16. # Using tar 1.15.x the following equivalent command sets:
  17. #
  18. # 1. tar cf archive file1 file2
  19. # and
  20. # 2. tar cfT archive /dev/null
  21. # tar rf archive file1
  22. # tar rt archive file2
  23. #
  24. # produced different archives (GNU format is assumed). It was reported
  25. # by TAMUKI Shoichi on 2006-07-21 [1].
  26. #
  27. # The bug was due to tar being unable to discern between GNU and OLDGNU
  28. # formats and always assuming the latter. The main difference between
  29. # the two is that OLDGNU preserves all bits in the mode field, whereas
  30. # GNU format keeps only the lower 9 ones (mode & 0777).
  31. #
  32. # This was fixed on 2006-07-24 (commit f4e4adea80a) by making tar truncate
  33. # the mode field even in OLDGNU format. Obviously, the fix broke the
  34. # format backward compatibility, but it went unnoticed until 2009-10-03
  35. # (after all, the OLDGNU format is not in much use nowadays), when
  36. # Igor Zhbanov reported it [2].
  37. #
  38. # The final fix was applied on 2009-10-04.
  39. #
  40. # References:
  41. # [1] <[email protected]>
  42. # http://lists.gnu.org/archive/html/bug-tar/2006-07/msg00029.html
  43. # [2] <[email protected]>
  44. # http://lists.gnu.org/archive/html/bug-tar/2009-10/msg00006.html
  45. # The test case below verifies that the equivalent create and append commands
  46. # produce binary equivalent archives for all formats.
  47. AT_SETUP([append vs. create])
  48. AT_KEYWORDS([append append02 append-gnu])
  49. AT_TAR_CHECK([
  50. genfile --file file1
  51. genfile --file file2
  52. # Make sure file timestamps in the archive will not differ
  53. MTIME="--mtime=@0"
  54. # For PAX archives, we need to make sure extended header names are
  55. # reproducible and that their contents won't change with time
  56. if test $[]TEST_TAR_FORMAT = posix; then
  57. TAR_OPTIONS="$TAR_OPTIONS --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=mtime,delete=atime,delete=ctime"
  58. fi
  59. echo Creating archive.1
  60. tar $MTIME -cf archive.1 file1 file2
  61. echo Creating archive.2
  62. tar $MTIME -cf archive.2 -T /dev/null
  63. tar $MTIME -rf archive.2 file1
  64. tar $MTIME -rf archive.2 file2
  65. echo Comparing archives
  66. cmp archive.1 archive.2
  67. ],
  68. [0],
  69. [Creating archive.1
  70. Creating archive.2
  71. Comparing archives
  72. ])
  73. AT_CLEANUP
  74. # End of append02.at