Subject: Re: bug#11671: Bootstrap randomly fails on Hydra

From: Paul Eggert <[email-masked]>
Date: Tue, 12 Jun 2012 21:36:05 -0700

On 06/12/2012 01:14 PM, Ludovic Courtès wrote:
> ‘$top_srcdir/gnulib/build-aux’ was indeed
> r-xr-xr-x.

Can you please try to reproduce that problem with build-aux,
if only artificially, along with the following patch?

gnulib-tool: work even if repository is read-only
Problem reported by Ludovic Courtès in <http://bugs.gnu.org/11671>.
* gnulib-tool (func_cp): New function.
(func_lookup_file, func_add_or_update, top level): Use it.
diff --git a/gnulib-tool b/gnulib-tool
index 16f9b2f..f3d1ee6 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -699,6 +699,14 @@ func_relconcat ()
   done
 }

+# func_cp SRC DEST
+# Like cp SRC DEST, except that the destination is made writeable
+# if it is not already writeable.
+func_cp ()
+{
+  cp "$1" "$2" && { test -w "$2" || chmod u+w "$2"; }
+}
+
 # func_ln SRC DEST
 # Like ln -s, except that SRC is given relative to the current directory (or
 # absolute), not given relative to the directory of DEST.
@@ -1464,7 +1472,7 @@ func_lookup_file ()
       if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
         lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
         rm -f "$tmp/$lkbase"
-        cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
+        func_cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
         patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
           || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
         lookedup_file="$tmp/$lkbase"
@@ -4685,7 +4693,7 @@ s,^\(.................................................[^ ]*\) *,
     esac
     func_dest_tmpfilename "$g"
     func_lookup_file "$f"
-    cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
+    func_cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
     if test -n "$sed_transform_main_lib_file"; then
       case "$of" in
         lib/*)
@@ -6665,7 +6673,7 @@ s/\([.*$]\)/[\1]/g'
     fi
     # Copy the file.
     func_dest_tmpfilename "$g"
-    cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
+    func_cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
     already_present=true
     if test -f "$destdir/$g"; then
       # The file already exists.