1.1 --- a/install-sh Wed May 31 12:51:24 2017 +0200 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,527 +0,0 @@ 1.4 -#!/bin/sh 1.5 -# install - install a program, script, or datafile 1.6 - 1.7 -scriptversion=2011-11-20.07; # UTC 1.8 - 1.9 -# This originates from X11R5 (mit/util/scripts/install.sh), which was 1.10 -# later released in X11R6 (xc/config/util/install.sh) with the 1.11 -# following copyright and license. 1.12 -# 1.13 -# Copyright (C) 1994 X Consortium 1.14 -# 1.15 -# Permission is hereby granted, free of charge, to any person obtaining a copy 1.16 -# of this software and associated documentation files (the "Software"), to 1.17 -# deal in the Software without restriction, including without limitation the 1.18 -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 1.19 -# sell copies of the Software, and to permit persons to whom the Software is 1.20 -# furnished to do so, subject to the following conditions: 1.21 -# 1.22 -# The above copyright notice and this permission notice shall be included in 1.23 -# all copies or substantial portions of the Software. 1.24 -# 1.25 -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.26 -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.27 -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1.28 -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1.29 -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 1.30 -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1.31 -# 1.32 -# Except as contained in this notice, the name of the X Consortium shall not 1.33 -# be used in advertising or otherwise to promote the sale, use or other deal- 1.34 -# ings in this Software without prior written authorization from the X Consor- 1.35 -# tium. 1.36 -# 1.37 -# 1.38 -# FSF changes to this file are in the public domain. 1.39 -# 1.40 -# Calling this script install-sh is preferred over install.sh, to prevent 1.41 -# 'make' implicit rules from creating a file called install from it 1.42 -# when there is no Makefile. 1.43 -# 1.44 -# This script is compatible with the BSD install script, but was written 1.45 -# from scratch. 1.46 - 1.47 -nl=' 1.48 -' 1.49 -IFS=" "" $nl" 1.50 - 1.51 -# set DOITPROG to echo to test this script 1.52 - 1.53 -# Don't use :- since 4.3BSD and earlier shells don't like it. 1.54 -doit=${DOITPROG-} 1.55 -if test -z "$doit"; then 1.56 - doit_exec=exec 1.57 -else 1.58 - doit_exec=$doit 1.59 -fi 1.60 - 1.61 -# Put in absolute file names if you don't have them in your path; 1.62 -# or use environment vars. 1.63 - 1.64 -chgrpprog=${CHGRPPROG-chgrp} 1.65 -chmodprog=${CHMODPROG-chmod} 1.66 -chownprog=${CHOWNPROG-chown} 1.67 -cmpprog=${CMPPROG-cmp} 1.68 -cpprog=${CPPROG-cp} 1.69 -mkdirprog=${MKDIRPROG-mkdir} 1.70 -mvprog=${MVPROG-mv} 1.71 -rmprog=${RMPROG-rm} 1.72 -stripprog=${STRIPPROG-strip} 1.73 - 1.74 -posix_glob='?' 1.75 -initialize_posix_glob=' 1.76 - test "$posix_glob" != "?" || { 1.77 - if (set -f) 2>/dev/null; then 1.78 - posix_glob= 1.79 - else 1.80 - posix_glob=: 1.81 - fi 1.82 - } 1.83 -' 1.84 - 1.85 -posix_mkdir= 1.86 - 1.87 -# Desired mode of installed file. 1.88 -mode=0755 1.89 - 1.90 -chgrpcmd= 1.91 -chmodcmd=$chmodprog 1.92 -chowncmd= 1.93 -mvcmd=$mvprog 1.94 -rmcmd="$rmprog -f" 1.95 -stripcmd= 1.96 - 1.97 -src= 1.98 -dst= 1.99 -dir_arg= 1.100 -dst_arg= 1.101 - 1.102 -copy_on_change=false 1.103 -no_target_directory= 1.104 - 1.105 -usage="\ 1.106 -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 1.107 - or: $0 [OPTION]... SRCFILES... DIRECTORY 1.108 - or: $0 [OPTION]... -t DIRECTORY SRCFILES... 1.109 - or: $0 [OPTION]... -d DIRECTORIES... 1.110 - 1.111 -In the 1st form, copy SRCFILE to DSTFILE. 1.112 -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 1.113 -In the 4th, create DIRECTORIES. 1.114 - 1.115 -Options: 1.116 - --help display this help and exit. 1.117 - --version display version info and exit. 1.118 - 1.119 - -c (ignored) 1.120 - -C install only if different (preserve the last data modification time) 1.121 - -d create directories instead of installing files. 1.122 - -g GROUP $chgrpprog installed files to GROUP. 1.123 - -m MODE $chmodprog installed files to MODE. 1.124 - -o USER $chownprog installed files to USER. 1.125 - -s $stripprog installed files. 1.126 - -t DIRECTORY install into DIRECTORY. 1.127 - -T report an error if DSTFILE is a directory. 1.128 - 1.129 -Environment variables override the default commands: 1.130 - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 1.131 - RMPROG STRIPPROG 1.132 -" 1.133 - 1.134 -while test $# -ne 0; do 1.135 - case $1 in 1.136 - -c) ;; 1.137 - 1.138 - -C) copy_on_change=true;; 1.139 - 1.140 - -d) dir_arg=true;; 1.141 - 1.142 - -g) chgrpcmd="$chgrpprog $2" 1.143 - shift;; 1.144 - 1.145 - --help) echo "$usage"; exit $?;; 1.146 - 1.147 - -m) mode=$2 1.148 - case $mode in 1.149 - *' '* | *' '* | *' 1.150 -'* | *'*'* | *'?'* | *'['*) 1.151 - echo "$0: invalid mode: $mode" >&2 1.152 - exit 1;; 1.153 - esac 1.154 - shift;; 1.155 - 1.156 - -o) chowncmd="$chownprog $2" 1.157 - shift;; 1.158 - 1.159 - -s) stripcmd=$stripprog;; 1.160 - 1.161 - -t) dst_arg=$2 1.162 - # Protect names problematic for 'test' and other utilities. 1.163 - case $dst_arg in 1.164 - -* | [=\(\)!]) dst_arg=./$dst_arg;; 1.165 - esac 1.166 - shift;; 1.167 - 1.168 - -T) no_target_directory=true;; 1.169 - 1.170 - --version) echo "$0 $scriptversion"; exit $?;; 1.171 - 1.172 - --) shift 1.173 - break;; 1.174 - 1.175 - -*) echo "$0: invalid option: $1" >&2 1.176 - exit 1;; 1.177 - 1.178 - *) break;; 1.179 - esac 1.180 - shift 1.181 -done 1.182 - 1.183 -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 1.184 - # When -d is used, all remaining arguments are directories to create. 1.185 - # When -t is used, the destination is already specified. 1.186 - # Otherwise, the last argument is the destination. Remove it from $@. 1.187 - for arg 1.188 - do 1.189 - if test -n "$dst_arg"; then 1.190 - # $@ is not empty: it contains at least $arg. 1.191 - set fnord "$@" "$dst_arg" 1.192 - shift # fnord 1.193 - fi 1.194 - shift # arg 1.195 - dst_arg=$arg 1.196 - # Protect names problematic for 'test' and other utilities. 1.197 - case $dst_arg in 1.198 - -* | [=\(\)!]) dst_arg=./$dst_arg;; 1.199 - esac 1.200 - done 1.201 -fi 1.202 - 1.203 -if test $# -eq 0; then 1.204 - if test -z "$dir_arg"; then 1.205 - echo "$0: no input file specified." >&2 1.206 - exit 1 1.207 - fi 1.208 - # It's OK to call 'install-sh -d' without argument. 1.209 - # This can happen when creating conditional directories. 1.210 - exit 0 1.211 -fi 1.212 - 1.213 -if test -z "$dir_arg"; then 1.214 - do_exit='(exit $ret); exit $ret' 1.215 - trap "ret=129; $do_exit" 1 1.216 - trap "ret=130; $do_exit" 2 1.217 - trap "ret=141; $do_exit" 13 1.218 - trap "ret=143; $do_exit" 15 1.219 - 1.220 - # Set umask so as not to create temps with too-generous modes. 1.221 - # However, 'strip' requires both read and write access to temps. 1.222 - case $mode in 1.223 - # Optimize common cases. 1.224 - *644) cp_umask=133;; 1.225 - *755) cp_umask=22;; 1.226 - 1.227 - *[0-7]) 1.228 - if test -z "$stripcmd"; then 1.229 - u_plus_rw= 1.230 - else 1.231 - u_plus_rw='% 200' 1.232 - fi 1.233 - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 1.234 - *) 1.235 - if test -z "$stripcmd"; then 1.236 - u_plus_rw= 1.237 - else 1.238 - u_plus_rw=,u+rw 1.239 - fi 1.240 - cp_umask=$mode$u_plus_rw;; 1.241 - esac 1.242 -fi 1.243 - 1.244 -for src 1.245 -do 1.246 - # Protect names problematic for 'test' and other utilities. 1.247 - case $src in 1.248 - -* | [=\(\)!]) src=./$src;; 1.249 - esac 1.250 - 1.251 - if test -n "$dir_arg"; then 1.252 - dst=$src 1.253 - dstdir=$dst 1.254 - test -d "$dstdir" 1.255 - dstdir_status=$? 1.256 - else 1.257 - 1.258 - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 1.259 - # might cause directories to be created, which would be especially bad 1.260 - # if $src (and thus $dsttmp) contains '*'. 1.261 - if test ! -f "$src" && test ! -d "$src"; then 1.262 - echo "$0: $src does not exist." >&2 1.263 - exit 1 1.264 - fi 1.265 - 1.266 - if test -z "$dst_arg"; then 1.267 - echo "$0: no destination specified." >&2 1.268 - exit 1 1.269 - fi 1.270 - dst=$dst_arg 1.271 - 1.272 - # If destination is a directory, append the input filename; won't work 1.273 - # if double slashes aren't ignored. 1.274 - if test -d "$dst"; then 1.275 - if test -n "$no_target_directory"; then 1.276 - echo "$0: $dst_arg: Is a directory" >&2 1.277 - exit 1 1.278 - fi 1.279 - dstdir=$dst 1.280 - dst=$dstdir/`basename "$src"` 1.281 - dstdir_status=0 1.282 - else 1.283 - # Prefer dirname, but fall back on a substitute if dirname fails. 1.284 - dstdir=` 1.285 - (dirname "$dst") 2>/dev/null || 1.286 - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 1.287 - X"$dst" : 'X\(//\)[^/]' \| \ 1.288 - X"$dst" : 'X\(//\)$' \| \ 1.289 - X"$dst" : 'X\(/\)' \| . 2>/dev/null || 1.290 - echo X"$dst" | 1.291 - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 1.292 - s//\1/ 1.293 - q 1.294 - } 1.295 - /^X\(\/\/\)[^/].*/{ 1.296 - s//\1/ 1.297 - q 1.298 - } 1.299 - /^X\(\/\/\)$/{ 1.300 - s//\1/ 1.301 - q 1.302 - } 1.303 - /^X\(\/\).*/{ 1.304 - s//\1/ 1.305 - q 1.306 - } 1.307 - s/.*/./; q' 1.308 - ` 1.309 - 1.310 - test -d "$dstdir" 1.311 - dstdir_status=$? 1.312 - fi 1.313 - fi 1.314 - 1.315 - obsolete_mkdir_used=false 1.316 - 1.317 - if test $dstdir_status != 0; then 1.318 - case $posix_mkdir in 1.319 - '') 1.320 - # Create intermediate dirs using mode 755 as modified by the umask. 1.321 - # This is like FreeBSD 'install' as of 1997-10-28. 1.322 - umask=`umask` 1.323 - case $stripcmd.$umask in 1.324 - # Optimize common cases. 1.325 - *[2367][2367]) mkdir_umask=$umask;; 1.326 - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 1.327 - 1.328 - *[0-7]) 1.329 - mkdir_umask=`expr $umask + 22 \ 1.330 - - $umask % 100 % 40 + $umask % 20 \ 1.331 - - $umask % 10 % 4 + $umask % 2 1.332 - `;; 1.333 - *) mkdir_umask=$umask,go-w;; 1.334 - esac 1.335 - 1.336 - # With -d, create the new directory with the user-specified mode. 1.337 - # Otherwise, rely on $mkdir_umask. 1.338 - if test -n "$dir_arg"; then 1.339 - mkdir_mode=-m$mode 1.340 - else 1.341 - mkdir_mode= 1.342 - fi 1.343 - 1.344 - posix_mkdir=false 1.345 - case $umask in 1.346 - *[123567][0-7][0-7]) 1.347 - # POSIX mkdir -p sets u+wx bits regardless of umask, which 1.348 - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 1.349 - ;; 1.350 - *) 1.351 - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 1.352 - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 1.353 - 1.354 - if (umask $mkdir_umask && 1.355 - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 1.356 - then 1.357 - if test -z "$dir_arg" || { 1.358 - # Check for POSIX incompatibilities with -m. 1.359 - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 1.360 - # other-writable bit of parent directory when it shouldn't. 1.361 - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 1.362 - ls_ld_tmpdir=`ls -ld "$tmpdir"` 1.363 - case $ls_ld_tmpdir in 1.364 - d????-?r-*) different_mode=700;; 1.365 - d????-?--*) different_mode=755;; 1.366 - *) false;; 1.367 - esac && 1.368 - $mkdirprog -m$different_mode -p -- "$tmpdir" && { 1.369 - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 1.370 - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 1.371 - } 1.372 - } 1.373 - then posix_mkdir=: 1.374 - fi 1.375 - rmdir "$tmpdir/d" "$tmpdir" 1.376 - else 1.377 - # Remove any dirs left behind by ancient mkdir implementations. 1.378 - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 1.379 - fi 1.380 - trap '' 0;; 1.381 - esac;; 1.382 - esac 1.383 - 1.384 - if 1.385 - $posix_mkdir && ( 1.386 - umask $mkdir_umask && 1.387 - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 1.388 - ) 1.389 - then : 1.390 - else 1.391 - 1.392 - # The umask is ridiculous, or mkdir does not conform to POSIX, 1.393 - # or it failed possibly due to a race condition. Create the 1.394 - # directory the slow way, step by step, checking for races as we go. 1.395 - 1.396 - case $dstdir in 1.397 - /*) prefix='/';; 1.398 - [-=\(\)!]*) prefix='./';; 1.399 - *) prefix='';; 1.400 - esac 1.401 - 1.402 - eval "$initialize_posix_glob" 1.403 - 1.404 - oIFS=$IFS 1.405 - IFS=/ 1.406 - $posix_glob set -f 1.407 - set fnord $dstdir 1.408 - shift 1.409 - $posix_glob set +f 1.410 - IFS=$oIFS 1.411 - 1.412 - prefixes= 1.413 - 1.414 - for d 1.415 - do 1.416 - test X"$d" = X && continue 1.417 - 1.418 - prefix=$prefix$d 1.419 - if test -d "$prefix"; then 1.420 - prefixes= 1.421 - else 1.422 - if $posix_mkdir; then 1.423 - (umask=$mkdir_umask && 1.424 - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 1.425 - # Don't fail if two instances are running concurrently. 1.426 - test -d "$prefix" || exit 1 1.427 - else 1.428 - case $prefix in 1.429 - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 1.430 - *) qprefix=$prefix;; 1.431 - esac 1.432 - prefixes="$prefixes '$qprefix'" 1.433 - fi 1.434 - fi 1.435 - prefix=$prefix/ 1.436 - done 1.437 - 1.438 - if test -n "$prefixes"; then 1.439 - # Don't fail if two instances are running concurrently. 1.440 - (umask $mkdir_umask && 1.441 - eval "\$doit_exec \$mkdirprog $prefixes") || 1.442 - test -d "$dstdir" || exit 1 1.443 - obsolete_mkdir_used=true 1.444 - fi 1.445 - fi 1.446 - fi 1.447 - 1.448 - if test -n "$dir_arg"; then 1.449 - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 1.450 - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 1.451 - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 1.452 - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 1.453 - else 1.454 - 1.455 - # Make a couple of temp file names in the proper directory. 1.456 - dsttmp=$dstdir/_inst.$$_ 1.457 - rmtmp=$dstdir/_rm.$$_ 1.458 - 1.459 - # Trap to clean up those temp files at exit. 1.460 - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 1.461 - 1.462 - # Copy the file name to the temp name. 1.463 - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 1.464 - 1.465 - # and set any options; do chmod last to preserve setuid bits. 1.466 - # 1.467 - # If any of these fail, we abort the whole thing. If we want to 1.468 - # ignore errors from any of these, just make sure not to ignore 1.469 - # errors from the above "$doit $cpprog $src $dsttmp" command. 1.470 - # 1.471 - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 1.472 - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 1.473 - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 1.474 - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 1.475 - 1.476 - # If -C, don't bother to copy if it wouldn't change the file. 1.477 - if $copy_on_change && 1.478 - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 1.479 - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 1.480 - 1.481 - eval "$initialize_posix_glob" && 1.482 - $posix_glob set -f && 1.483 - set X $old && old=:$2:$4:$5:$6 && 1.484 - set X $new && new=:$2:$4:$5:$6 && 1.485 - $posix_glob set +f && 1.486 - 1.487 - test "$old" = "$new" && 1.488 - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 1.489 - then 1.490 - rm -f "$dsttmp" 1.491 - else 1.492 - # Rename the file to the real destination. 1.493 - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 1.494 - 1.495 - # The rename failed, perhaps because mv can't rename something else 1.496 - # to itself, or perhaps because mv is so ancient that it does not 1.497 - # support -f. 1.498 - { 1.499 - # Now remove or move aside any old file at destination location. 1.500 - # We try this two ways since rm can't unlink itself on some 1.501 - # systems and the destination file might be busy for other 1.502 - # reasons. In this case, the final cleanup might fail but the new 1.503 - # file should still install successfully. 1.504 - { 1.505 - test ! -f "$dst" || 1.506 - $doit $rmcmd -f "$dst" 2>/dev/null || 1.507 - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 1.508 - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 1.509 - } || 1.510 - { echo "$0: cannot unlink or rename $dst" >&2 1.511 - (exit 1); exit 1 1.512 - } 1.513 - } && 1.514 - 1.515 - # Now rename the file to the real destination. 1.516 - $doit $mvcmd "$dsttmp" "$dst" 1.517 - } 1.518 - fi || exit 1 1.519 - 1.520 - trap '' 0 1.521 - fi 1.522 -done 1.523 - 1.524 -# Local variables: 1.525 -# eval: (add-hook 'write-file-hooks 'time-stamp) 1.526 -# time-stamp-start: "scriptversion=" 1.527 -# time-stamp-format: "%:y-%02m-%02d.%02H" 1.528 -# time-stamp-time-zone: "UTC" 1.529 -# time-stamp-end: "; # UTC" 1.530 -# End: