]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
install-sh: support -s with read-only source
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 26 Aug 2019 01:51:26 +0000 (18:51 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 26 Aug 2019 21:45:03 +0000 (14:45 -0700)
Problem reported by Karl Berry in:
https://lists.gnu.org/r/bug-gnulib/2019-08/msg00067.html
* lib/install-sh: If -s is given, create the temporary file
with $cp_umask so that ‘strip’ can write to it.

lib/install-sh

index 8175c640fe6288a75cc846567ea5506086f326f4..20d8b2eaea9c7e1a9a83cbae1b770ab021fe114c 100755 (executable)
@@ -451,7 +451,18 @@ do
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
 
     # Copy the file name to the temp name.
-    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+    (umask $cp_umask &&
+     { test -z "$stripcmd" || {
+        # Create $dsttmp read-write so that cp doesn't create it read-only,
+        # which would cause strip to fail.
+        if test -z "$doit"; then
+          : >"$dsttmp" # No need to fork-exec 'touch'.
+        else
+          $doit touch "$dsttmp"
+        fi
+       }
+     } &&
+     $doit_exec $cpprog "$src" "$dsttmp") &&
 
     # and set any options; do chmod last to preserve setuid bits.
     #