automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

enforce DESTDIR in distcheck (PR/186)


From: Alexandre Duret-Lutz
Subject: enforce DESTDIR in distcheck (PR/186)
Date: Wed, 08 May 2002 15:25:49 +0200
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu)

A recent thread in gnu.bug.utils recalled me this failed attempt:
http://mail.gnu.org/pipermail/automake-patches/2002-January/000610.html

Here is a second try.  This time

  - files are installed in a temporary directory under /tmp
    (this is to avoid the very long directory names mentioned in
    the above mail);

  - it does two installs: one without, and the other with DESTDIR
    (we run make installcheck in the first case only)

This still uses the read-only trick to detect files which are
installed in the wrong directory.

How does it look?

2002-05-08  Alexandre Duret-Lutz  <address@hidden>

        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.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.178
diff -u -r1.178 NEWS
--- NEWS        6 May 2002 06:51:04 -0000       1.178
+++ NEWS        8 May 2002 13:16:48 -0000
@@ -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
Index: lib/am/distdir.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/distdir.am,v
retrieving revision 1.32
diff -u -r1.32 distdir.am
--- lib/am/distdir.am   26 Mar 2002 10:48:35 -0000      1.32
+++ lib/am/distdir.am   8 May 2002 13:16:48 -0000
@@ -270,9 +270,13 @@
 ## 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 @@
          && $(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.
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.396
diff -u -r1.396 Makefile.am
--- tests/Makefile.am   8 May 2002 08:56:42 -0000       1.396
+++ tests/Makefile.am   8 May 2002 13:16:48 -0000
@@ -123,6 +123,7 @@
 depend2.test \
 depend3.test \
 depend4.test \
+destdir.test \
 dirforbid.test \
 dirname.test \
 discover.test \
Index: tests/destdir.test
===================================================================
RCS file: tests/destdir.test
diff -N tests/destdir.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/destdir.test  8 May 2002 13:16:48 -0000
@@ -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
+:

-- 
Alexandre Duret-Lutz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]