From 7ee69d2e083ec447f0309b0581d341aee3f8264a Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 17 May 2002 10:49:55 +0000 Subject: [PATCH] For PR automake/186: * lib/am/distdir.am (distcheck): Attempt a DESTDIR install. * tests/destdir.test: New file. * tests/Makefile.am (TESTS): Add destdir.test. --- ChangeLog | 7 +++++++ NEWS | 2 ++ lib/am/distdir.am | 25 +++++++++++++++++++++++-- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/destdir.test | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100755 tests/destdir.test diff --git a/ChangeLog b/ChangeLog index 3fb5902..09f4da3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-05-17 Alexandre Duret-Lutz + + For PR automake/186: + * lib/am/distdir.am (distcheck): Attempt a DESTDIR install. + * tests/destdir.test: New file. + * tests/Makefile.am (TESTS): Add destdir.test. + 2002-05-16 Alexandre Duret-Lutz * automake.in (conditional_true_when): Return false if $WHEN == FALSE. diff --git a/NEWS b/NEWS index 1af7979..8133eca 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ New in 1.6a: +* `make distcheck' will enforce DESTDIR support by attempting + a DESTDIR install. * `+=' can be used in conditionals, even if the augmented variable was defined for another condition. * It is no longuer a requirement to use AM_CONFIG_HEADER instead of diff --git a/lib/am/distdir.am b/lib/am/distdir.am index 4b9d46c..ac96b3f 100644 --- a/lib/am/distdir.am +++ b/lib/am/distdir.am @@ -270,9 +270,13 @@ distcheck: dist ## Undo the write access. chmod a-w $(distdir) dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \ +## We will attemp a DESTDIR install in $dc_destdir. We don't +## create this directory under $dc_install_base, because it would +## create very long directory names. + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ ?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \ && cd $(distdir)/=build \ - && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ ?GETTEXT? --with-included-gettext \ ## Additional flags for configure. Keep this last in the configure ## invocation so the user can override previous options. @@ -284,10 +288,27 @@ distcheck: dist && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ ## We use -le 1 because the `dir' file might still exist after uninstall. - && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ + && (test `find "$$dc_install_base" -type f -print | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ find $$dc_install_base -type f -print ; \ exit 1; } >&2 ) \ +## Make sure the package has proper DESTDIR support (we could not test this +## in the previous install/installcheck/uninstall test, because it's reasonable +## for installcheck to fails in a DESTDIR install). +## We make the `$dc_install_base' read-only because this is where files +## with missing DESTDIR support are likely to be installed. + && chmod -R a-w "$$dc_install_base" \ +## The logic here is quire convoluted because we must clean $dc_destdir +## whatever happens (it won't be erased by the next run of distcheck like +## $(dirstir) is). + && ({ $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && (test `find "$$dc_destdir" -type f -print | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall (check DESTDIR support):" ; \ + find "$$dc_destdir" -type f -print ; \ + exit 1; } >&2 ) \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ ## Make sure to remove the dist file we created in the test build ## directory. diff --git a/tests/Makefile.am b/tests/Makefile.am index 33e5ed4..4d744bc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -124,6 +124,7 @@ depend.test \ depend2.test \ depend3.test \ depend4.test \ +destdir.test \ dirforbid.test \ dirname.test \ discover.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 45b4f2a..a1ace4d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -208,6 +208,7 @@ depend.test \ depend2.test \ depend3.test \ depend4.test \ +destdir.test \ dirforbid.test \ dirname.test \ discover.test \ diff --git a/tests/destdir.test b/tests/destdir.test new file mode 100755 index 0000000..8a4fd8c --- /dev/null +++ b/tests/destdir.test @@ -0,0 +1,33 @@ +#! /bin/sh + +# Make sure that `make distcheck' can find some $(DESTDIR) omissions. +# PR/186. + +. $srcdir/defs || exit 1 + +set -e + +cat >> configure.in <<'EOF' +AC_OUTPUT +EOF + +cat > Makefile.am <<'EOF' +dist_data_DATA = foo + +# This rule is bogus because it doesn't use $(DESTDIR) on the +# second argument of cp. distcheck is expected to catch this. +install-data-hook: + cp $(DESTDIR)$(datadir)/foo $(datadir)/bar + +uninstall-local: + rm -f $(DESTDIR)$(datadir)/bar +EOF + +: > foo + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a +./configure +$MAKE distcheck && exit 1 +: -- 2.7.4