annotate src/portaudio_20161030_catalina_patch/install-sh @ 162:d43aab368df9

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