dist: fix automake bug #19614.
From https://bugs.gnu.org/19614 (Dimitrios Apostolou).
tar was piped into the compressor, and a pipeline reports only its
last exit status, so a failing tar left a truncated archive behind
and `make dist' still exited 0. `pipefail' is not portable, so tar
now writes $(distdir).tar and each dist-* target compresses that.
One tar run per `make dist' instead of one per format, at the price
of room for the uncompressed tarball.
Some tar implementations only warn about files they cannot archive
and still exit 0, so anything on tar's standard error counts as a
failure too. cpio prints a block count even when it succeeds, so
configure exempts it; AM_DIST_TAR_IGNORE_STDERR lets the user do the
same.
* lib/am/distdir.am ($(distdir).tar): new rule; runs tar and catches
its failures.
(AM_DIST_TAR_IGNORE_STDERR): new user variable.
(dist-gzip, dist-bzip2, dist-bzip3, dist-lzip, dist-xz, dist-zstd)
(dist-tarZ): compress $(distdir).tar instead of piping tar.
(dist-shar): likewise; shar and gzip now run separately.
(am__post_remove_distdir): remove $(distdir).tar too.
* m4/tar.m4 (_AM_PROG_TAR): substitute am__tar_ignore_stderr, "yes"
for cpio only.
* m4/optional.m4 (_AM_OPTIONAL_TAR): compress $(distdir).tar rather
than run tar again.
* t/dist-tar-fails.sh: new test.
* t/list-of-tests.mk (handwritten_TESTS): add it.
* t/dist-shar.sh: check that a failing shar fails `make dist-shar'.
* t/dist-formats.tap: keep the stubbed archiver's stderr clean.
* doc/automake.texi (The Types of Distributions): document it.
* NEWS: mention it.
9 files changed