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