tar-override.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  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 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program 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. # Check that the user can override the tar program used by "make dist"
  17. # at runtime, by redefining the 'TAR' environment variable.
  18. # NOTE: currently this works only when the tar format used is 'v7'
  19. # (which is the default one).
  20. . test-init.sh
  21. cwd=$(pwd) || fatal_ "getting current working directory"
  22. echo AC_OUTPUT >> configure.ac
  23. cat > am--tar <<'END'
  24. #!/bin/sh
  25. echo $1 > am--tar-has-run
  26. shift
  27. exec tar "$@"
  28. END
  29. chmod a+x am--tar
  30. cat > Makefile.am <<'END'
  31. check-local: dist
  32. ls -l ;: For debugging.
  33. test -f am--tar-has-run
  34. CLEANFILES = am--tar-has-run
  35. END
  36. $ACLOCAL
  37. $AUTOCONF
  38. $AUTOMAKE
  39. ./configure
  40. clean_temp () { rm -f *.tar.* *has-run*; }
  41. $MAKE dist
  42. test -f $distdir.tar.gz
  43. ls | grep has-run && exit 1
  44. clean_temp
  45. TAR="$cwd/am--tar foo" $MAKE distcheck
  46. test -f $distdir.tar.gz
  47. test "$(cat am--tar-has-run)" = foo
  48. clean_temp
  49. unset TAR
  50. # Creative use of eval to pacify maintainer checks.
  51. eval \$'MAKE dist "TAR=./am--tar mu"'
  52. test -f $distdir.tar.gz
  53. test "$(cat am--tar-has-run)" = mu
  54. :