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