annotate src/fftw-3.3.3/install-sh @ 23:619f715526df sv_v2.1

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