Subject: Re: bug#10975: 'make dist-gz dist-xz' fails

From: Stefano Lattarini <[email-masked]>
Date: Fri, 09 Mar 2012 21:36:42 +0100

Hi Olaf, Tim.

On 03/09/2012 08:53 PM, Tim Landscheidt wrote:
> Olaf Lenz <[email-masked]> wrote:
> 
>> [...]
>> The problem seems to be a race condition.
>> "make dist-bzip2" populates the distribution dir, tars it and deletes it
>> after 5 seconds.
>
Nope -- it deletes it *immediately*, and then re-tries to delete it after 5
seconds if the first deletion fails.  This is done in an attempt to accommodate
systems like MinGW where an "active" directory cannot be deleted:

 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10470>

 During that time "make dist-xz" has started and noticed
>> that the distdir already exists. Unfortunately, it is deleted while
>> dist-xz is still packing.
> 
> For a possible workaround, see
> <URI:http://permalink.gmane.org/gmane.comp.sysutils.automake.bugs/4940>.
> I agree that it would be nice to fix this properly.
> 
> Tim
> 
I've reproduced the bug with the attached test case (committed to maint).

I've also verified that the bug was also present in automake 1.11.2 and
automake 1.11.1, so this is not a regression introduced by the "sleep 5"
change referenced above.

For the moment, and until the bug is properly fixed, my advice is: don't
run multiple "dist-*" targets in the same make invocations.

Regards,
  Stefano
>From 370e5775c20872a8f2b5c1e520b31dc1544b9cd8 Mon Sep 17 00:00:00 2001
Message-Id: <370e5775c[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Fri, 9 Mar 2012 21:35:04 +0100
Subject: [PATCH] coverage: expose automake bug#10975

* tests/dist-pr10975.test: New test.
* tests/list-of-tests.mk: Add it.
* tests/Makefile.am (XFAIL_TESTS): Likewise.
---
 tests/Makefile.am        |    1 +
 tests/dist-pr109765.test |   44 ++++++++++++++++++++++++++++++++++++++++++++
 tests/list-of-tests.mk   |    1 +
 3 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100755 tests/dist-pr109765.test

diff --git a/tests/Makefile.am b/tests/Makefile.am
index d909942..b8ede30 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,6 +23,7 @@ auxdir2.test \
 cond17.test \
 dist-auxfile.test \
 dist-auxfile-2.test \
+dist-pr109765.test \
 gcj6.test \
 java-nobase.test \
 objext-pr10128.test \
diff --git a/tests/dist-pr109765.test b/tests/dist-pr109765.test
new file mode 100755
index 0000000..d656d56
--- /dev/null
+++ b/tests/dist-pr109765.test
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Expose automake bug#10975: when several "dist-*" targets are invoked
+# on the make command line, the first one ends up removing the distdir,
+# so that the latter ones fail.
+
+required=bzip2
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+: > Makefile.am
+
+$ACLOCAL  || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE || fatal_ "automake failed"
+
+./configure
+$MAKE dist-gzip dist-bzip2
+
+gzip -dc $distdir.tar.gz | tar tf - > one || { cat one; Exit 1; }
+cat one
+bzip2 -dc $distdir.tar.gz | tar tf - > two || { cat two; Exit 1; }
+cat two
+
+$FGREP "$distdir/Makefile.am" one
+diff one two
+
+:
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index 420b56b..023bf3b 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -332,6 +332,7 @@ dist-included-parent-dir.test \
 dist-missing-am.test \
 dist-missing-included-m4.test \
 dist-missing-m4.test \
+dist-pr109765.test \
 distcleancheck.test \
 distcom2.test \
 distcom3.test \
-- 
1.7.9