Subversion Repositories DIN Is Noise

Rev

Rev 2096 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2096 Rev 2097
Line 1... Line 1...
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=2009-04-28.21; # UTC
4
scriptversion=2020-11-14.01; # 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
#
Line 33... Line 33...
33
#
33
#
34
#
34
#
35
# FSF changes to this file are in the public domain.
35
# FSF changes to this file are in the public domain.
36
#
36
#
37
# Calling this script install-sh is preferred over install.sh, to prevent
37
# Calling this script install-sh is preferred over install.sh, to prevent
38
# `make' implicit rules from creating a file called install from it
38
# 'make' implicit rules from creating a file called install from it
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
-
 
53
  doit_exec=exec
-
 
54
else
-
 
55
  doit_exec=$doit
52
doit_exec=${doit:-exec}
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}
Line 66... Line 62...
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
-
 
72
# Create dirs (including intermediate dirs) using mode 755.
-
 
73
# This is like GNU 'install' as of coreutils 8.32 (2020).
-
 
74
mkdir_umask=22
-
 
75
-
 
76
backupsuffix=
87
chgrpcmd=
77
chgrpcmd=
88
chmodcmd=$chmodprog
78
chmodcmd=$chmodprog
89
chowncmd=
79
chowncmd=
90
mvcmd=$mvprog
80
mvcmd=$mvprog
91
rmcmd="$rmprog -f"
81
rmcmd="$rmprog -f"
Line 95... Line 85...
95
dst=
85
dst=
96
dir_arg=
86
dir_arg=
97
dst_arg=
87
dst_arg=
98
88
99
copy_on_change=false
89
copy_on_change=false
100
no_target_directory=
90
is_target_a_directory=possibly
101
91
102
usage="\
92
usage="\
103
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
93
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
104
   or: $0 [OPTION]... SRCFILES... DIRECTORY
94
   or: $0 [OPTION]... SRCFILES... DIRECTORY
105
   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
95
   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
Line 112... Line 102...
112
Options:
102
Options:
113
     --help     display this help and exit.
103
     --help     display this help and exit.
114
     --version  display version info and exit.
104
     --version  display version info and exit.
115
105
116
  -c            (ignored)
106
  -c            (ignored)
117
  -C            install only if different (preserve the last data modification time)
107
  -C            install only if different (preserve data modification time)
118
  -d            create directories instead of installing files.
108
  -d            create directories instead of installing files.
119
  -g GROUP      $chgrpprog installed files to GROUP.
109
  -g GROUP      $chgrpprog installed files to GROUP.
120
  -m MODE       $chmodprog installed files to MODE.
110
  -m MODE       $chmodprog installed files to MODE.
121
  -o USER       $chownprog installed files to USER.
111
  -o USER       $chownprog installed files to USER.
-
 
112
  -p            pass -p to $cpprog.
122
  -s            $stripprog installed files.
113
  -s            $stripprog installed files.
-
 
114
  -S SUFFIX     attempt to back up existing files, with suffix SUFFIX.
123
  -t DIRECTORY  install into DIRECTORY.
115
  -t DIRECTORY  install into DIRECTORY.
124
  -T            report an error if DSTFILE is a directory.
116
  -T            report an error if DSTFILE is a directory.
125
117
126
Environment variables override the default commands:
118
Environment variables override the default commands:
127
  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
119
  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
128
  RMPROG STRIPPROG
120
  RMPROG STRIPPROG
-
 
121
-
 
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.
-
 
124
-
 
125
If -S is not specified, no backups are attempted.
-
 
126
-
 
127
Email bug reports to bug-automake@gnu.org.
-
 
128
Automake home page: https://www.gnu.org/software/automake/
129
"
129
"
130
130
131
while test $# -ne 0; do
131
while test $# -ne 0; do
132
  case $1 in
132
  case $1 in
133
    -c) ;;
133
    -c) ;;
Line 135... Line 135...
135
    -C) copy_on_change=true;;
135
    -C) copy_on_change=true;;
136
136
137
    -d) dir_arg=true;;
137
    -d) dir_arg=true;;
138
138
139
    -g) chgrpcmd="$chgrpprog $2"
139
    -g) chgrpcmd="$chgrpprog $2"
140
	shift;;
140
        shift;;
141
141
142
    --help) echo "$usage"; exit $?;;
142
    --help) echo "$usage"; exit $?;;
143
143
144
    -m) mode=$2
144
    -m) mode=$2
145
	case $mode in
145
        case $mode in
146
	  *' '* | *'	'* | *'
-
 
147
'*	  | *'*'* | *'?'* | *'['*)
146
          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
148
	    echo "$0: invalid mode: $mode" >&2
147
            echo "$0: invalid mode: $mode" >&2
149
	    exit 1;;
148
            exit 1;;
150
	esac
149
        esac
151
	shift;;
150
        shift;;
152
151
153
    -o) chowncmd="$chownprog $2"
152
    -o) chowncmd="$chownprog $2"
154
	shift;;
153
        shift;;
-
 
154
-
 
155
    -p) cpprog="$cpprog -p";;
155
156
156
    -s) stripcmd=$stripprog;;
157
    -s) stripcmd=$stripprog;;
157
158
158
    -t) dst_arg=$2
159
    -S) backupsuffix="$2"
159
	shift;;
160
        shift;;
160
161
-
 
162
    -t)
-
 
163
        is_target_a_directory=always
-
 
164
        dst_arg=$2
-
 
165
        # Protect names problematic for 'test' and other utilities.
-
 
166
        case $dst_arg in
-
 
167
          -* | [=\(\)!]) dst_arg=./$dst_arg;;
-
 
168
        esac
-
 
169
        shift;;
-
 
170
161
    -T) no_target_directory=true;;
171
    -T) is_target_a_directory=never;;
162
172
163
    --version) echo "$0 $scriptversion"; exit $?;;
173
    --version) echo "$0 $scriptversion"; exit $?;;
164
174
165
    --)	shift
175
    --) shift
166
	break;;
176
        break;;
167
177
168
    -*)	echo "$0: invalid option: $1" >&2
178
    -*) echo "$0: invalid option: $1" >&2
169
	exit 1;;
179
        exit 1;;
170
180
171
    *)  break;;
181
    *)  break;;
172
  esac
182
  esac
173
  shift
183
  shift
174
done
184
done
175
185
-
 
186
# We allow the use of options -d and -T together, by making -d
-
 
187
# take the precedence; this is for compatibility with GNU install.
-
 
188
-
 
189
if test -n "$dir_arg"; then
-
 
190
  if test -n "$dst_arg"; then
-
 
191
    echo "$0: target directory not allowed when installing a directory." >&2
-
 
192
    exit 1
-
 
193
  fi
-
 
194
fi
-
 
195
176
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
196
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
177
  # When -d is used, all remaining arguments are directories to create.
197
  # When -d is used, all remaining arguments are directories to create.
178
  # When -t is used, the destination is already specified.
198
  # When -t is used, the destination is already specified.
179
  # Otherwise, the last argument is the destination.  Remove it from $@.
199
  # Otherwise, the last argument is the destination.  Remove it from $@.
180
  for arg
200
  for arg
Line 184... Line 204...
184
      set fnord "$@" "$dst_arg"
204
      set fnord "$@" "$dst_arg"
185
      shift # fnord
205
      shift # fnord
186
    fi
206
    fi
187
    shift # arg
207
    shift # arg
188
    dst_arg=$arg
208
    dst_arg=$arg
-
 
209
    # Protect names problematic for 'test' and other utilities.
-
 
210
    case $dst_arg in
-
 
211
      -* | [=\(\)!]) dst_arg=./$dst_arg;;
-
 
212
    esac
189
  done
213
  done
190
fi
214
fi
191
215
192
if test $# -eq 0; then
216
if test $# -eq 0; then
193
  if test -z "$dir_arg"; then
217
  if test -z "$dir_arg"; then
194
    echo "$0: no input file specified." >&2
218
    echo "$0: no input file specified." >&2
195
    exit 1
219
    exit 1
196
  fi
220
  fi
197
  # It's OK to call `install-sh -d' without argument.
221
  # It's OK to call 'install-sh -d' without argument.
198
  # This can happen when creating conditional directories.
222
  # This can happen when creating conditional directories.
199
  exit 0
223
  exit 0
200
fi
224
fi
201
225
202
if test -z "$dir_arg"; then
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
-
 
229
      echo "$0: $dst_arg: Is not a directory." >&2
-
 
230
      exit 1
-
 
231
    fi
-
 
232
  fi
-
 
233
fi
-
 
234
-
 
235
if test -z "$dir_arg"; then
203
  trap '(exit $?); exit' 1 2 13 15
236
  do_exit='(exit $ret); exit $ret'
-
 
237
  trap "ret=129; $do_exit" 1
-
 
238
  trap "ret=130; $do_exit" 2
-
 
239
  trap "ret=141; $do_exit" 13
-
 
240
  trap "ret=143; $do_exit" 15
204
241
205
  # Set umask so as not to create temps with too-generous modes.
242
  # Set umask so as not to create temps with too-generous modes.
206
  # However, 'strip' requires both read and write access to temps.
243
  # However, 'strip' requires both read and write access to temps.
207
  case $mode in
244
  case $mode in
208
    # Optimize common cases.
245
    # Optimize common cases.
209
    *644) cp_umask=133;;
246
    *644) cp_umask=133;;
210
    *755) cp_umask=22;;
247
    *755) cp_umask=22;;
211
248
212
    *[0-7])
249
    *[0-7])
213
      if test -z "$stripcmd"; then
250
      if test -z "$stripcmd"; then
214
	u_plus_rw=
251
        u_plus_rw=
215
      else
252
      else
216
	u_plus_rw='% 200'
253
        u_plus_rw='% 200'
217
      fi
254
      fi
218
      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
255
      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
219
    *)
256
    *)
220
      if test -z "$stripcmd"; then
257
      if test -z "$stripcmd"; then
221
	u_plus_rw=
258
        u_plus_rw=
222
      else
259
      else
223
	u_plus_rw=,u+rw
260
        u_plus_rw=,u+rw
224
      fi
261
      fi
225
      cp_umask=$mode$u_plus_rw;;
262
      cp_umask=$mode$u_plus_rw;;
226
  esac
263
  esac
227
fi
264
fi
228
265
229
for src
266
for src
230
do
267
do
231
  # Protect names starting with `-'.
268
  # Protect names problematic for 'test' and other utilities.
232
  case $src in
269
  case $src in
233
    -*) src=./$src;;
270
    -* | [=\(\)!]) src=./$src;;
234
  esac
271
  esac
235
272
236
  if test -n "$dir_arg"; then
273
  if test -n "$dir_arg"; then
237
    dst=$src
274
    dst=$src
238
    dstdir=$dst
275
    dstdir=$dst
239
    test -d "$dstdir"
276
    test -d "$dstdir"
240
    dstdir_status=$?
277
    dstdir_status=$?
-
 
278
    # Don't chown directories that already exist.
-
 
279
    if test $dstdir_status = 0; then
-
 
280
      chowncmd=""
-
 
281
    fi
241
  else
282
  else
242
283
243
    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
284
    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
244
    # might cause directories to be created, which would be especially bad
285
    # might cause directories to be created, which would be especially bad
245
    # if $src (and thus $dsttmp) contains '*'.
286
    # if $src (and thus $dsttmp) contains '*'.
Line 250... Line 291...
250
291
251
    if test -z "$dst_arg"; then
292
    if test -z "$dst_arg"; then
252
      echo "$0: no destination specified." >&2
293
      echo "$0: no destination specified." >&2
253
      exit 1
294
      exit 1
254
    fi
295
    fi
255
-
 
256
    dst=$dst_arg
296
    dst=$dst_arg
257
    # Protect names starting with `-'.
-
 
258
    case $dst in
-
 
259
      -*) dst=./$dst;;
-
 
260
    esac
-
 
261
297
262
    # If destination is a directory, append the input filename; won't work
298
    # If destination is a directory, append the input filename.
263
    # if double slashes aren't ignored.
-
 
264
    if test -d "$dst"; then
299
    if test -d "$dst"; then
265
      if test -n "$no_target_directory"; then
300
      if test "$is_target_a_directory" = never; then
266
	echo "$0: $dst_arg: Is a directory" >&2
301
        echo "$0: $dst_arg: Is a directory" >&2
267
	exit 1
302
        exit 1
268
      fi
303
      fi
269
      dstdir=$dst
304
      dstdir=$dst
270
      dst=$dstdir/`basename "$src"`
305
      dstbase=`basename "$src"`
-
 
306
      case $dst in
-
 
307
	*/) dst=$dst$dstbase;;
-
 
308
	*)  dst=$dst/$dstbase;;
-
 
309
      esac
271
      dstdir_status=0
310
      dstdir_status=0
272
    else
311
    else
273
      # Prefer dirname, but fall back on a substitute if dirname fails.
-
 
274
      dstdir=`
312
      dstdir=`dirname "$dst"`
275
	(dirname "$dst") 2>/dev/null ||
-
 
276
	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-
 
277
	     X"$dst" : 'X\(//\)[^/]' \| \
-
 
278
	     X"$dst" : 'X\(//\)$' \| \
-
 
279
	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-
 
280
	echo X"$dst" |
-
 
281
	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-
 
282
		   s//\1/
-
 
283
		   q
-
 
284
		 }
-
 
285
		 /^X\(\/\/\)[^/].*/{
-
 
286
		   s//\1/
-
 
287
		   q
-
 
288
		 }
-
 
289
		 /^X\(\/\/\)$/{
-
 
290
		   s//\1/
-
 
291
		   q
-
 
292
		 }
-
 
293
		 /^X\(\/\).*/{
-
 
294
		   s//\1/
-
 
295
		   q
-
 
296
		 }
-
 
297
		 s/.*/./; q'
-
 
298
      `
-
 
299
-
 
300
      test -d "$dstdir"
313
      test -d "$dstdir"
301
      dstdir_status=$?
314
      dstdir_status=$?
302
    fi
315
    fi
303
  fi
316
  fi
304
317
-
 
318
  case $dstdir in
-
 
319
    */) dstdirslash=$dstdir;;
-
 
320
    *)  dstdirslash=$dstdir/;;
-
 
321
  esac
-
 
322
305
  obsolete_mkdir_used=false
323
  obsolete_mkdir_used=false
306
324
307
  if test $dstdir_status != 0; then
325
  if test $dstdir_status != 0; then
308
    case $posix_mkdir in
326
    case $posix_mkdir in
309
      '')
327
      '')
310
	# Create intermediate dirs using mode 755 as modified by the umask.
328
        # With -d, create the new directory with the user-specified mode.
311
	# This is like FreeBSD 'install' as of 1997-10-28.
329
        # Otherwise, rely on $mkdir_umask.
312
	umask=`umask`
330
        if test -n "$dir_arg"; then
313
	case $stripcmd.$umask in
331
          mkdir_mode=-m$mode
314
	  # Optimize common cases.
332
        else
315
	  *[2367][2367]) mkdir_umask=$umask;;
333
          mkdir_mode=
316
	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
334
        fi
317
335
318
	  *[0-7])
336
        posix_mkdir=false
319
	    mkdir_umask=`expr $umask + 22 \
337
	# The $RANDOM variable is not portable (e.g., dash).  Use it
320
	      - $umask % 100 % 40 + $umask % 20 \
338
	# here however when possible just to lower collision chance.
321
	      - $umask % 10 % 4 + $umask % 2
339
	tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-
 
340
-
 
341
	trap '
322
	    `;;
342
	  ret=$?
323
	  *) mkdir_umask=$umask,go-w;;
343
	  rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
-
 
344
	  exit $ret
324
	esac
345
	' 0
325
346
-
 
347
	# Because "mkdir -p" follows existing symlinks and we likely work
-
 
348
	# directly in world-writeable /tmp, make sure that the '$tmpdir'
326
	# With -d, create the new directory with the user-specified mode.
349
	# directory is successfully created first before we actually test
-
 
350
	# 'mkdir -p'.
327
	# Otherwise, rely on $mkdir_umask.
351
	if (umask $mkdir_umask &&
-
 
352
	    $mkdirprog $mkdir_mode "$tmpdir" &&
-
 
353
	    exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
-
 
354
	then
328
	if test -n "$dir_arg"; then
355
	  if test -z "$dir_arg" || {
-
 
356
	       # Check for POSIX incompatibilities 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.
-
 
360
	       test_tmpdir="$tmpdir/a"
-
 
361
	       ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
-
 
362
	       case $ls_ld_tmpdir in
-
 
363
		 d????-?r-*) different_mode=700;;
-
 
364
		 d????-?--*) different_mode=755;;
-
 
365
		 *) false;;
-
 
366
	       esac &&
-
 
367
	       $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
-
 
368
		 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
-
 
369
		 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-
 
370
	       }
-
 
371
	     }
329
	  mkdir_mode=-m$mode
372
	  then posix_mkdir=:
-
 
373
	  fi
-
 
374
	  rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
330
	else
375
	else
-
 
376
	  # Remove any dirs left behind by ancient mkdir implementations.
331
	  mkdir_mode=
377
	  rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
332
	fi
378
	fi
333
-
 
334
	posix_mkdir=false
-
 
335
	case $umask in
-
 
336
	  *[123567][0-7][0-7])
-
 
337
	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-
 
338
	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-
 
339
	    ;;
-
 
340
	  *)
-
 
341
	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-
 
342
	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
 
343
-
 
344
	    if (umask $mkdir_umask &&
-
 
345
		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-
 
346
	    then
-
 
347
	      if test -z "$dir_arg" || {
-
 
348
		   # Check for POSIX incompatibilities with -m.
-
 
349
		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-
 
350
		   # other-writeable bit of parent directory when it shouldn't.
-
 
351
		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-
 
352
		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-
 
353
		   case $ls_ld_tmpdir in
-
 
354
		     d????-?r-*) different_mode=700;;
-
 
355
		     d????-?--*) different_mode=755;;
-
 
356
		     *) false;;
-
 
357
		   esac &&
-
 
358
		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-
 
359
		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-
 
360
		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-
 
361
		   }
-
 
362
		 }
-
 
363
	      then posix_mkdir=:
-
 
364
	      fi
-
 
365
	      rmdir "$tmpdir/d" "$tmpdir"
-
 
366
	    else
-
 
367
	      # Remove any dirs left behind by ancient mkdir implementations.
-
 
368
	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-
 
369
	    fi
-
 
370
	    trap '' 0;;
379
	trap '' 0;;
371
	esac;;
-
 
372
    esac
380
    esac
373
381
374
    if
382
    if
375
      $posix_mkdir && (
383
      $posix_mkdir && (
376
	umask $mkdir_umask &&
384
        umask $mkdir_umask &&
377
	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
385
        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
378
      )
386
      )
379
    then :
387
    then :
380
    else
388
    else
381
389
382
      # The umask is ridiculous, or mkdir does not conform to POSIX,
390
      # mkdir does not conform to POSIX,
383
      # or it failed possibly due to a race condition.  Create the
391
      # or it failed possibly due to a race condition.  Create the
384
      # directory the slow way, step by step, checking for races as we go.
392
      # directory the slow way, step by step, checking for races as we go.
385
393
386
      case $dstdir in
394
      case $dstdir in
387
	/*) prefix='/';;
395
        /*) prefix='/';;
388
	-*) prefix='./';;
396
        [-=\(\)!]*) prefix='./';;
389
	*)  prefix='';;
397
        *)  prefix='';;
390
      esac
398
      esac
391
399
392
      eval "$initialize_posix_glob"
-
 
393
-
 
394
      oIFS=$IFS
400
      oIFS=$IFS
395
      IFS=/
401
      IFS=/
396
      $posix_glob set -f
402
      set -f
397
      set fnord $dstdir
403
      set fnord $dstdir
398
      shift
404
      shift
399
      $posix_glob set +f
405
      set +f
400
      IFS=$oIFS
406
      IFS=$oIFS
401
407
402
      prefixes=
408
      prefixes=
403
409
404
      for d
410
      for d
405
      do
411
      do
406
	test -z "$d" && continue
412
        test X"$d" = X && continue
407
413
408
	prefix=$prefix$d
414
        prefix=$prefix$d
409
	if test -d "$prefix"; then
415
        if test -d "$prefix"; then
410
	  prefixes=
416
          prefixes=
411
	else
417
        else
412
	  if $posix_mkdir; then
418
          if $posix_mkdir; then
413
	    (umask=$mkdir_umask &&
419
            (umask $mkdir_umask &&
414
	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
420
             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
415
	    # Don't fail if two instances are running concurrently.
421
            # Don't fail if two instances are running concurrently.
416
	    test -d "$prefix" || exit 1
422
            test -d "$prefix" || exit 1
417
	  else
423
          else
418
	    case $prefix in
424
            case $prefix in
419
	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
425
              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
420
	      *) qprefix=$prefix;;
426
              *) qprefix=$prefix;;
421
	    esac
427
            esac
422
	    prefixes="$prefixes '$qprefix'"
428
            prefixes="$prefixes '$qprefix'"
423
	  fi
429
          fi
424
	fi
430
        fi
425
	prefix=$prefix/
431
        prefix=$prefix/
426
      done
432
      done
427
433
428
      if test -n "$prefixes"; then
434
      if test -n "$prefixes"; then
429
	# Don't fail if two instances are running concurrently.
435
        # Don't fail if two instances are running concurrently.
430
	(umask $mkdir_umask &&
436
        (umask $mkdir_umask &&
431
	 eval "\$doit_exec \$mkdirprog $prefixes") ||
437
         eval "\$doit_exec \$mkdirprog $prefixes") ||
432
	  test -d "$dstdir" || exit 1
438
          test -d "$dstdir" || exit 1
433
	obsolete_mkdir_used=true
439
        obsolete_mkdir_used=true
434
      fi
440
      fi
435
    fi
441
    fi
436
  fi
442
  fi
437
443
438
  if test -n "$dir_arg"; then
444
  if test -n "$dir_arg"; then
Line 441... Line 447...
441
    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
447
    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
442
      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
448
      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
443
  else
449
  else
444
450
445
    # Make a couple of temp file names in the proper directory.
451
    # Make a couple of temp file names in the proper directory.
446
    dsttmp=$dstdir/_inst.$$_
452
    dsttmp=${dstdirslash}_inst.$$_
447
    rmtmp=$dstdir/_rm.$$_
453
    rmtmp=${dstdirslash}_rm.$$_
448
454
449
    # Trap to clean up those temp files at exit.
455
    # Trap to clean up those temp files at exit.
450
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
456
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
451
457
452
    # Copy the file name to the temp name.
458
    # Copy the file name to the temp name.
-
 
459
    (umask $cp_umask &&
-
 
460
     { test -z "$stripcmd" || {
-
 
461
	 # Create $dsttmp read-write so that cp doesn't create it read-only,
-
 
462
	 # which would cause strip to fail.
-
 
463
	 if test -z "$doit"; then
-
 
464
	   : >"$dsttmp" # No need to fork-exec 'touch'.
-
 
465
	 else
-
 
466
	   $doit touch "$dsttmp"
-
 
467
	 fi
-
 
468
       }
-
 
469
     } &&
453
    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
470
     $doit_exec $cpprog "$src" "$dsttmp") &&
454
471
455
    # and set any options; do chmod last to preserve setuid bits.
472
    # and set any options; do chmod last to preserve setuid bits.
456
    #
473
    #
457
    # If any of these fail, we abort the whole thing.  If we want to
474
    # If any of these fail, we abort the whole thing.  If we want to
458
    # ignore errors from any of these, just make sure not to ignore
475
    # ignore errors from any of these, just make sure not to ignore
Line 463... Line 480...
463
    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
480
    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
464
    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
481
    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
465
482
466
    # If -C, don't bother to copy if it wouldn't change the file.
483
    # If -C, don't bother to copy if it wouldn't change the file.
467
    if $copy_on_change &&
484
    if $copy_on_change &&
468
       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
485
       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
469
       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
486
       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
470
-
 
471
       eval "$initialize_posix_glob" &&
-
 
472
       $posix_glob set -f &&
487
       set -f &&
473
       set X $old && old=:$2:$4:$5:$6 &&
488
       set X $old && old=:$2:$4:$5:$6 &&
474
       set X $new && new=:$2:$4:$5:$6 &&
489
       set X $new && new=:$2:$4:$5:$6 &&
475
       $posix_glob set +f &&
490
       set +f &&
476
-
 
477
       test "$old" = "$new" &&
491
       test "$old" = "$new" &&
478
       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
492
       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
479
    then
493
    then
480
      rm -f "$dsttmp"
494
      rm -f "$dsttmp"
481
    else
495
    else
-
 
496
      # If $backupsuffix is set, and the file being installed
-
 
497
      # already exists, attempt a backup.  Don't worry if it fails,
-
 
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
-
 
501
      fi
-
 
502
482
      # Rename the file to the real destination.
503
      # Rename the file to the real destination.
483
      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
504
      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
484
505
485
      # The rename failed, perhaps because mv can't rename something else
506
      # The rename failed, perhaps because mv can't rename something else
486
      # to itself, or perhaps because mv is so ancient that it does not
507
      # to itself, or perhaps because mv is so ancient that it does not
487
      # support -f.
508
      # support -f.
488
      {
509
      {
489
	# Now remove or move aside any old file at destination location.
510
        # Now remove or move aside any old file at destination location.
490
	# We try this two ways since rm can't unlink itself on some
511
        # We try this two ways since rm can't unlink itself on some
491
	# systems and the destination file might be busy for other
512
        # systems and the destination file might be busy for other
492
	# reasons.  In this case, the final cleanup might fail but the new
513
        # reasons.  In this case, the final cleanup might fail but the new
493
	# file should still install successfully.
514
        # file should still install successfully.
494
	{
515
        {
495
	  test ! -f "$dst" ||
516
          test ! -f "$dst" ||
496
	  $doit $rmcmd -f "$dst" 2>/dev/null ||
517
          $doit $rmcmd "$dst" 2>/dev/null ||
497
	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
518
          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
498
	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
519
            { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
499
	  } ||
520
          } ||
500
	  { echo "$0: cannot unlink or rename $dst" >&2
521
          { echo "$0: cannot unlink or rename $dst" >&2
501
	    (exit 1); exit 1
522
            (exit 1); exit 1
502
	  }
523
          }
503
	} &&
524
        } &&
504
525
505
	# Now rename the file to the real destination.
526
        # Now rename the file to the real destination.
506
	$doit $mvcmd "$dsttmp" "$dst"
527
        $doit $mvcmd "$dsttmp" "$dst"
507
      }
528
      }
508
    fi || exit 1
529
    fi || exit 1
509
530
510
    trap '' 0
531
    trap '' 0
511
  fi
532
  fi
512
done
533
done
513
534
514
# Local variables:
535
# Local variables:
515
# eval: (add-hook 'write-file-hooks 'time-stamp)
536
# eval: (add-hook 'before-save-hook 'time-stamp)
516
# time-stamp-start: "scriptversion="
537
# time-stamp-start: "scriptversion="
517
# time-stamp-format: "%:y-%02m-%02d.%02H"
538
# time-stamp-format: "%:y-%02m-%02d.%02H"
518
# time-stamp-time-zone: "UTC"
539
# time-stamp-time-zone: "UTC0"
519
# time-stamp-end: "; # UTC"
540
# time-stamp-end: "; # UTC"
520
# End:
541
# End: