Mercurial > hg > early-roguelike
comparison install-sh @ 253:d9badb9c0179
Update the fallback install script.
| author | John "Elwin" Edwards |
|---|---|
| date | Tue, 31 Jan 2017 18:59:38 -0500 |
| parents | 78ca6502d2a6 |
| children | 029c1f5c5588 |
comparison
equal
deleted
inserted
replaced
| 252:3d4252fa2ed3 | 253:d9badb9c0179 |
|---|---|
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # install - install a program, script, or datafile | 2 # install - install a program, script, or datafile |
| 3 | 3 |
| 4 scriptversion=2011-11-20.07; # UTC | 4 scriptversion=2013-12-25.23; # UTC |
| 5 | 5 |
| 6 # This originates from X11R5 (mit/util/scripts/install.sh), which was | 6 # This originates from X11R5 (mit/util/scripts/install.sh), which was |
| 7 # later released in X11R6 (xc/config/util/install.sh) with the | 7 # later released in X11R6 (xc/config/util/install.sh) with the |
| 8 # following copyright and license. | 8 # following copyright and license. |
| 9 # | 9 # |
| 39 # when there is no Makefile. | 39 # when there is no Makefile. |
| 40 # | 40 # |
| 41 # This script is compatible with the BSD install script, but was written | 41 # This script is compatible with the BSD install script, but was written |
| 42 # from scratch. | 42 # from scratch. |
| 43 | 43 |
| 44 tab=' ' | |
| 44 nl=' | 45 nl=' |
| 45 ' | 46 ' |
| 46 IFS=" "" $nl" | 47 IFS=" $tab$nl" |
| 47 | 48 |
| 48 # set DOITPROG to echo to test this script | 49 # Set DOITPROG to "echo" to test this script. |
| 49 | 50 |
| 50 # Don't use :- since 4.3BSD and earlier shells don't like it. | |
| 51 doit=${DOITPROG-} | 51 doit=${DOITPROG-} |
| 52 if test -z "$doit"; then | 52 doit_exec=${doit:-exec} |
| 53 doit_exec=exec | |
| 54 else | |
| 55 doit_exec=$doit | |
| 56 fi | |
| 57 | 53 |
| 58 # Put in absolute file names if you don't have them in your path; | 54 # Put in absolute file names if you don't have them in your path; |
| 59 # or use environment vars. | 55 # or use environment vars. |
| 60 | 56 |
| 61 chgrpprog=${CHGRPPROG-chgrp} | 57 chgrpprog=${CHGRPPROG-chgrp} |
| 66 mkdirprog=${MKDIRPROG-mkdir} | 62 mkdirprog=${MKDIRPROG-mkdir} |
| 67 mvprog=${MVPROG-mv} | 63 mvprog=${MVPROG-mv} |
| 68 rmprog=${RMPROG-rm} | 64 rmprog=${RMPROG-rm} |
| 69 stripprog=${STRIPPROG-strip} | 65 stripprog=${STRIPPROG-strip} |
| 70 | 66 |
| 71 posix_glob='?' | |
| 72 initialize_posix_glob=' | |
| 73 test "$posix_glob" != "?" || { | |
| 74 if (set -f) 2>/dev/null; then | |
| 75 posix_glob= | |
| 76 else | |
| 77 posix_glob=: | |
| 78 fi | |
| 79 } | |
| 80 ' | |
| 81 | |
| 82 posix_mkdir= | 67 posix_mkdir= |
| 83 | 68 |
| 84 # Desired mode of installed file. | 69 # Desired mode of installed file. |
| 85 mode=0755 | 70 mode=0755 |
| 86 | 71 |
| 95 dst= | 80 dst= |
| 96 dir_arg= | 81 dir_arg= |
| 97 dst_arg= | 82 dst_arg= |
| 98 | 83 |
| 99 copy_on_change=false | 84 copy_on_change=false |
| 100 no_target_directory= | 85 is_target_a_directory=possibly |
| 101 | 86 |
| 102 usage="\ | 87 usage="\ |
| 103 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE | 88 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE |
| 104 or: $0 [OPTION]... SRCFILES... DIRECTORY | 89 or: $0 [OPTION]... SRCFILES... DIRECTORY |
| 105 or: $0 [OPTION]... -t DIRECTORY SRCFILES... | 90 or: $0 [OPTION]... -t DIRECTORY SRCFILES... |
| 135 -C) copy_on_change=true;; | 120 -C) copy_on_change=true;; |
| 136 | 121 |
| 137 -d) dir_arg=true;; | 122 -d) dir_arg=true;; |
| 138 | 123 |
| 139 -g) chgrpcmd="$chgrpprog $2" | 124 -g) chgrpcmd="$chgrpprog $2" |
| 140 shift;; | 125 shift;; |
| 141 | 126 |
| 142 --help) echo "$usage"; exit $?;; | 127 --help) echo "$usage"; exit $?;; |
| 143 | 128 |
| 144 -m) mode=$2 | 129 -m) mode=$2 |
| 145 case $mode in | 130 case $mode in |
| 146 *' '* | *' '* | *' | 131 *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) |
| 147 '* | *'*'* | *'?'* | *'['*) | 132 echo "$0: invalid mode: $mode" >&2 |
| 148 echo "$0: invalid mode: $mode" >&2 | 133 exit 1;; |
| 149 exit 1;; | 134 esac |
| 150 esac | 135 shift;; |
| 151 shift;; | |
| 152 | 136 |
| 153 -o) chowncmd="$chownprog $2" | 137 -o) chowncmd="$chownprog $2" |
| 154 shift;; | 138 shift;; |
| 155 | 139 |
| 156 -s) stripcmd=$stripprog;; | 140 -s) stripcmd=$stripprog;; |
| 157 | 141 |
| 158 -t) dst_arg=$2 | 142 -t) |
| 159 # Protect names problematic for 'test' and other utilities. | 143 is_target_a_directory=always |
| 160 case $dst_arg in | 144 dst_arg=$2 |
| 161 -* | [=\(\)!]) dst_arg=./$dst_arg;; | 145 # Protect names problematic for 'test' and other utilities. |
| 162 esac | 146 case $dst_arg in |
| 163 shift;; | 147 -* | [=\(\)!]) dst_arg=./$dst_arg;; |
| 164 | 148 esac |
| 165 -T) no_target_directory=true;; | 149 shift;; |
| 150 | |
| 151 -T) is_target_a_directory=never;; | |
| 166 | 152 |
| 167 --version) echo "$0 $scriptversion"; exit $?;; | 153 --version) echo "$0 $scriptversion"; exit $?;; |
| 168 | 154 |
| 169 --) shift | 155 --) shift |
| 170 break;; | 156 break;; |
| 171 | 157 |
| 172 -*) echo "$0: invalid option: $1" >&2 | 158 -*) echo "$0: invalid option: $1" >&2 |
| 173 exit 1;; | 159 exit 1;; |
| 174 | 160 |
| 175 *) break;; | 161 *) break;; |
| 176 esac | 162 esac |
| 177 shift | 163 shift |
| 178 done | 164 done |
| 165 | |
| 166 # We allow the use of options -d and -T together, by making -d | |
| 167 # take the precedence; this is for compatibility with GNU install. | |
| 168 | |
| 169 if test -n "$dir_arg"; then | |
| 170 if test -n "$dst_arg"; then | |
| 171 echo "$0: target directory not allowed when installing a directory." >&2 | |
| 172 exit 1 | |
| 173 fi | |
| 174 fi | |
| 179 | 175 |
| 180 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then | 176 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then |
| 181 # When -d is used, all remaining arguments are directories to create. | 177 # When -d is used, all remaining arguments are directories to create. |
| 182 # When -t is used, the destination is already specified. | 178 # When -t is used, the destination is already specified. |
| 183 # Otherwise, the last argument is the destination. Remove it from $@. | 179 # Otherwise, the last argument is the destination. Remove it from $@. |
| 206 # This can happen when creating conditional directories. | 202 # This can happen when creating conditional directories. |
| 207 exit 0 | 203 exit 0 |
| 208 fi | 204 fi |
| 209 | 205 |
| 210 if test -z "$dir_arg"; then | 206 if test -z "$dir_arg"; then |
| 207 if test $# -gt 1 || test "$is_target_a_directory" = always; then | |
| 208 if test ! -d "$dst_arg"; then | |
| 209 echo "$0: $dst_arg: Is not a directory." >&2 | |
| 210 exit 1 | |
| 211 fi | |
| 212 fi | |
| 213 fi | |
| 214 | |
| 215 if test -z "$dir_arg"; then | |
| 211 do_exit='(exit $ret); exit $ret' | 216 do_exit='(exit $ret); exit $ret' |
| 212 trap "ret=129; $do_exit" 1 | 217 trap "ret=129; $do_exit" 1 |
| 213 trap "ret=130; $do_exit" 2 | 218 trap "ret=130; $do_exit" 2 |
| 214 trap "ret=141; $do_exit" 13 | 219 trap "ret=141; $do_exit" 13 |
| 215 trap "ret=143; $do_exit" 15 | 220 trap "ret=143; $do_exit" 15 |
| 221 *644) cp_umask=133;; | 226 *644) cp_umask=133;; |
| 222 *755) cp_umask=22;; | 227 *755) cp_umask=22;; |
| 223 | 228 |
| 224 *[0-7]) | 229 *[0-7]) |
| 225 if test -z "$stripcmd"; then | 230 if test -z "$stripcmd"; then |
| 226 u_plus_rw= | 231 u_plus_rw= |
| 227 else | 232 else |
| 228 u_plus_rw='% 200' | 233 u_plus_rw='% 200' |
| 229 fi | 234 fi |
| 230 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; | 235 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; |
