comparison install-sh @ 1826:6a621a625b04

New release
author Adam Chlipala <adam@chlipala.net>
date Tue, 25 Sep 2012 08:16:58 -0400
parents 27d68ccb2c9e
children
comparison
equal deleted inserted replaced
1825:52c291b05738 1826:6a621a625b04
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-01-19.21; # UTC 4 scriptversion=2009-04-28.21; # 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 #
154 shift;; 154 shift;;
155 155
156 -s) stripcmd=$stripprog;; 156 -s) stripcmd=$stripprog;;
157 157
158 -t) dst_arg=$2 158 -t) dst_arg=$2
159 # Protect names problematic for `test' and other utilities.
160 case $dst_arg in
161 -* | [=\(\)!]) dst_arg=./$dst_arg;;
162 esac
163 shift;; 159 shift;;
164 160
165 -T) no_target_directory=true;; 161 -T) no_target_directory=true;;
166 162
167 --version) echo "$0 $scriptversion"; exit $?;; 163 --version) echo "$0 $scriptversion"; exit $?;;
188 set fnord "$@" "$dst_arg" 184 set fnord "$@" "$dst_arg"
189 shift # fnord 185 shift # fnord
190 fi 186 fi
191 shift # arg 187 shift # arg
192 dst_arg=$arg 188 dst_arg=$arg
193 # Protect names problematic for `test' and other utilities.
194 case $dst_arg in
195 -* | [=\(\)!]) dst_arg=./$dst_arg;;
196 esac
197 done 189 done
198 fi 190 fi
199 191
200 if test $# -eq 0; then 192 if test $# -eq 0; then
201 if test -z "$dir_arg"; then 193 if test -z "$dir_arg"; then
206 # This can happen when creating conditional directories. 198 # This can happen when creating conditional directories.
207 exit 0 199 exit 0
208 fi 200 fi
209 201
210 if test -z "$dir_arg"; then 202 if test -z "$dir_arg"; then
211 do_exit='(exit $ret); exit $ret' 203 trap '(exit $?); exit' 1 2 13 15
212 trap "ret=129; $do_exit" 1
213 trap "ret=130; $do_exit" 2
214 trap "ret=141; $do_exit" 13
215 trap "ret=143; $do_exit" 15
216 204
217 # Set umask so as not to create temps with too-generous modes. 205 # Set umask so as not to create temps with too-generous modes.
218 # However, 'strip' requires both read and write access to temps. 206 # However, 'strip' requires both read and write access to temps.
219 case $mode in 207 case $mode in
220 # Optimize common cases. 208 # Optimize common cases.
238 esac 226 esac
239 fi 227 fi
240 228
241 for src 229 for src
242 do 230 do
243 # Protect names problematic for `test' and other utilities. 231 # Protect names starting with `-'.
244 case $src in 232 case $src in
245 -* | [=\(\)!]) src=./$src;; 233 -*) src=./$src;;
246 esac 234 esac
247 235
248 if test -n "$dir_arg"; then 236 if test -n "$dir_arg"; then
249 dst=$src 237 dst=$src
250 dstdir=$dst 238 dstdir=$dst
262 250
263 if test -z "$dst_arg"; then 251 if test -z "$dst_arg"; then
264 echo "$0: no destination specified." >&2 252 echo "$0: no destination specified." >&2
265 exit 1 253 exit 1
266 fi 254 fi
255
267 dst=$dst_arg 256 dst=$dst_arg
257 # Protect names starting with `-'.
258 case $dst in
259 -*) dst=./$dst;;
260 esac
268 261
269 # If destination is a directory, append the input filename; won't work 262 # If destination is a directory, append the input filename; won't work
270 # if double slashes aren't ignored. 263 # if double slashes aren't ignored.
271 if test -d "$dst"; then 264 if test -d "$dst"; then
272 if test -n "$no_target_directory"; then 265 if test -n "$no_target_directory"; then
390 # or it failed possibly due to a race condition. Create the 383 # or it failed possibly due to a race condition. Create the
391 # directory the slow way, step by step, checking for races as we go. 384 # directory the slow way, step by step, checking for races as we go.
392 385
393 case $dstdir in 386 case $dstdir in
394 /*) prefix='/';; 387 /*) prefix='/';;
395 [-=\(\)!]*) prefix='./';; 388 -*) prefix='./';;
396 *) prefix='';; 389 *) prefix='';;
397 esac 390 esac
398 391
399 eval "$initialize_posix_glob" 392 eval "$initialize_posix_glob"
400 393
408 401
409 prefixes= 402 prefixes=
410 403
411 for d 404 for d
412 do 405 do
413 test X"$d" = X && continue 406 test -z "$d" && continue
414 407
415 prefix=$prefix$d 408 prefix=$prefix$d
416 if test -d "$prefix"; then 409 if test -d "$prefix"; then
417 prefixes= 410 prefixes=
418 else 411 else