annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/config-3.8-x86_64-linux-gnu/install-sh @ 68:5028fdace37b

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