Lines Matching +full:protect +full:- +full:exec
2 # install - install a program, script, or datafile
4 scriptversion=2024-06-19.01; # UTC
26 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
30 # be used in advertising or otherwise to promote the sale, use or other deal-
31 # ings in this Software without prior written authorization from the X Consor-
37 # Calling this script install-sh is preferred over install.sh, to prevent
51 doit=${DOITPROG-}
52 doit_exec=${doit:-exec}
57 chgrpprog=${CHGRPPROG-chgrp}
58 chmodprog=${CHMODPROG-chmod}
59 chownprog=${CHOWNPROG-chown}
60 cmpprog=${CMPPROG-cmp}
61 cpprog=${CPPROG-cp}
62 mkdirprog=${MKDIRPROG-mkdir}
63 mvprog=${MVPROG-mv}
64 rmprog=${RMPROG-rm}
65 stripprog=${STRIPPROG-strip}
81 rmcmd="$rmprog -f"
93 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
95 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
96 or: $0 [OPTION]... -d DIRECTORIES...
103 --help display this help and exit.
104 --version display version info and exit.
106 -c (ignored)
107 -C install only if different (preserve data modification time)
108 -d create directories instead of installing files.
109 -g GROUP $chgrpprog installed files to GROUP.
110 -m MODE $chmodprog installed files to MODE.
111 -o USER $chownprog installed files to USER.
112 -p pass -p to $cpprog.
113 -s $stripprog installed files.
114 -S SUFFIX attempt to back up existing files, with suffix SUFFIX.
115 -t DIRECTORY install into DIRECTORY.
116 -T report an error if DSTFILE is a directory.
122 By default, rm is invoked with -f; when overridden with RMPROG,
123 it's up to you to specify -f if you want it.
125 If -S is not specified, no backups are attempted.
127 Report bugs to <bug-automake@gnu.org>.
131 while test $# -ne 0; do
133 -c) ;;
135 -C) copy_on_change=true;;
137 -d) dir_arg=true;;
139 -g) chgrpcmd="$chgrpprog $2"
142 --help) echo "$usage"; exit $?;;
144 -m) mode=$2
152 -o) chowncmd="$chownprog $2"
155 -p) cpprog="$cpprog -p";;
157 -s) stripcmd=$stripprog;;
159 -S) backupsuffix="$2"
162 -t)
165 # Protect names problematic for 'test' and other utilities.
167 -* | [=\(\)!]) dst_arg=./$dst_arg;;
171 -T) is_target_a_directory=never;;
173 --version) echo "$0 (GNU Automake) $scriptversion"; exit $?;;
175 --) shift
178 -*) echo "$0: invalid option: $1" >&2
186 # We allow the use of options -d and -T together, by making -d
189 if test -n "$dir_arg"; then
190 if test -n "$dst_arg"; then
196 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
197 # When -d is used, all remaining arguments are directories to create.
198 # When -t is used, the destination is already specified.
202 if test -n "$dst_arg"; then
209 # Protect names problematic for 'test' and other utilities.
211 -* | [=\(\)!]) dst_arg=./$dst_arg;;
216 if test $# -eq 0; then
217 if test -z "$dir_arg"; then
221 # It's OK to call 'install-sh -d' without argument.
226 if test -z "$dir_arg"; then
227 if test $# -gt 1 || test "$is_target_a_directory" = always; then
228 if test ! -d "$dst_arg"; then
235 if test -z "$dir_arg"; then
242 # Set umask so as not to create temps with too-generous modes.
249 *[0-7])
250 if test -z "$stripcmd"; then
255 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
257 if test -z "$stripcmd"; then
268 # Protect names problematic for 'test' and other utilities.
270 -* | [=\(\)!]) src=./$src;;
273 if test -n "$dir_arg"; then
276 test -d "$dstdir"
287 if test ! -f "$src" && test ! -d "$src"; then
292 if test -z "$dst_arg"; then
299 if test -d "$dst"; then
313 test -d "$dstdir"
328 # With -d, create the new directory with the user-specified mode.
330 if test -n "$dir_arg"; then
331 mkdir_mode=-m$mode
339 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
347 # Because "mkdir -p" follows existing symlinks and we likely work
348 # directly in world-writable /tmp, make sure that the '$tmpdir'
350 # 'mkdir -p'.
353 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
355 if test -z "$dir_arg" || {
356 # Check for POSIX incompatibility with -m.
357 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
358 # other-writable bit of parent directory when it shouldn't.
359 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
361 ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
363 d????-?r-*) different_mode=700;;
364 d????-?--*) different_mode=755;;
367 $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
368 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
377 rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
385 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
396 [-=\(\)!]*) prefix='./';;
402 set -f
415 if test -d "$prefix"; then
420 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
422 test -d "$prefix" || exit 1
434 if test -n "$prefixes"; then
438 test -d "$dstdir" || exit 1
444 if test -n "$dir_arg"; then
445 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
446 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
448 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
456 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
460 { test -z "$stripcmd" || {
461 # Create $dsttmp read-write so that cp doesn't create it read-only,
463 if test -z "$doit"; then
464 : >"$dsttmp" # No need to fork-exec 'touch'.
478 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
479 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
480 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
481 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
483 # If -C, don't bother to copy if it wouldn't change the file.
485 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
486 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
487 set -f &&
494 rm -f "$dsttmp"
498 # e.g., if mv doesn't support -f.
499 if test -n "$backupsuffix" && test -f "$dst"; then
500 $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
504 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
508 # support -f.
516 test ! -f "$dst" ||
518 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
536 # eval: (add-hook 'before-save-hook 'time-stamp)
537 # time-stamp-start: "scriptversion="
538 # time-stamp-format: "%:y-%02m-%02d.%02H"
539 # time-stamp-time-zone: "UTC0"
540 # time-stamp-end: "; # UTC"