annotate src/fftw-3.3.5/install-sh @ 169:223a55898ab9 tip default

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