158
137
--version) echo "$0 $scriptversion"; exit $?;;
139
*) # When -d is used, all remaining arguments are directories to create.
140
# When -t is used, the destination is already specified.
141
test -n "$dir_arg$dstarg" && break
142
# Otherwise, the last argument is the destination. Remove it from $@.
145
if test -n "$dstarg"; then
146
# $@ is not empty: it contains at least $arg.
147
set fnord "$@" "$dstarg"
163
-*) echo "$0: invalid option: $1" >&2
170
if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
171
# When -d is used, all remaining arguments are directories to create.
172
# When -t is used, the destination is already specified.
173
# Otherwise, the last argument is the destination. Remove it from $@.
176
if test -n "$dstarg"; then
177
# $@ is not empty: it contains at least $arg.
178
set fnord "$@" "$dstarg"
186
if test $# -eq 0; then
157
if test -z "$1"; then
187
158
if test -z "$dir_arg"; then
188
159
echo "$0: no input file specified." >&2
260
208
echo "$0: $dstarg: Is a directory" >&2
264
dst=$dstdir/`basename "$src"`
267
# Prefer dirname, but fall back on a substitute if dirname fails.
269
(dirname "$dst") 2>/dev/null ||
270
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
271
X"$dst" : 'X\(//\)[^/]' \| \
272
X"$dst" : 'X\(//\)$' \| \
273
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
275
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
211
dst=$dst/`basename "$src"`
299
obsolete_mkdir_used=false
301
if test $dstdir_status != 0; then
304
# Create intermediate dirs using mode 755 as modified by the umask.
305
# This is like FreeBSD 'install' as of 1997-10-28.
307
case $stripcmd.$umask in
308
# Optimize common cases.
309
*[2367][2367]) mkdir_umask=$umask;;
310
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
313
mkdir_umask=`expr $umask + 22 \
314
- $umask % 100 % 40 + $umask % 20 \
315
- $umask % 10 % 4 + $umask % 2
317
*) mkdir_umask=$umask,go-w;;
320
# With -d, create the new directory with the user-specified mode.
321
# Otherwise, rely on $mkdir_umask.
322
if test -n "$dir_arg"; then
331
# POSIX mkdir -p sets u+wx bits regardless of umask, which
332
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
335
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
336
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
338
if (umask $mkdir_umask &&
339
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
341
if test -z "$dir_arg" || {
342
# Check for POSIX incompatibilities with -m.
343
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
344
# other-writeable bit of parent directory when it shouldn't.
345
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
346
ls_ld_tmpdir=`ls -ld "$tmpdir"`
347
case $ls_ld_tmpdir in
348
d????-?r-*) different_mode=700;;
349
d????-?--*) different_mode=755;;
352
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
353
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
354
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
359
rmdir "$tmpdir/d" "$tmpdir"
361
# Remove any dirs left behind by ancient mkdir implementations.
362
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
370
umask $mkdir_umask &&
371
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
376
# The umask is ridiculous, or mkdir does not conform to POSIX,
377
# or it failed possibly due to a race condition. Create the
378
# directory the slow way, step by step, checking for races as we go.
388
if (set -f) 2>/dev/null; then
397
$posix_glob && set -f
215
# This sed command emulates the dirname command.
216
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
218
# Make sure that the destination directory exists.
220
# Skip lots of stat calls in the usual case.
221
if test ! -d "$dstdir"; then
224
IFS="${IFS-$defaultIFS}"
227
# Some sh's can't handle IFS=/ for some reason.
229
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
235
while test $# -ne 0 ; do
400
$posix_glob && set +f
407
test -z "$d" && continue
410
if test -d "$prefix"; then
413
if $posix_mkdir; then
414
(umask=$mkdir_umask &&
415
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
416
# Don't fail if two instances are running concurrently.
417
test -d "$prefix" || exit 1
420
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
423
prefixes="$prefixes '$qprefix'"
429
if test -n "$prefixes"; then
430
# Don't fail if two instances are running concurrently.
431
(umask $mkdir_umask &&
432
eval "\$doit_exec \$mkdirprog $prefixes") ||
433
test -d "$dstdir" || exit 1
434
obsolete_mkdir_used=true
238
if test ! -d "$pathcomp"; then
239
$mkdirprog "$pathcomp"
240
# mkdir can fail with a `File exist' error in case several
241
# install-sh are creating the directory concurrently. This
243
test -d "$pathcomp" || exit
439
249
if test -n "$dir_arg"; then
440
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
441
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
442
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
443
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
250
$doit $mkdircmd "$dst" \
251
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
252
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
253
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
254
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
257
dstfile=`basename "$dst"`
446
259
# Make a couple of temp file names in the proper directory.
447
260
dsttmp=$dstdir/_inst.$$_