| 1 |
# This file is part of GNU tar testsuite. -*- Autotest -*- |
| 2 |
# Copyright 2018-2023 Free Software Foundation, Inc. |
| 3 |
# |
| 4 |
# GNU tar 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 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# GNU tar is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 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 |
|
| 17 |
dnl TAR_CHECK_COMPRESS(TOOL, SUF[, SUF2]) |
| 18 |
dnl Tests whether tar can create archives using TOOL (i.e. using the --TOOL |
| 19 |
dnl command line option). SUF and optional SUF2 are suffixes for created |
| 20 |
dnl archives (without leading dot). Tar should be able to use TOOL to |
| 21 |
dnl automatically decompress archives with names ending on these suffixes. |
| 22 |
m4_define([TAR_CHECK_COMPRESS], |
| 23 |
[AT_SETUP([compress: $1]) |
| 24 |
AT_KEYWORDS([compression compress-$1 $1]) |
| 25 |
|
| 26 |
AT_CHECK([ |
| 27 |
AT_GZIP_PREREQ($1) |
| 28 |
unset TAR_OPTIONS |
| 29 |
|
| 30 |
touch empty |
| 31 |
set -e |
| 32 |
: create with --$1 |
| 33 |
tar --$1 -cf k.tar.$2 empty |
| 34 |
tar tf k.tar.$2 |
| 35 |
|
| 36 |
m4_foreach([SUF], m4_quote(m4_shift($@)), |
| 37 |
[ |
| 38 |
echo testing .SUF |
| 39 |
tar -acf k2.tar.SUF empty |
| 40 |
cat k2.tar.SUF | $1 -d > k.SUF.tar |
| 41 |
tar tf k.SUF.tar |
| 42 |
]) |
| 43 |
|
| 44 |
# Extraction: ensure compressed format is correctly recognized |
| 45 |
rm -f empty |
| 46 |
tar xf k.tar.$2 |
| 47 |
test -f empty |
| 48 |
], |
| 49 |
[0], |
| 50 |
[empty |
| 51 |
m4_foreach([SUF],m4_quote(m4_shift($@)),[testing .SUF |
| 52 |
empty |
| 53 |
])]) |
| 54 |
|
| 55 |
AT_CLEANUP |
| 56 |
]) |