compress.m4 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. dnl TAR_CHECK_COMPRESS(TOOL, SUF[, SUF2])
  17. dnl Tests whether tar can create archives using TOOL (i.e. using the --TOOL
  18. dnl command line option). SUF and optional SUF2 are suffixes for created
  19. dnl archives (without leading dot). Tar should be able to use TOOL to
  20. dnl automatically decompress archives with names ending on these suffixes.
  21. m4_define([TAR_CHECK_COMPRESS],
  22. [AT_SETUP([compress: $1])
  23. AT_KEYWORDS([compression compress-$1 $1])
  24. AT_CHECK([
  25. AT_GZIP_PREREQ($1)
  26. unset TAR_OPTIONS
  27. unset XZ_OPT
  28. unset XZ_DEFAULTS
  29. touch empty
  30. set -e
  31. : create with --$1
  32. tar --$1 -cf k.tar.$2 empty
  33. tar tf k.tar.$2
  34. m4_foreach([SUF], m4_quote(m4_shift($@)),
  35. [
  36. echo testing .SUF
  37. tar -acf k2.tar.SUF empty
  38. cat k2.tar.SUF | $1 -d > k.SUF.tar
  39. tar tf k.SUF.tar
  40. ])
  41. # Extraction: ensure compressed format is correctly recognized
  42. rm -f empty
  43. tar xf k.tar.$2
  44. test -f empty
  45. ],
  46. [0],
  47. [empty
  48. m4_foreach([SUF],m4_quote(m4_shift($@)),[testing .SUF
  49. empty
  50. ])])
  51. AT_CLEANUP
  52. ])