annotate fft/fftw/fftw-3.3.4/install-sh @ 40:223f770b5341 kissfft-double tip

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