annotate src/fftw-3.3.5/install-sh @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 2cd0e3b3e1fd
children
rev   line source
Chris@42 1 #!/bin/sh
Chris@42 2 # install - install a program, script, or datafile
Chris@42 3
Chris@42 4 scriptversion=2011-11-20.07; # UTC
Chris@42 5
Chris@42 6 # This originates from X11R5 (mit/util/scripts/install.sh), which was
Chris@42 7 # later released in X11R6 (xc/config/util/install.sh) with the
Chris@42 8 # following copyright and license.
Chris@42 9 #
Chris@42 10 # Copyright (C) 1994 X Consortium
Chris@42 11 #
Chris@42 12 # Permission is hereby granted, free of charge, to any person obtaining a copy
Chris@42 13 # of this software and associated documentation files (the "Software"), to
Chris@42 14 # deal in the Software without restriction, including without limitation the
Chris@42 15 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
Chris@42 16 # sell copies of the Software, and to permit persons to whom the Software is
Chris@42 17 # furnished to do so, subject to the following conditions:
Chris@42 18 #
Chris@42 19 # The above copyright notice and this permission notice shall be included in
Chris@42 20 # all copies or substantial portions of the Software.
Chris@42 21 #
Chris@42 22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Chris@42 23 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Chris@42 24 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Chris@42 25 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Chris@42 26 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
Chris@42 27 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@42 28 #
Chris@42 29 # Except as contained in this notice, the name of the X Consortium shall not
Chris@42 30 # be used in advertising or otherwise to promote the sale, use or other deal-
Chris@42 31 # ings in this Software without prior written authorization from the X Consor-
Chris@42 32 # tium.
Chris@42 33 #
Chris@42 34 #
Chris@42 35 # FSF changes to this file are in the public domain.
Chris@42 36 #
Chris@42 37 # Calling this script install-sh is preferred over install.sh, to prevent
Chris@42 38 # 'make' implicit rules from creating a file called install from it
Chris@42 39 # when there is no Makefile.
Chris@42 40 #
Chris@42 41 # This script is compatible with the BSD install script, but was written
Chris@42 42 # from scratch.
Chris@42 43
Chris@42 44 nl='
Chris@42 45 '
Chris@42 46 IFS=" "" $nl"
Chris@42 47
Chris@42 48 # set DOITPROG to echo to test this script
Chris@42 49
Chris@42 50 # Don't use :- since 4.3BSD and earlier shells don't like it.
Chris@42 51 doit=${DOITPROG-}
Chris@42 52 if test -z "$doit"; then
Chris@42 53 doit_exec=exec
Chris@42 54 else
Chris@42 55 doit_exec=$doit
Chris@42 56 fi
Chris@42 57
Chris@42 58 # Put in absolute file names if you don't have them in your path;
Chris@42 59 # or use environment vars.
Chris@42 60
Chris@42 61 chgrpprog=${CHGRPPROG-chgrp}
Chris@42 62 chmodprog=${CHMODPROG-chmod}
Chris@42 63 chownprog=${CHOWNPROG-chown}
Chris@42 64 cmpprog=${CMPPROG-cmp}
Chris@42 65 cpprog=${CPPROG-cp}
Chris@42 66 mkdirprog=${MKDIRPROG-mkdir}
Chris@42 67 mvprog=${MVPROG-mv}
Chris@42 68 rmprog=${RMPROG-rm}
Chris@42 69 stripprog=${STRIPPROG-strip}
Chris@42 70
Chris@42 71 posix_glob='?'
Chris@42 72 initialize_posix_glob='
Chris@42 73 test "$posix_glob" != "?" || {
Chris@42 74 if (set -f) 2>/dev/null; then
Chris@42 75 posix_glob=
Chris@42 76 else
Chris@42 77 posix_glob=:
Chris@42 78 fi
Chris@42 79 }
Chris@42 80 '
Chris@42 81
Chris@42 82 posix_mkdir=
Chris@42 83
Chris@42 84 # Desired mode of installed file.
Chris@42 85 mode=0755
Chris@42 86
Chris@42 87 chgrpcmd=
Chris@42 88 chmodcmd=$chmodprog
Chris@42 89 chowncmd=
Chris@42 90 mvcmd=$mvprog
Chris@42 91 rmcmd="$rmprog -f"
Chris@42 92 stripcmd=
Chris@42 93
Chris@42 94 src=
Chris@42 95 dst=
Chris@42 96 dir_arg=
Chris@42 97 dst_arg=
Chris@42 98
Chris@42 99 copy_on_change=false
Chris@42 100 no_target_directory=
Chris@42 101
Chris@42 102 usage="\
Chris@42 103 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
Chris@42 104 or: $0 [OPTION]... SRCFILES... DIRECTORY
Chris@42 105 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
Chris@42 106 or: $0 [OPTION]... -d DIRECTORIES...
Chris@42 107
Chris@42 108 In the 1st form, copy SRCFILE to DSTFILE.
Chris@42 109 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
Chris@42 110 In the 4th, create DIRECTORIES.
Chris@42 111
Chris@42 112 Options:
Chris@42 113 --help display this help and exit.
Chris@42 114 --version display version info and exit.
Chris@42 115
Chris@42 116 -c (ignored)
Chris@42 117 -C install only if different (preserve the last data modification time)
Chris@42 118 -d create directories instead of installing files.
Chris@42 119 -g GROUP $chgrpprog installed files to GROUP.
Chris@42 120 -m MODE $chmodprog installed files to MODE.
Chris@42 121 -o USER $chownprog installed files to USER.
Chris@42 122 -s $stripprog installed files.
Chris@42 123 -t DIRECTORY install into DIRECTORY.
Chris@42 124 -T report an error if DSTFILE is a directory.
Chris@42 125
Chris@42 126 Environment variables override the default commands:
Chris@42 127 CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
Chris@42 128 RMPROG STRIPPROG
Chris@42 129 "
Chris@42 130
Chris@42 131 while test $# -ne 0; do
Chris@42 132 case $1 in
Chris@42 133 -c) ;;
Chris@42 134
Chris@42 135 -C) copy_on_change=true;;
Chris@42 136
Chris@42 137 -d) dir_arg=true;;
Chris@42 138
Chris@42 139 -g) chgrpcmd="$chgrpprog $2"
Chris@42 140 shift;;
Chris@42 141
Chris@42 142 --help) echo "$usage"; exit $?;;
Chris@42 143
Chris@42 144 -m) mode=$2
Chris@42 145 case $mode in
Chris@42 146 *' '* | *' '* | *'
Chris@42 147 '* | *'*'* | *'?'* | *'['*)
Chris@42 148 echo "$0: invalid mode: $mode" >&2
Chris@42 149 exit 1;;
Chris@42 150 esac
Chris@42 151 shift;;
Chris@42 152
Chris@42 153 -o) chowncmd="$chownprog $2"
Chris@42 154 shift;;
Chris@42 155
Chris@42 156 -s) stripcmd=$stripprog;;
Chris@42 157
Chris@42 158 -t) dst_arg=$2
Chris@42 159 # Protect names problematic for 'test' and other utilities.
Chris@42 160 case $dst_arg in
Chris@42 161 -* | [=\(\)!]) dst_arg=./$dst_arg;;
Chris@42 162 esac
Chris@42 163 shift;;
Chris@42 164
Chris@42 165 -T) no_target_directory=true;;
Chris@42 166
Chris@42 167 --version) echo "$0 $scriptversion"; exit $?;;
Chris@42 168
Chris@42 169 --) shift
Chris@42 170 break;;
Chris@42 171
Chris@42 172 -*) echo "$0: invalid option: $1" >&2
Chris@42 173 exit 1;;
Chris@42 174
Chris@42 175 *) break;;
Chris@42 176 esac
Chris@42 177 shift
Chris@42 178 done
Chris@42 179
Chris@42 180 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
Chris@42 181 # When -d is used, all remaining arguments are directories to create.
Chris@42 182 # When -t is used, the destination is already specified.
Chris@42 183 # Otherwise, the last argument is the destination. Remove it from $@.
Chris@42 184 for arg
Chris@42 185 do
Chris@42 186 if test -n "$dst_arg"; then
Chris@42 187 # $@ is not empty: it contains at least $arg.
Chris@42 188 set fnord "$@" "$dst_arg"
Chris@42 189 shift # fnord
Chris@42 190 fi
Chris@42 191 shift # arg
Chris@42 192 dst_arg=$arg
Chris@42 193 # Protect names problematic for 'test' and other utilities.
Chris@42 194 case $dst_arg in
Chris@42 195 -* | [=\(\)!]) dst_arg=./$dst_arg;;
Chris@42 196 esac
Chris@42 197 done
Chris@42 198 fi
Chris@42 199
Chris@42 200 if test $# -eq 0; then
Chris@42 201 if test -z "$dir_arg"; then
Chris@42 202 echo "$0: no input file specified." >&2
Chris@42 203 exit 1
Chris@42 204 fi
Chris@42 205 # It's OK to call 'install-sh -d' without argument.
Chris@42 206 # This can happen when creating conditional directories.
Chris@42 207 exit 0
Chris@42 208 fi
Chris@42 209
Chris@42 210 if test -z "$dir_arg"; then
Chris@42 211 do_exit='(exit $ret); exit $ret'
Chris@42 212 trap "ret=129; $do_exit" 1
Chris@42 213 trap "ret=130; $do_exit" 2
Chris@42 214 trap "ret=141; $do_exit" 13
Chris@42 215 trap "ret=143; $do_exit" 15
Chris@42 216
Chris@42 217 # Set umask so as not to create temps with too-generous modes.
Chris@42 218 # However, 'strip' requires both read and write access to temps.
Chris@42 219 case $mode in
Chris@42 220 # Optimize common cases.
Chris@42 221 *644) cp_umask=133;;
Chris@42 222 *755) cp_umask=22;;
Chris@42 223
Chris@42 224 *[0-7])
Chris@42 225 if test -z "$stripcmd"; then
Chris@42 226 u_plus_rw=
Chris@42 227 else
Chris@42 228 u_plus_rw='% 200'
Chris@42 229 fi
Chris@42 230 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
Chris@42 231 *)
Chris@42 232 if test -z "$stripcmd"; then
Chris@42 233 u_plus_rw=
Chris@42 234 else
Chris@42 235 u_plus_rw=,u+rw
Chris@42 236 fi
Chris@42 237 cp_umask=$mode$u_plus_rw;;
Chris@42 238 esac
Chris@42 239 fi
Chris@42 240
Chris@42 241 for src
Chris@42 242 do
Chris@42 243 # Protect names problematic for 'test' and other utilities.
Chris@42 244 case $src in
Chris@42 245 -* | [=\(\)!]) src=./$src;;
Chris@42 246 esac
Chris@42 247
Chris@42 248 if test -n "$dir_arg"; then
Chris@42 249 dst=$src
Chris@42 250 dstdir=$dst
Chris@42 251 test -d "$dstdir"
Chris@42 252 dstdir_status=$?
Chris@42 253 else
Chris@42 254
Chris@42 255 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
Chris@42 256 # might cause directories to be created, which would be especially bad
Chris@42 257 # if $src (and thus $dsttmp) contains '*'.
Chris@42 258 if test ! -f "$src" && test ! -d "$src"; then
Chris@42 259 echo "$0: $src does not exist." >&2
Chris@42 260 exit 1
Chris@42 261 fi
Chris@42 262
Chris@42 263 if test -z "$dst_arg"; then
Chris@42 264 echo "$0: no destination specified." >&2
Chris@42 265 exit 1
Chris@42 266 fi
Chris@42 267 dst=$dst_arg
Chris@42 268
Chris@42 269 # If destination is a directory, append the input filename; won't work
Chris@42 270 # if double slashes aren't ignored.
Chris@42 271 if test -d "$dst"; then
Chris@42 272 if test -n "$no_target_directory"; then
Chris@42 273 echo "$0: $dst_arg: Is a directory" >&2
Chris@42 274 exit 1
Chris@42 275 fi
Chris@42 276 dstdir=$dst
Chris@42 277 dst=$dstdir/`basename "$src"`
Chris@42 278 dstdir_status=0
Chris@42 279 else
Chris@42 280 # Prefer dirname, but fall back on a substitute if dirname fails.
Chris@42 281 dstdir=`
Chris@42 282 (dirname "$dst") 2>/dev/null ||
Chris@42 283 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
Chris@42 284 X"$dst" : 'X\(//\)[^/]' \| \
Chris@42 285 X"$dst" : 'X\(//\)$' \| \
Chris@42 286 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
Chris@42 287 echo X"$dst" |
Chris@42 288 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
Chris@42 289 s//\1/
Chris@42 290 q
Chris@42 291 }
Chris@42 292 /^X\(\/\/\)[^/].*/{
Chris@42 293 s//\1/
Chris@42 294 q
Chris@42 295 }
Chris@42 296 /^X\(\/\/\)$/{
Chris@42 297 s//\1/
Chris@42 298 q
Chris@42 299 }
Chris@42 300 /^X\(\/\).*/{
Chris@42 301 s//\1/
Chris@42 302 q
Chris@42 303 }
Chris@42 304 s/.*/./; q'
Chris@42 305 `
Chris@42 306
Chris@42 307 test -d "$dstdir"
Chris@42 308 dstdir_status=$?
Chris@42 309 fi
Chris@42 310 fi
Chris@42 311
Chris@42 312 obsolete_mkdir_used=false
Chris@42 313
Chris@42 314 if test $dstdir_status != 0; then
Chris@42 315 case $posix_mkdir in
Chris@42 316 '')
Chris@42 317 # Create intermediate dirs using mode 755 as modified by the umask.
Chris@42 318 # This is like FreeBSD 'install' as of 1997-10-28.
Chris@42 319 umask=`umask`
Chris@42 320 case $stripcmd.$umask in
Chris@42 321 # Optimize common cases.
Chris@42 322 *[2367][2367]) mkdir_umask=$umask;;
Chris@42 323 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
Chris@42 324
Chris@42 325 *[0-7])
Chris@42 326 mkdir_umask=`expr $umask + 22 \
Chris@42 327 - $umask % 100 % 40 + $umask % 20 \
Chris@42 328 - $umask % 10 % 4 + $umask % 2
Chris@42 329 `;;
Chris@42 330 *) mkdir_umask=$umask,go-w;;
Chris@42 331 esac
Chris@42 332
Chris@42 333 # With -d, create the new directory with the user-specified mode.
Chris@42 334 # Otherwise, rely on $mkdir_umask.
Chris@42 335 if test -n "$dir_arg"; then
Chris@42 336 mkdir_mode=-m$mode
Chris@42 337 else
Chris@42 338 mkdir_mode=
Chris@42 339 fi
Chris@42 340
Chris@42 341 posix_mkdir=false
Chris@42 342 case $umask in
Chris@42 343 *[123567][0-7][0-7])
Chris@42 344 # POSIX mkdir -p sets u+wx bits regardless of umask, which
Chris@42 345 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
Chris@42 346 ;;
Chris@42 347 *)
Chris@42 348 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
Chris@42 349 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
Chris@42 350
Chris@42 351 if (umask $mkdir_umask &&
Chris@42 352 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
Chris@42 353 then
Chris@42 354 if test -z "$dir_arg" || {
Chris@42 355 # Check for POSIX incompatibilities with -m.
Chris@42 356 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
Chris@42 357 # other-writable bit of parent directory when it shouldn't.
Chris@42 358 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
Chris@42 359 ls_ld_tmpdir=`ls -ld "$tmpdir"`
Chris@42 360 case $ls_ld_tmpdir in
Chris@42 361 d????-?r-*) different_mode=700;;
Chris@42 362 d????-?--*) different_mode=755;;
Chris@42 363 *) false;;
Chris@42 364 esac &&
Chris@42 365 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
Chris@42 366 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
Chris@42 367 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
Chris@42 368 }
Chris@42 369 }
Chris@42 370 then posix_mkdir=:
Chris@42 371 fi
Chris@42 372 rmdir "$tmpdir/d" "$tmpdir"
Chris@42 373 else
Chris@42 374 # Remove any dirs left behind by ancient mkdir implementations.
Chris@42 375 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
Chris@42 376 fi
Chris@42 377 trap '' 0;;
Chris@42 378 esac;;
Chris@42 379 esac
Chris@42 380
Chris@42 381 if
Chris@42 382 $posix_mkdir && (
Chris@42 383 umask $mkdir_umask &&
Chris@42 384 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
Chris@42 385 )
Chris@42 386 then :
Chris@42 387 else
Chris@42 388
Chris@42 389 # The umask is ridiculous, or mkdir does not conform to POSIX,
Chris@42 390 # or it failed possibly due to a race condition. Create the
Chris@42 391 # directory the slow way, step by step, checking for races as we go.
Chris@42 392
Chris@42 393 case $dstdir in
Chris@42 394 /*) prefix='/';;
Chris@42 395 [-=\(\)!]*) prefix='./';;
Chris@42 396 *) prefix='';;
Chris@42 397 esac
Chris@42 398
Chris@42 399 eval "$initialize_posix_glob"
Chris@42 400
Chris@42 401 oIFS=$IFS
Chris@42 402 IFS=/
Chris@42 403 $posix_glob set -f
Chris@42 404 set fnord $dstdir
Chris@42 405 shift
Chris@42 406 $posix_glob set +f
Chris@42 407 IFS=$oIFS
Chris@42 408
Chris@42 409 prefixes=
Chris@42 410
Chris@42 411 for d
Chris@42 412 do
Chris@42 413 test X"$d" = X && continue
Chris@42 414
Chris@42 415 prefix=$prefix$d
Chris@42 416 if test -d "$prefix"; then
Chris@42 417 prefixes=
Chris@42 418 else
Chris@42 419 if $posix_mkdir; then
Chris@42 420 (umask=$mkdir_umask &&
Chris@42 421 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
Chris@42 422 # Don't fail if two instances are running concurrently.
Chris@42 423 test -d "$prefix" || exit 1
Chris@42 424 else
Chris@42 425 case $prefix in
Chris@42 426 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
Chris@42 427 *) qprefix=$prefix;;
Chris@42 428 esac
Chris@42 429 prefixes="$prefixes '$qprefix'"
Chris@42 430 fi
Chris@42 431 fi
Chris@42 432 prefix=$prefix/
Chris@42 433 done
Chris@42 434
Chris@42 435 if test -n "$prefixes"; then
Chris@42 436 # Don't fail if two instances are running concurrently.
Chris@42 437 (umask $mkdir_umask &&
Chris@42 438 eval "\$doit_exec \$mkdirprog $prefixes") ||
Chris@42 439 test -d "$dstdir" || exit 1
Chris@42 440 obsolete_mkdir_used=true
Chris@42 441 fi
Chris@42 442 fi
Chris@42 443 fi
Chris@42 444
Chris@42 445 if test -n "$dir_arg"; then
Chris@42 446 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
Chris@42 447 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
Chris@42 448 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
Chris@42 449 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
Chris@42 450 else
Chris@42 451
Chris@42 452 # Make a couple of temp file names in the proper directory.
Chris@42 453 dsttmp=$dstdir/_inst.$$_
Chris@42 454 rmtmp=$dstdir/_rm.$$_
Chris@42 455
Chris@42 456 # Trap to clean up those temp files at exit.
Chris@42 457 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
Chris@42 458
Chris@42 459 # Copy the file name to the temp name.
Chris@42 460 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
Chris@42 461
Chris@42 462 # and set any options; do chmod last to preserve setuid bits.
Chris@42 463 #
Chris@42 464 # If any of these fail, we abort the whole thing. If we want to
Chris@42 465 # ignore errors from any of these, just make sure not to ignore
Chris@42 466 # errors from the above "$doit $cpprog $src $dsttmp" command.
Chris@42 467 #
Chris@42 468 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
Chris@42 469 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
Chris@42 470 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
Chris@42 471 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
Chris@42 472
Chris@42 473 # If -C, don't bother to copy if it wouldn't change the file.
Chris@42 474 if $copy_on_change &&
Chris@42 475 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
Chris@42 476 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
Chris@42 477
Chris@42 478 eval "$initialize_posix_glob" &&
Chris@42 479 $posix_glob set -f &&
Chris@42 480 set X $old && old=:$2:$4:$5:$6 &&
Chris@42 481 set X $new && new=:$2:$4:$5:$6 &&
Chris@42 482 $posix_glob set +f &&
Chris@42 483
Chris@42 484 test "$old" = "$new" &&
Chris@42 485 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
Chris@42 486 then
Chris@42 487 rm -f "$dsttmp"
Chris@42 488 else
Chris@42 489 # Rename the file to the real destination.
Chris@42 490 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
Chris@42 491
Chris@42 492 # The rename failed, perhaps because mv can't rename something else
Chris@42 493 # to itself, or perhaps because mv is so ancient that it does not
Chris@42 494 # support -f.
Chris@42 495 {
Chris@42 496 # Now remove or move aside any old file at destination location.
Chris@42 497 # We try this two ways since rm can't unlink itself on some
Chris@42 498 # systems and the destination file might be busy for other
Chris@42 499 # reasons. In this case, the final cleanup might fail but the new
Chris@42 500 # file should still install successfully.
Chris@42 501 {
Chris@42 502 test ! -f "$dst" ||
Chris@42 503 $doit $rmcmd -f "$dst" 2>/dev/null ||
Chris@42 504 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
Chris@42 505 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
Chris@42 506 } ||
Chris@42 507 { echo "$0: cannot unlink or rename $dst" >&2
Chris@42 508 (exit 1); exit 1
Chris@42 509 }
Chris@42 510 } &&
Chris@42 511
Chris@42 512 # Now rename the file to the real destination.
Chris@42 513 $doit $mvcmd "$dsttmp" "$dst"
Chris@42 514 }
Chris@42 515 fi || exit 1
Chris@42 516
Chris@42 517 trap '' 0
Chris@42 518 fi
Chris@42 519 done
Chris@42 520
Chris@42 521 # Local variables:
Chris@42 522 # eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@42 523 # time-stamp-start: "scriptversion="
Chris@42 524 # time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@42 525 # time-stamp-time-zone: "UTC"
Chris@42 526 # time-stamp-end: "; # UTC"
Chris@42 527 # End: