bug-automake
[Top][All Lists]
Advanced

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

automake 1.5 generates a 'make dist' that does a chmod a+w on sources


From: Paul Eggert
Subject: automake 1.5 generates a 'make dist' that does a chmod a+w on sources
Date: Mon, 24 Sep 2001 11:52:32 -0700 (PDT)

When building tar 1.13.24 I discovered that 'make dist' did a chmod
a+w on my original sources.  This is because 'make dist' uses hard
links to build a temporary directory containing the distribution, and
then does a 'chmod -R a+w' on the temporary directory just before
removing it.  That chmod has an undesirable side effect on the
original source files.

Here is a patch to cause 'make dist' to chmod u+w only, and only on
directories, as that's all that is really needed to allow 'rm -fr' to
succeed.

2001-09-14  Paul Eggert  <address@hidden>

        * lib/am/distdir.am (REMOVE_DISTDIR):
        New macro.  Do not change permission of non-directories.
        Change only user permission, as there's no point to changing group
        or other permission.
        (distdir, dist, dist-bzip2, dist-tarZ, dist-shar, dist-zip, dist-all,
         distcheck): Use it.

===================================================================
RCS file: lib/am/distdir.am,v
retrieving revision 1.5
retrieving revision 1.5.0.1
diff -pu -r1.5 -r1.5.0.1
--- lib/am/distdir.am   2001/07/14 20:12:52     1.5
+++ lib/am/distdir.am   2001/09/15 05:12:18     1.5.0.1
@@ -29,6 +29,11 @@ else !%?TOPDIR_P%
 ?DISTDIR?distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 endif !%?TOPDIR_P%
 
+REMOVE_DISTDIR = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+
 distdir: $(DISTFILES)
 ##
 ## For Gnits users, this is pretty handy.  Look at 15 lines
@@ -47,7 +52,7 @@ endif %?TOPDIR_P%
 ## Only for the top dir.
 ##
 if %?TOPDIR_P%
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
        mkdir $(distdir)
 endif %?TOPDIR_P%
 ##
@@ -168,13 +173,13 @@ GZIP_ENV = --best
 .PHONY: dist
 dist: distdir
        $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
 
 if  %?BZIP2%
 .PHONY: dist-bzip2
 dist-bzip2: distdir
        $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
 endif  %?BZIP2%
 
 
@@ -182,7 +187,7 @@ if  %?COMPRESS%
 .PHONY: dist-tarZ
 dist-tarZ: distdir
        $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
 endif  %?COMPRESS%
 
 
@@ -190,7 +195,7 @@ if  %?SHAR%
 .PHONY: dist-shar
 dist-shar: distdir
        shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
 endif  %?SHAR%
 
 
@@ -199,7 +204,7 @@ if  %?ZIP%
 dist-zip: distdir
        -rm -f $(distdir).zip
        zip -rq $(distdir).zip $(distdir)
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
 endif  %?ZIP%
 
 endif %?TOPDIR_P%
@@ -223,7 +228,7 @@ dist-all: distdir
 ?SHAR? shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 ?ZIP?  -rm -f $(distdir).zip
 ?ZIP?  zip -rq $(distdir).zip $(distdir)
-       -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
 
 endif %?TOPDIR_P%
 
@@ -239,8 +244,7 @@ if %?TOPDIR_P%
 # tarfile.
 .PHONY: distcheck
 distcheck: dist
-## Make sure we can remove distdir before trying to remove it.
-       -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
        GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
 ## Make the new source tree read-only.  Distributions ought to work in
 ## this case.  However, make the top-level directory writable so we
@@ -273,7 +277,7 @@ distcheck: dist
          && (test `find . -type f -print | wc -l` -eq 0 \
             || (echo "Error: files left after distclean" 1>&2; \
                 exit 1) )
-       -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
+       $(REMOVE_DISTDIR)
        @echo "$(distdir).tar.gz is ready for distribution" | \
          sed 'h;s/./=/g;p;x;p;x'
 endif %?TOPDIR_P%



reply via email to

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