File indexing completed on 2019-12-21 01:47:34
ce830a9c1… Alex*0001
d7d4fdf89… Alex*0002
5c0dde779… Alex*0003
f6a1b37d1… Alex*0004 scriptversion=2018-03-11.20;
5c0dde779… Alex*0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
ce830a9c1… Alex*0021
5c0dde779… Alex*0022
0023
0024
0025
0026
0027
ce830a9c1… Alex*0028
5c0dde779… Alex*0029
0030
0031
0032
0033
0034
0035
d7d4fdf89… Alex*0036
0037
2808ba210… Alex*0038
d7d4fdf89… Alex*0039
0040
0041
2808ba210… Alex*0042
0043
f6a1b37d1… Alex*0044 tab=' '
2808ba210… Alex*0045 nl='
0046 '
f6a1b37d1… Alex*0047 IFS=" $tab$nl"
d7d4fdf89… Alex*0048
f6a1b37d1… Alex*0049
d7d4fdf89… Alex*0050
2808ba210… Alex*0051 doit=${DOITPROG-}
f6a1b37d1… Alex*0052 doit_exec=${doit:-exec}
d7d4fdf89… Alex*0053
2808ba210… Alex*0054
0055
0056
0057 chgrpprog=${CHGRPPROG-chgrp}
0058 chmodprog=${CHMODPROG-chmod}
0059 chownprog=${CHOWNPROG-chown}
0060 cmpprog=${CMPPROG-cmp}
0061 cpprog=${CPPROG-cp}
0062 mkdirprog=${MKDIRPROG-mkdir}
0063 mvprog=${MVPROG-mv}
0064 rmprog=${RMPROG-rm}
0065 stripprog=${STRIPPROG-strip}
0066
0067 posix_mkdir=
0068
0069
0070 mode=0755
d7d4fdf89… Alex*0071
5c0dde779… Alex*0072 chgrpcmd=
2808ba210… Alex*0073 chmodcmd=$chmodprog
0074 chowncmd=
0075 mvcmd=$mvprog
d7d4fdf89… Alex*0076 rmcmd="$rmprog -f"
2808ba210… Alex*0077 stripcmd=
0078
5c0dde779… Alex*0079 src=
0080 dst=
0081 dir_arg=
2808ba210… Alex*0082 dst_arg=
0083
0084 copy_on_change=false
f6a1b37d1… Alex*0085 is_target_a_directory=possibly
5c0dde779… Alex*0086
2808ba210… Alex*0087 usage="\
0088 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
5c0dde779… Alex*0089 or: $0 [OPTION]... SRCFILES... DIRECTORY
0090 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
0091 or: $0 [OPTION]... -d DIRECTORIES...
0092
0093 In the 1st form, copy SRCFILE to DSTFILE.
0094 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
0095 In the 4th, create DIRECTORIES.
0096
0097 Options:
2808ba210… Alex*0098 --help display this help and exit.
0099 --version display version info and exit.
0100
0101 -c (ignored)
0102 -C install only if different (preserve the last data modification time)
0103 -d create directories instead of installing files.
0104 -g GROUP $chgrpprog installed files to GROUP.
0105 -m MODE $chmodprog installed files to MODE.
0106 -o USER $chownprog installed files to USER.
0107 -s $stripprog installed files.
0108 -t DIRECTORY install into DIRECTORY.
0109 -T report an error if DSTFILE is a directory.
5c0dde779… Alex*0110
0111 Environment variables override the default commands:
2808ba210… Alex*0112 CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
0113 RMPROG STRIPPROG
5c0dde779… Alex*0114 "
0115
2808ba210… Alex*0116 while test $
5c0dde779… Alex*0117 case $1 in
2808ba210… Alex*0118 -c) ;;
0119
0120 -C) copy_on_change=true;;
5c0dde779… Alex*0121
2808ba210… Alex*0122 -d) dir_arg=true;;
5c0dde779… Alex*0123
0124 -g) chgrpcmd="$chgrpprog $2"
f6a1b37d1… Alex*0125 shift;;
5c0dde779… Alex*0126
0127 --help) echo "$usage"; exit $?;;
0128
2808ba210… Alex*0129 -m) mode=$2
f6a1b37d1… Alex*0130 case $mode in
0131 *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
0132 echo "$0: invalid mode: $mode" >&2
0133 exit 1;;
0134 esac
0135 shift;;
5c0dde779… Alex*0136
0137 -o) chowncmd="$chownprog $2"
f6a1b37d1… Alex*0138 shift;;
5c0dde779… Alex*0139
2808ba210… Alex*0140 -s) stripcmd=$stripprog;;
5c0dde779… Alex*0141
f6a1b37d1… Alex*0142 -t)
0143 is_target_a_directory=always
0144 dst_arg=$2
0145
0146 case $dst_arg in
0147 -* | [=\(\)!]) dst_arg=./$dst_arg;;
0148 esac
0149 shift;;
d7d4fdf89… Alex*0150
f6a1b37d1… Alex*0151 -T) is_target_a_directory=never;;
5c0dde779… Alex*0152
0153 --version) echo "$0 $scriptversion"; exit $?;;
0154
f6a1b37d1… Alex*0155 --) shift
0156 break;;
2808ba210… Alex*0157
f6a1b37d1… Alex*0158 -*) echo "$0: invalid option: $1" >&2
0159 exit 1;;
2808ba210… Alex*0160
0161 *) break;;
5c0dde779… Alex*0162 esac
2808ba210… Alex*0163 shift
d7d4fdf89… Alex*0164 done
0165
f6a1b37d1… Alex*0166
0167
0168
0169 if test -n "$dir_arg"; then
0170 if test -n "$dst_arg"; then
0171 echo "$0: target directory not allowed when installing a directory." >&2
0172 exit 1
0173 fi
0174 fi
0175
2808ba210… Alex*0176 if test $
0177
0178
0179
0180 for arg
0181 do
0182 if test -n "$dst_arg"; then
0183
0184 set fnord "$@" "$dst_arg"
0185 shift
0186 fi
0187 shift
0188 dst_arg=$arg
0189
0190 case $dst_arg in
0191 -* | [=\(\)!]) dst_arg=./$dst_arg;;
0192 esac
0193 done
0194 fi
0195
0196 if test $
5c0dde779… Alex*0197 if test -z "$dir_arg"; then
0198 echo "$0: no input file specified." >&2
0199 exit 1
0200 fi
2808ba210… Alex*0201
5c0dde779… Alex*0202
0203 exit 0
0204 fi
d7d4fdf89… Alex*0205
f6a1b37d1… Alex*0206 if test -z "$dir_arg"; then
0207 if test $
0208 if test ! -d "$dst_arg"; then
0209 echo "$0: $dst_arg: Is not a directory." >&2
0210 exit 1
0211 fi
0212 fi
0213 fi
0214
2808ba210… Alex*0215 if test -z "$dir_arg"; then
0216 do_exit='(exit $ret); exit $ret'
0217 trap "ret=129; $do_exit" 1
0218 trap "ret=130; $do_exit" 2
0219 trap "ret=141; $do_exit" 13
0220 trap "ret=143; $do_exit" 15
0221
0222
0223
0224 case $mode in
0225
0226 *644) cp_umask=133;;
0227 *755) cp_umask=22;;
0228
0229 *[0-7])
0230 if test -z "$stripcmd"; then
f6a1b37d1… Alex*0231 u_plus_rw=
2808ba210… Alex*0232 else
f6a1b37d1… Alex*0233 u_plus_rw='% 200'
2808ba210… Alex*0234 fi
0235 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
0236 *)
0237 if test -z "$stripcmd"; then
f6a1b37d1… Alex*0238 u_plus_rw=
2808ba210… Alex*0239 else
f6a1b37d1… Alex*0240 u_plus_rw=,u+rw
2808ba210… Alex*0241 fi
0242 cp_umask=$mode$u_plus_rw;;
0243 esac
0244 fi
0245
5c0dde779… Alex*0246 for src
0247 do
2808ba210… Alex*0248
5c0dde779… Alex*0249 case $src in
2808ba210… Alex*0250 -* | [=\(\)!]) src=./$src;;
5c0dde779… Alex*0251 esac
0252
0253 if test -n "$dir_arg"; then
0254 dst=$src
2808ba210… Alex*0255 dstdir=$dst
0256 test -d "$dstdir"
0257 dstdir_status=$?
5c0dde779… Alex*0258 else
2808ba210… Alex*0259
5c0dde779… Alex*0260
0261
0262
0263 if test ! -f "$src" && test ! -d "$src"; then
0264 echo "$0: $src does not exist." >&2
0265 exit 1
0266 fi
0267
2808ba210… Alex*0268 if test -z "$dst_arg"; then
5c0dde779… Alex*0269 echo "$0: no destination specified." >&2
0270 exit 1
0271 fi
2808ba210… Alex*0272 dst=$dst_arg
d7d4fdf89… Alex*0273
f6a1b37d1… Alex*0274
5c0dde779… Alex*0275 if test -d "$dst"; then
f6a1b37d1… Alex*0276 if test "$is_target_a_directory" = never; then
0277 echo "$0: $dst_arg: Is a directory" >&2
0278 exit 1
5c0dde779… Alex*0279 fi
2808ba210… Alex*0280 dstdir=$dst
f6a1b37d1… Alex*0281 dstbase=`basename "$src"`
0282 case $dst in
0283 */) dst=$dst$dstbase;;
0284 *) dst=$dst/$dstbase;;
0285 esac
2808ba210… Alex*0286 dstdir_status=0
0287 else
f6a1b37d1… Alex*0288 dstdir=`dirname "$dst"`
2808ba210… Alex*0289 test -d "$dstdir"
0290 dstdir_status=$?
5c0dde779… Alex*0291 fi
0292 fi
0293
f6a1b37d1… Alex*0294 case $dstdir in
0295 */) dstdirslash=$dstdir;;
0296 *) dstdirslash=$dstdir/;;
0297 esac
0298
2808ba210… Alex*0299 obsolete_mkdir_used=false
0300
0301 if test $dstdir_status != 0; then
0302 case $posix_mkdir in
0303 '')
f6a1b37d1… Alex*0304
0305
0306 umask=`umask`
0307 case $stripcmd.$umask in
0308
0309 *[2367][2367]) mkdir_umask=$umask;;
0310 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
0311
0312 *[0-7])
0313 mkdir_umask=`expr $umask + 22 \
0314 - $umask % 100 % 40 + $umask % 20 \
0315 - $umask % 10 % 4 + $umask % 2
0316 `;;
0317 *) mkdir_umask=$umask,go-w;;
0318 esac
0319
0320
0321
0322 if test -n "$dir_arg"; then
0323 mkdir_mode=-m$mode
0324 else
0325 mkdir_mode=
0326 fi
0327
0328 posix_mkdir=false
0329 case $umask in
0330 *[123567][0-7][0-7])
0331
0332
0333 ;;
0334 *)
0335
0336
0337 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
0338
0339 trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
0340
0341
0342
0343
0344
0345 if (umask $mkdir_umask &&
0346 $mkdirprog $mkdir_mode "$tmpdir" &&
0347 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
0348 then
0349 if test -z "$dir_arg" || {
0350
0351
0352
0353
0354 test_tmpdir="$tmpdir/a"
0355 ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
0356 case $ls_ld_tmpdir in
0357 d????-?r-*) different_mode=700;;
0358 d????-?--*) different_mode=755;;
0359 *) false;;
0360 esac &&
0361 $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
0362 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
0363 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
0364 }
0365 }
0366 then posix_mkdir=:
0367 fi
0368 rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
0369 else
0370
0371 rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
0372 fi
0373 trap '' 0;;
0374 esac;;
2808ba210… Alex*0375 esac
5c0dde779… Alex*0376
2808ba210… Alex*0377 if
0378 $posix_mkdir && (
f6a1b37d1… Alex*0379 umask $mkdir_umask &&
0380 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
2808ba210… Alex*0381 )
0382 then :
0383 else
5c0dde779… Alex*0384
2808ba210… Alex*0385
0386
0387
5c0dde779… Alex*0388
2808ba210… Alex*0389 case $dstdir in
f6a1b37d1… Alex*0390 /*) prefix='/';;
0391 [-=\(\)!]*) prefix='./';;
0392 *) prefix='';;
2808ba210… Alex*0393 esac
5c0dde779… Alex*0394
2808ba210… Alex*0395 oIFS=$IFS
0396 IFS=/
f6a1b37d1… Alex*0397 set -f
2808ba210… Alex*0398 set fnord $dstdir
5c0dde779… Alex*0399 shift
f6a1b37d1… Alex*0400 set +f
2808ba210… Alex*0401 IFS=$oIFS
0402
0403 prefixes=
0404
0405 for d
0406 do
f6a1b37d1… Alex*0407 test X"$d" = X && continue
0408
0409 prefix=$prefix$d
0410 if test -d "$prefix"; then
0411 prefixes=
0412 else
0413 if $posix_mkdir; then
0414 (umask=$mkdir_umask &&
0415 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
0416
0417 test -d "$prefix" || exit 1
0418 else
0419 case $prefix in
0420 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
0421 *) qprefix=$prefix;;
0422 esac
0423 prefixes="$prefixes '$qprefix'"
0424 fi
0425 fi
0426 prefix=$prefix/
2808ba210… Alex*0427 done
0428
0429 if test -n "$prefixes"; then
f6a1b37d1… Alex*0430
0431 (umask $mkdir_umask &&
0432 eval "\$doit_exec \$mkdirprog $prefixes") ||
0433 test -d "$dstdir" || exit 1
0434 obsolete_mkdir_used=true
5c0dde779… Alex*0435 fi
2808ba210… Alex*0436 fi
5c0dde779… Alex*0437 fi
0438
0439 if test -n "$dir_arg"; then
2808ba210… Alex*0440 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
0441 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
0442 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
0443 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
5c0dde779… Alex*0444 else
0445
0446
f6a1b37d1… Alex*0447 dsttmp=${dstdirslash}_inst.$$_
0448 rmtmp=${dstdirslash}_rm.$$_
5c0dde779… Alex*0449
0450
0451 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
0452
0453
2808ba210… Alex*0454 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
5c0dde779… Alex*0455
0456
0457
0458
0459
0460
0461
2808ba210… Alex*0462 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
0463 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
0464 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
0465 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
0466
0467
0468 if $copy_on_change &&
f6a1b37d1… Alex*0469 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
0470 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
0471 set -f &&
2808ba210… Alex*0472 set X $old && old=:$2:$4:$5:$6 &&
0473 set X $new && new=:$2:$4:$5:$6 &&
f6a1b37d1… Alex*0474 set +f &&
2808ba210… Alex*0475 test "$old" = "$new" &&
0476 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
0477 then
0478 rm -f "$dsttmp"
0479 else
0480
0481 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
0482
0483
0484
0485
0486 {
f6a1b37d1… Alex*0487
0488
0489
0490
0491
0492 {
0493 test ! -f "$dst" ||
0494 $doit $rmcmd -f "$dst" 2>/dev/null ||
0495 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
0496 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
0497 } ||
0498 { echo "$0: cannot unlink or rename $dst" >&2
0499 (exit 1); exit 1
0500 }
0501 } &&
0502
0503
0504 $doit $mvcmd "$dsttmp" "$dst"
2808ba210… Alex*0505 }
0506 fi || exit 1
0507
0508 trap '' 0
0509 fi
5c0dde779… Alex*0510 done
d7d4fdf89… Alex*0511
5c0dde779… Alex*0512
f6a1b37d1… Alex*0513
5c0dde779… Alex*0514
0515
f6a1b37d1… Alex*0516
2808ba210… Alex*0517
5c0dde779… Alex*0518