X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=config%2Finstall-sh;h=e4160c991dc958a11b89654e365c72a13639f6b2;hb=e3bd6e57b7544e9dd5bd560f369971b20c419671;hp=040ebc8866dfbc0acfcc2e25776c7c86a793459e;hpb=f70fab5a395c05a3653897acc8baf8d87031b4ee;p=gnulib.git diff --git a/config/install-sh b/config/install-sh index 040ebc886..e4160c991 100755 --- a/config/install-sh +++ b/config/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2004-01-12.10 +scriptversion=2004-04-01.17 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -214,7 +214,7 @@ do # Skip lots of stat calls in the usual case. if test ! -d "$dstdir"; then defaultIFS=' - ' + ' IFS="${IFS-$defaultIFS}" oIFS=$IFS @@ -228,7 +228,13 @@ do while test $# -ne 0 ; do pathcomp=$pathcomp$1 shift - test -d "$pathcomp" || $mkdirprog "$pathcomp" + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" || lasterr=$? + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; } + fi pathcomp=$pathcomp/ done fi @@ -274,26 +280,35 @@ do && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && - # Now remove or move aside any old file at destination location. We - # try this two ways since rm can't unlink itself on some systems and - # the destination file might be busy for other reasons. In this case, - # the final cleanup might fail but the new file should still install - # successfully. - { - if test -f "$dstdir/$dstfile"; then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ - || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ - || { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 - (exit 1); exit - } - else - : - fi - } && - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } fi || { (exit 1); exit; } done