automake-patches
[Top][All Lists]
Advanced

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

Re: automake/533: DISTFILES containing a directory and files in that dir


From: Ralf Wildenhues
Subject: Re: automake/533: DISTFILES containing a directory and files in that directory
Date: Fri, 13 Mar 2009 00:17:58 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Peter,

* Peter Breitenlohner wrote on Thu, Jan 29, 2009 at 05:24:55PM CET:
> >Number:         533
> >Synopsis:       DISTFILES containing a directory and files in that directory

> I tried to include a Third-Party package (automake manual 23.2) using
> the suggestion in the last paragraph, i.e., doing everything with a
> proxy Makefile.am such as:
> 
>    bin_PROGRAMS = prog
>    prog_SOURCES = sub/prog.c
>    EXTRA_DIST = sub
> 
> with the result that 'make distcheck' failed.
> 
> In this example the use of nodist_prog_SOURCES would of course avoid
> this problem, but there may be other situations where this cannot be
> done easily.

> Attached is a patch addressing this problem.

Thank you for the good bug report and the proposed patch.

> The solution may be somewhat simple minded. Maybe the chmod has to be
> replaced by 'find ... || chmod ...' as is done in other places.

Well, yes.  The simple 'chmod -R' changes modes of files, too, which is
a bad idea.  Changing that to be
  find ... -type d -exec chmod ...

is also not sufficient if you want to allow directories being listed
multiple times: files being copied over by a later 'cp -pR' might not
be writable, leading to errors again.  Adding -f to these cp invocations
should fix that.  (Note that 'cp -fpR' alone without the prior 'find
... chmod' is not sufficient either).

The following patch seems to handle these issues, and the testsuite
addition seems to expose most of them.


Now, I'm not so sure whether that is the way we want to go.  Some may
regard the distcheck failure as feature not a bug, it being more
efficient and "cleaner" to not list things multiple times.  OTOH,
sometimes it may not be possible to avoid it; and I think it is a
source of less compatibility between different Automake versions.

So I'm still unsure whether to apply this patch.

Cheers,
Ralf

2009-03-13  Peter Breitenlohner  <address@hidden>
            Ralf Wildenhues  <address@hidden>

        For PR automake/533:
        DISTFILES containing a directory and files in that directory.
        When the source tree contains non-writable files or directories
        (as happens during distcheck), and directories or entries
        thereof are listed multiple times in variables to be
        distributed, then the corresponding directories below $(distdir)
        need to be made writable recursively.  Since file modes should
        not change, they need to be copied recursively using `cp -f'.
        * lib/am/distdir.am: Handle this situation.
        * tests/distdir.test: Extend test to those cases.
        * NEWS: Update.
        Report by Peter Breitenlohner.

diff --git a/NEWS b/NEWS
index 35148ef..bf66ed8 100644
--- a/NEWS
+++ b/NEWS
@@ -187,6 +187,9 @@ Bugs fixed in 1.10a:
   - Targets provided by automake behave better with `make -n', in that they
     take care not to create files.
 
+  - `make distcheck' works also when both a directory and some file below it
+    have been added to a distribution variable, such as EXTRA_DIST or 
*_SOURCES.
+
 * Bugs introduced by 1.10:
 
   - Fix output of dummy dependency files in presence of post-processed
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index ad5e771..4290fda 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -198,10 +198,16 @@ endif %?TOPDIR_P%
 ## directory exists only in $(srcdir), because some vendor Make (such
 ## as Tru64) will magically create an empty directory in `.'
            dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+## If the destination directory already exists, it may contain read-only
+## files, e.g., during `make distcheck'.
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -777 -exec chmod a+rwx 
{} \;; \
+           fi; \
            if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-             cp -pR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -777 -exec chmod a+rwx 
{} \;; \
            fi; \
-           cp -pR $$d/$$file "$(distdir)$$dir" || exit 1; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
          else \
 ## Test for file existence because sometimes a file gets included in
 ## DISTFILES twice.  For example this happens when a single source
diff --git a/tests/distdir.test b/tests/distdir.test
index 641a307..dc5dfe9 100755
--- a/tests/distdir.test
+++ b/tests/distdir.test
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2003, 2006, 2007  Free Software Foundation, 
Inc.
+# Copyright (C) 1996, 2001, 2002, 2003, 2006, 2007, 2009  Free Software
+# Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,6 +19,7 @@
 # sure *srcdir is properly handled.  Note that using `./', as in
 #   EXTRA_DIST = ./joe
 # does not work portably: it fails with HP-UX and Tru64 make.
+# Also test DISTFILES containing a directory and a file in it.
 
 . ./defs || Exit 1
 
@@ -26,20 +28,36 @@ set -e
 echo AC_OUTPUT >>configure.in
 
 cat > Makefile.am << 'END'
-EXTRA_DIST = foo/bar joe $(top_srcdir)/woo/doo $(srcdir)/dada
+include_HEADERS = some/file another/sub/subsub/file2 yet/another/file3
+EXTRA_DIST = foo/bar joe $(top_srcdir)/woo/doo $(srcdir)/dada \
+            some another/sub yet \
+            some another/sub yet
+
+
+all-local:
+       $(MKDIR_P) another/sub/subsub
+       touch another/sub/subsub/file2
+
+CLEANFILES = another/sub/subsub/file2
+
 check-local:
        test -f $(srcdir)/foo/bar
        test -f $(srcdir)/woo/doo
        test -f $(srcdir)/joe
        test -f $(srcdir)/dada
+       test -f $(srcdir)/some/file
+       test -f $(srcdir)/another/sub/subsub/file2 \
+       || test -f /another/sub/subsub/file2
+       test -f $(srcdir)/yet/another/file3
 END
 
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 
-mkdir foo woo
-touch foo/bar joe woo/doo dada
+mkdir foo woo some another another/sub another/sub/subsub yet yet/another
+touch foo/bar joe woo/doo dada some/file another/sub/subsub/file2
+touch yet/another/file3
 
 mkdir build
 cd build




reply via email to

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