15 Commits

Author SHA1 Message Date
Sergey Poznyakoff
44cfdfb8b6 Version 1.32 2019-02-23 14:54:53 +02:00
Sergey Poznyakoff
97d8951536 Minor fixes in docs.
* doc/tar.1: Remove description of the --preserve option
Document verbosity levels.
* doc/tar.texi: Fix description of the -o option.
2019-02-04 21:30:00 +02:00
Daniel Le
bf5d66109c Fix typos in the documentation
Short option "t" was mistranslated to "--test" instead of "--list" in commit
67cad0792b.
2019-01-15 15:29:03 +02:00
Sergey Poznyakoff
bd1b0fc97c Fix build on AIX
* src/unlink.c (flush_deferred_unlinks): Avoid possible duplicate case
(if ENOTEMPTY==EEXIST)
2019-01-15 15:21:03 +02:00
Sergey Poznyakoff
a7289daf5c Version 1.31.90 2019-01-15 14:38:02 +02:00
Sergey Poznyakoff
72506bddee Ensure gnu format when running checkpoint tests 2019-01-14 23:32:15 +02:00
Sergey Poznyakoff
a311b908c0 Fix compression tests
Existing compression tests used tar with compiled-in defaults. However,
some of the defaults are sure to create archives that are not byte-to-byte
reproducible (e.g. DEFAULT_ARCHIVE_FORMAT=POSIX, because the name field
in posix extended headers uses PID of the creating process by default).
Moreover, some compressors (e.g. gzip) store current timestamp in
the file header when compressing from stdin, so that using cmp on the
two created archives as the tests did is error-prone. Another problem
is that the tests implicitly assumed that tar uses archive suffix to
recognize its format when extracting, which isn't the case. Finally,
there's hardly any reason in using sed to create m4 sources, when
everything can be achieved by m4 itself.

* tests/Makefile.am: Remove generation of compress-*.at files.
* tests/compress.at.in: Remove.
* tests/compress.m4: New file.
* tests/testsuite.at: Include compress.m4, use TAR_CHECK_COMPRESS to
check compression options.
2019-01-14 18:55:43 +02:00
Sergey Poznyakoff
cb07844454 Fix possible NULL dereference (savannah bug #55369)
* src/sparse.c (pax_decode_header): Check return from find_next_block.
2019-01-14 15:22:09 +02:00
Sergey Poznyakoff
2f5a57be4b Fix compilation without iconv. 2019-01-14 14:46:43 +02:00
Sergey Poznyakoff
3da8c2850d Fix iconv usage.
Patch by Christian Weisgerber.

* src/utf8.c (utf8_convert): non-zero return from iconv means failure.
2019-01-14 13:59:39 +02:00
Pavel Raiskup
c697d62598 tests: fix numeric.at for BSD
While creating file, BSD kernels inherit the group ownership from
parent directory.
http://lists.gnu.org/archive/html/bug-tar/2016-06/msg00000.html

* tests/numeric.at: Attempt to 'chown' the newly created directory
to proper group (at least on affected machines that command is
expected to succeed).
2019-01-14 12:54:29 +02:00
Sergey Poznyakoff
b0930da045 Fix typo in manpage. 2019-01-14 12:48:16 +02:00
Sergey Poznyakoff
f86722c34c Fix expected output in dirrem tests.
In both tests, the "file changed as we read it" warning might be
produced for dir/sub, depending on the ctime resolution and timing.
The problem was fixed by 64b43fdf70, but regressed
after e7cd377f78, which removed 1 second
delays between each pair of checkpoints. Since the presense or absense
of this warning is irrelevant for the test, it is now suppressed.

* tests/dirrem01.at: Suppress the file-changed warning.
* tests/dirrem02.at: Likewise.
2019-01-14 12:26:59 +02:00
Sergey Poznyakoff
aa0684ce90 Fix the use of --checkpoint without explicit --checkpoint-action
* src/checkpoint.c (checkpoint_finish_compile): Set default action,
if necessary.
* tests/checkpoint/defaults.at: New testcase.
* tests/checkpoint/dot-compat.at: New testcase.
* tests/checkpoint/dot-int.at: New testcase.
* tests/checkpoint/dot.at: New testcase.
* tests/checkpoint/interval.at: New testcase.
* tests/Makefile.am: Add new testcases.
* tests/testsuite.at Include new testcases.
2019-01-12 10:24:47 +02:00
Sergey Poznyakoff
85c005ee13 Remove erroneous abort() call
The call was introduced by commit ccef8581. It caused tar to abort
on perfectly normal operations, like untarring archives containing
./ with the -U option,

See http://lists.gnu.org/archive/html/bug-tar/2019-01/msg00019.html
for details.

* src/extract.c (maybe_recoverable): Remove misplaced call to abort().
2019-01-10 18:18:49 +02:00
23 changed files with 304 additions and 153 deletions

2
.gitignore vendored
View File

@@ -8,6 +8,7 @@
.deps
.emacs*
.libs
.gdbinit
ABOUT-NLS
ChangeLog
INSTALL
@@ -28,3 +29,4 @@ libtool
m4
rmt
stamp-h1
TAGS

18
NEWS
View File

@@ -1,6 +1,22 @@
GNU tar NEWS - User visible changes. 2019-01-02
GNU tar NEWS - User visible changes. 2019-02-23
Please send GNU tar bug reports to <bug-tar@gnu.org>
version 1.32 - Sergey Poznyakoff, 2019-02-23
* Fix the use of --checkpoint without explicit --checkpoint-action
* Fix extraction with the -U option
See http://lists.gnu.org/archive/html/bug-tar/2019-01/msg00015.html,
for details
* Fix iconv usage on BSD-based systems
* Fix possible NULL dereference (savannah bug #55369)
* Improve the testsuite
version 1.31 - Sergey Poznyakoff, 2019-01-02

1
THANKS
View File

@@ -95,6 +95,7 @@ Christian Laubscher christian.laubscher@tiscalinet.ch
Christian T. Dum ctd@mpe-garching.mpg.de
Christian von Roques roques@pond.sub.org
Christian Wetzel wetzel@phoenix-pacs.de
Christian Weisgerber naddy@mips.inka.de
Christoph Litauer litauer@mailhost.uni-koblenz.de
Christophe Colle colle@krtkg1.rug.ac.be
Christophe Kalt Christophe.Kalt@kbcfp.com

View File

@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_INIT([GNU tar], [1.31], [bug-tar@gnu.org])
AC_INIT([GNU tar], [1.32], [bug-tar@gnu.org])
AC_CONFIG_SRCDIR([src/tar.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])

View File

@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
.TH TAR 1 "May 16, 2018" "TAR" "GNU TAR Manual"
.TH TAR 1 "February 4, 2019" "TAR" "GNU TAR Manual"
.SH NAME
tar \- an archiving utility
.SH SYNOPSIS
@@ -111,7 +111,7 @@ into the archive file
verbosely listing the files being archived:
.PP
.EX
.B tar cfv a.tar /etc
.B tar cfv etc.tar /etc
.EE
.PP
In
@@ -133,9 +133,9 @@ The example command above written in the
could look like:
.PP
.EX
.B tar -cvf a.tar /etc
.B tar -cvf etc.tar /etc
or
.B tar -c -v -f a.tar /etc
.B tar -c -v -f etc.tar /etc
.EE
.PP
In
@@ -152,11 +152,11 @@ method.
Here are several ways of writing the example command in this style:
.PP
.EX
.B tar --create --file a.tar --verbose /etc
.B tar --create --file etc.tar --verbose /etc
.EE
or (abbreviating some options):
.EX
.B tar --cre --file=a.tar --verb /etc
.B tar --cre --file=etc.tar --verb /etc
.EE
.PP
The options in all three styles can be intermixed, although doing so
@@ -562,9 +562,6 @@ stored in archive with owner name \fINEWUSR\fR and UID \fINEWUID\fR.
\fB\-p\fR, \fB\-\-preserve\-permissions\fR, \fB\-\-same\-permissions\fR
extract information about file permissions (default for superuser)
.TP
\fB\-\-preserve\fR
Same as both \fB\-p\fR and \fB\-s\fR.
.TP
\fB\-\-same\-owner\fR
Try extracting files with the same ownership as exists in the archive
(default for superuser).
@@ -1117,7 +1114,11 @@ The \fBSIG\fR prefix can be omitted.
Print file modification times in UTC.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Verbosely list files processed.
Verbosely list files processed. Each instance of this option on the
command line increases the verbosity level by one. The maximum
verbosity level is 3. For a detailed discussion of how various
verbosity levels affect tar's output, please refer to \fBGNU Tar
Manual\fR, subsection 2.5.1 "\fBThe \-\-verbose Option\fR".
.TP
\fB\-\-warning\fR=\fIKEYWORD\fR
Enable or disable warning messages identified by \fIKEYWORD\fR. The

View File

@@ -1464,7 +1464,7 @@ tar: Removing leading '/' from member names
/home/myself/practice/folk
/home/myself/practice/jazz
/home/myself/practice/collection.tar
$ @kbd{tar --test --file practice.tar}
$ @kbd{tar --list --file practice.tar}
home/myself/practice/
home/myself/practice/blues
home/myself/practice/folk
@@ -1495,7 +1495,7 @@ home/myself/practice/blues
home/myself/practice/folk
home/myself/practice/jazz
home/myself/practice/collection.tar
$ @kbd{tar --test --file practice.tar}
$ @kbd{tar --list --file practice.tar}
home/myself/practice/
home/myself/practice/blues
home/myself/practice/folk
@@ -3795,8 +3795,8 @@ them with the equivalent long option.
@item -m @tab @ref{--touch}.
@item -o @tab When creating, @ref{--no-same-owner}, when extracting ---
@ref{--portability}.
@item -o @tab When extracting, same as @ref{--no-same-owner}. When creating,
-- @ref{--old-archive}.
The latter usage is deprecated. It is retained for compatibility with
the earlier versions of @GNUTAR{}. In future releases

View File

@@ -149,18 +149,20 @@ checkpoint_compile_action (const char *str)
void
checkpoint_finish_compile (void)
{
if (checkpoint_state == CHKP_INIT
&& checkpoint_option
&& !checkpoint_action)
{
/* Provide a historical default */
checkpoint_compile_action ("echo");
}
if (checkpoint_state == CHKP_COMPILE)
{
sigprocmask (SIG_BLOCK, &sigs, NULL);
if (checkpoint_option)
{
if (!checkpoint_action)
/* Provide a historical default */
checkpoint_compile_action ("echo");
}
else if (checkpoint_action)
/* Otherwise, set default checkpoint rate */
if (!checkpoint_option)
/* set default checkpoint rate */
checkpoint_option = DEFAULT_CHECKPOINT;
checkpoint_state = CHKP_RUN;

View File

@@ -787,7 +787,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
case UNLINK_FIRST_OLD_FILES:
break;
}
abort (); /* notreached */
FALLTHROUGH;
case ENOENT:
/* Attempt creating missing intermediate directories. */

View File

@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
if (!b) \
FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
if (!blk)
FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))

View File

@@ -127,7 +127,9 @@ flush_deferred_unlinks (bool force)
case EEXIST:
/* OpenSolaris >=10 sets EEXIST instead of ENOTEMPTY
if trying to remove a non-empty directory */
#if defined ENOTEMPTY && ENOTEMPTY != EEXIST
case ENOTEMPTY:
#endif
/* Keep the record in list, in the hope we'll
be able to remove it later */
prev = p;

View File

@@ -35,11 +35,14 @@
# define iconv_open(tocode, fromcode) ((iconv_t) -1)
# undef iconv
# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) ((size_t) 0)
# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) (errno = ENOSYS, (size_t) -1)
# undef iconv_close
# define iconv_close(cd) 0
# undef iconv_t
# define iconv_t int
#endif
@@ -81,7 +84,18 @@ utf8_convert (bool to_utf, char const *input, char **output)
outlen = inlen * MB_LEN_MAX + 1;
ob = ret = xmalloc (outlen);
ib = (char ICONV_CONST *) input;
if (iconv (cd, &ib, &inlen, &ob, &outlen) == -1)
/* According to POSIX, "if iconv() encounters a character in the input
buffer that is valid, but for which an identical character does not
exist in the target codeset, iconv() shall perform an
implementation-defined conversion on this character." It will "update
the variables pointed to by the arguments to reflect the extent of the
conversion and return the number of non-identical conversions performed".
On error, it returns -1.
In other words, non-zero return always indicates failure, either because
the input was not fully converted, or because it was converted in a
non-reversible way.
*/
if (iconv (cd, &ib, &inlen, &ob, &outlen) != 0)
{
free (ret);
return false;

View File

@@ -19,7 +19,7 @@
EXTRA_DIST = $(TESTSUITE_AT) \
testsuite package.m4 star/README star/quicktest.sh \
compress.at.in
compress.m4
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
@@ -47,6 +47,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
TESTSUITE_AT = \
testsuite.at\
compress.m4\
T-cd.at\
T-dir00.at\
T-dir01.at\
@@ -70,12 +71,11 @@ TESTSUITE_AT = \
chtype.at\
comprec.at\
comperr.at\
compress-zstd.at\
compress-xz.at\
compress-bzip2.at\
compress-gzip.at\
compress-lzip.at\
compress-lzop.at\
checkpoint/defaults.at\
checkpoint/interval.at\
checkpoint/dot.at\
checkpoint/dot-compat.at\
checkpoint/dot-int.at\
delete01.at\
delete02.at\
delete03.at\
@@ -277,42 +277,6 @@ TESTSUITE_AT = \
selacl01.at\
capabs_raw01.at
CLEANFILES += compress-zstd.at
compress-zstd.at: compress.at.in
$(AM_V_GEN)rm -rf $@ $@-t
$(AM_V_at)sed 's/@tool@/zstd/g;s/@suff@/zst/g;s/@suff2@/tzst/g;' \
$(srcdir)/compress.at.in > $@-t && chmod a-w $@-t && mv $@-t $@
CLEANFILES += compress-gzip.at
compress-gzip.at: compress.at.in
$(AM_V_GEN)rm -rf $@ $@-t
$(AM_V_at)sed 's/@tool@/gzip/g;s/@suff@/gz/g;s/@suff2@/tgz/g;' \
$(srcdir)/compress.at.in > $@-t && chmod a-w $@-t && mv $@-t $@
CLEANFILES += compress-xz.at
compress-xz.at: compress.at.in
$(AM_V_GEN)rm -rf $@ $@-t
$(AM_V_at)sed 's/@tool@/xz/g;s/@suff@/xz/g;s/@suff2@/txz/g;' \
$(srcdir)/compress.at.in > $@-t && chmod a-w $@-t && mv $@-t $@
CLEANFILES += compress-bzip2.at
compress-bzip2.at: compress.at.in
$(AM_V_GEN)rm -rf $@ $@-t
$(AM_V_at)sed 's/@tool@/bzip2/g;s/@suff@/bz2/g;s/@suff2@/tbz2/g;' \
$(srcdir)/compress.at.in > $@-t && chmod a-w $@-t && mv $@-t $@
CLEANFILES += compress-lzip.at
compress-lzip.at: compress.at.in
$(AM_V_GEN)rm -rf $@ $@-t
$(AM_V_at)sed 's/@tool@/lzip/g;s/@suff@/lz/g;s/@suff2@//g;' \
$(srcdir)/compress.at.in > $@-t && chmod a-w $@-t && mv $@-t $@
CLEANFILES += compress-lzop.at
compress-lzop.at: compress.at.in
$(AM_V_GEN)rm -rf $@ $@-t
$(AM_V_at)sed 's/@tool@/lzop/g;s/@suff@/lzo/g;s/@suff2@//g;' \
$(srcdir)/compress.at.in > $@-t && chmod a-w $@-t && mv $@-t $@
distclean-local:
-rm -rf download

View File

@@ -0,0 +1,25 @@
# This file is part of GNU tar test suite. -*- Autotest -*-
# Copyright 2019 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([checkpoint defaults])
AT_KEYWORDS([checkpoint checkpoint/defaults])
CPT_CHECK([
tar --checkpoint -c -f ../a.tar .
],
[0],
[],
[tar: Write checkpoint 10
])
AT_CLEANUP

View File

@@ -0,0 +1,23 @@
# This file is part of GNU tar test suite. -*- Autotest -*-
# Copyright 2019 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([dot action (compatibility syntax)])
AT_KEYWORDS([checkpoint checkpoint/dot-compat])
CPT_CHECK([
tar --checkpoint=.2 -c -f ../a.tar .
],
[],
[.....])
AT_CLEANUP

View File

@@ -0,0 +1,24 @@
# This file is part of GNU tar test suite. -*- Autotest -*-
# Copyright 2019 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([dot action and interval])
AT_KEYWORDS([checkpoint checkpoint/dot-int])
CPT_CHECK([
tar --checkpoint-action=dot --checkpoint=2 -c -f ../a.tar .
],
[],
[.....])
AT_CLEANUP

24
tests/checkpoint/dot.at Normal file
View File

@@ -0,0 +1,24 @@
# This file is part of GNU tar test suite. -*- Autotest -*-
# Copyright 2019 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([dot action])
AT_KEYWORDS([checkpoint checkpoint/dot])
CPT_CHECK([
tar --checkpoint-action=dot -c -f ../a.tar .
],
[],
[.])
AT_CLEANUP

View File

@@ -0,0 +1,29 @@
# This file is part of GNU tar test suite. -*- Autotest -*-
# Copyright 2019 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([checkpoint interval])
AT_KEYWORDS([checkpoint checkpoint/interval])
CPT_CHECK([
tar --checkpoint=2 -c -f ../a.tar .
],
[0],
[],
[tar: Write checkpoint 2
tar: Write checkpoint 4
tar: Write checkpoint 6
tar: Write checkpoint 8
tar: Write checkpoint 10
])
AT_CLEANUP

View File

@@ -1,67 +0,0 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2018-2019 Free Software Foundation, Inc.
# This file is part of GNU tar.
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# tar can create/decompress @tool@-compressed tarballs
AT_SETUP([compress: @tool@])
AT_KEYWORDS([compression @tool@])
unset TAR_OPTIONS
AT_CHECK([
AT_GZIP_PREREQ([@tool@])
touch empty
# Create with --@tool@:
tar --@tool@ -cf - empty 2>err > k.tar.@suff@ || exit 1
test -s err && exit 1
tar tf k.tar.@suff@ 2>err > out || exit 1
test "$(cat out)" = empty || exit 1
test -s err && exit 1
# Ensure -ac works with an -f-specified .@suff@-suffixed name.
tar -acf k2.tar.@suff@ empty 2>err > out || exit 1
cmp k2.tar.@suff@ k.tar.@suff@ || exit 1
test -s err && exit 1
# Extraction: ensure the .@suff@ suffix is recognized.
rm -f empty || exit 1
tar xf k.tar.@suff@ 2>err > out || exit 1
test -s err && exit 1
test -f empty || exit 1
if test -n '@suff2@'; then
# Extraction: ensure the .@suff2@ suffix is also recognized.
mv k.tar.@suff@ k.@suff2@ || exit 1
rm -f empty
tar xf k.@suff2@ 2>err > out || exit 1
test -s err && exit 1
test -f empty || exit 1
else
:
fi
],
[0],
[],
[],
[],[])
AT_CLEANUP

56
tests/compress.m4 Normal file
View File

@@ -0,0 +1,56 @@
# This file is part of GNU tar testsuite. -*- Autotest -*-
# Copyright 2018-2019 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl TAR_CHECK_COMPRESS(TOOL, SUF[, SUF2])
dnl Tests whether tar can create archives using TOOL (i.e. using the --TOOL
dnl command line option). SUF and optional SUF2 are suffixes for created
dnl archives (without leading dot). Tar should be able to use TOOL to
dnl automatically decompress archives with names ending on these suffixes.
m4_define([TAR_CHECK_COMPRESS],
[AT_SETUP([compress: $1])
AT_KEYWORDS([compression compress-$1 $1])
AT_CHECK([
AT_GZIP_PREREQ($1)
unset TAR_OPTIONS
touch empty
set -e
: create with --$1
tar --$1 -cf k.tar.$2 empty
tar tf k.tar.$2
m4_foreach([SUF], m4_quote(m4_shift($@)),
[
echo testing .SUF
tar -acf k2.tar.SUF empty
cat k2.tar.SUF | $1 -d > k.SUF.tar
tar tf k.SUF.tar
])
# Extraction: ensure compressed format is correctly recognized
rm -f empty
tar xf k.tar.$2
test -f empty
],
[0],
[empty
m4_foreach([SUF],m4_quote(m4_shift($@)),[testing .SUF
empty
])])
AT_CLEANUP
])

View File

@@ -27,9 +27,13 @@
# it prints a warning and exits with TAREXIT_DIFFERS.
#
# This test checks whether this behaviour is mimicked for directories, too.
# Remark: This file is based on 'filerem01.at', which is the test-case for
# a vanishing file.
#
# Notes:
# 1. This file is based on 'filerem01.at', which is the test-case for
# a vanishing file.
# 2. Depending on the stat.st_ctime resolution, the "file changed as we
# read it" warning might be issued for dir/sub. The test takes care to
# suppress it.
AT_SETUP([directory removed before reading])
AT_KEYWORDS([create incremental listed dirchange dirrem dirrem01])
@@ -48,13 +52,14 @@ esac
genfile --run --checkpoint=$CPT --unlink dir/sub/file2 --unlink dir/sub -- \
tar --blocking-factor=1 -c -f archive.tar \
--listed-incremental db -v dir >/dev/null
--listed-incremental db \
--warning=no-file-changed \
-v dir >/dev/null
],
[1],
[ignore],
[tar: dir: Directory is new
tar: dir/sub: Directory is new
tar: dir/sub: file changed as we read it
tar: dir/sub: File removed before we read it
],[],[],[gnu,posix])

View File

@@ -45,13 +45,14 @@ esac
genfile --run --checkpoint=$CPT --unlink dir/sub/file2 --unlink dir/sub -- \
tar --blocking-factor=1 -c -f archive.tar \
--listed-incremental db -v dir dir/sub >/dev/null
--listed-incremental db \
--warning=no-file-changed \
-v dir dir/sub >/dev/null
],
[2],
[ignore],
[tar: dir: Directory is new
tar: dir/sub: Directory is new
tar: dir/sub: file changed as we read it
tar: dir/sub: Cannot open: No such file or directory
tar: Exiting with failure status due to previous errors
],[],[],[gnu,posix])

View File

@@ -27,14 +27,17 @@ tar $1 -vvf a dir |dnl
])
AT_TAR_CHECK([
mkdir dir
genfile --file dir/file
MYUID=$(id -u) || AT_SKIP_TEST
MYGID=$(id -g) || AT_SKIP_TEST
MYUSR=$(id -un) || AT_SKIP_TEST
MYGRP=$(id -gn) || AT_SKIP_TEST
mkdir dir
# Ensure correct group id on BSDs.
chown :$MYGID dir >/dev/null 2>/dev/null
genfile --file dir/file
TESTOP([--create])
TESTOP([--list])
TESTOP([--diff])

View File

@@ -204,6 +204,7 @@ m4_include([version.at])
m4_include([pipe.at])
AT_BANNER([Options])
m4_include([options.at])
m4_include([options02.at])
m4_include([options03.at])
@@ -216,14 +217,35 @@ m4_include([opcomp04.at])
m4_include([opcomp05.at])
m4_include([opcomp06.at])
AT_BANNER([Checkpoints])
m4_pushdef([CPT_CHECK],
[AT_CHECK([
mkdir t
cd t
for i in 0 1 2 3 4 5 6 7 8 9
do
genfile --length 10240 --file $i
done
TAR_OPTIONS=-Hgnu
export TAR_OPTIONS
$1
],m4_shift($@))])
m4_include([checkpoint/defaults.at])
m4_include([checkpoint/interval.at])
m4_include([checkpoint/dot.at])
m4_include([checkpoint/dot-compat.at])
m4_include([checkpoint/dot-int.at])
m4_popdef([CPT_CHECK])
AT_BANNER([Compression])
m4_include([compress-gzip.at])
m4_include([compress-bzip2.at])
m4_include([compress-xz.at])
m4_include([compress.m4])
TAR_CHECK_COMPRESS(gzip, gz, tgz)
TAR_CHECK_COMPRESS(bzip2, bz2, tbz2)
TAR_CHECK_COMPRESS(xz, xz, txz)
dnl: omit lzma, because it would fail due to magic number mismatch
m4_include([compress-lzip.at])
m4_include([compress-lzop.at])
m4_include([compress-zstd.at])
TAR_CHECK_COMPRESS(lzip, lz)
TAR_CHECK_COMPRESS(lzop, lzo)
TAR_CHECK_COMPRESS(zstd, zst, tzst)
AT_BANNER([Positional options])
m4_include([positional01.at])