summaryrefslogtreecommitdiffstats
path: root/install-sh
diff options
context:
space:
mode:
authorKelley Cook <kcook@gcc.gnu.org>2004-09-23 01:21:50 +0000
committerR. Kelley Cook <kcook@gcc.gnu.org>2004-09-23 01:21:50 +0000
commit85f59630d86f7ac17f7fab129d0a758c684f6557 (patch)
tree0ce5b0ac94a126a4b9e01591de64ca22f7c57216 /install-sh
parentMakefile.am: Run aclocal with -I ../config (diff)
downloadgcc-85f59630d86f7ac17f7fab129d0a758c684f6557.tar.gz
gcc-85f59630d86f7ac17f7fab129d0a758c684f6557.tar.bz2
gcc-85f59630d86f7ac17f7fab129d0a758c684f6557.tar.xz
config.guess: New upstream version
2004-09-23 Kelley Cook <kcook@gcc.gnu.org> * config.guess: New upstream version * compile, depcomp, install-sh, ylwrap: Likewise. From-SVN: r87914
Diffstat (limited to 'install-sh')
-rwxr-xr-xinstall-sh134
1 files changed, 70 insertions, 64 deletions
diff --git a/install-sh b/install-sh
index 77bc38144f2..dd97db7aa1c 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2# install - install a program, script, or datafile 2# install - install a program, script, or datafile
3 3
4scriptversion=2004-02-15.20 4scriptversion=2004-09-10.20
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
@@ -58,9 +58,6 @@ stripprog="${STRIPPROG-strip}"
58rmprog="${RMPROG-rm}" 58rmprog="${RMPROG-rm}"
59mkdirprog="${MKDIRPROG-mkdir}" 59mkdirprog="${MKDIRPROG-mkdir}"
60 60
61transformbasename=
62transform_arg=
63instcmd="$mvprog"
64chmodcmd="$chmodprog 0755" 61chmodcmd="$chmodprog 0755"
65chowncmd= 62chowncmd=
66chgrpcmd= 63chgrpcmd=
@@ -70,23 +67,27 @@ mvcmd="$mvprog"
70src= 67src=
71dst= 68dst=
72dir_arg= 69dir_arg=
70dstarg=
71no_target_directory=
73 72
74usage="Usage: $0 [OPTION]... SRCFILE DSTFILE 73usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
75 or: $0 [OPTION]... SRCFILES... DIRECTORY 74 or: $0 [OPTION]... SRCFILES... DIRECTORY
76 or: $0 -d DIRECTORIES... 75 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
76 or: $0 [OPTION]... -d DIRECTORIES...
77 77
78In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default. 78In the 1st form, copy SRCFILE to DSTFILE.
79In the second, create the directory path DIR. 79In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
80In the 4th, create DIRECTORIES.
80 81
81Options: 82Options:
82-b=TRANSFORMBASENAME 83-c (ignored)
83-c copy source (using $cpprog) instead of moving (using $mvprog).
84-d create directories instead of installing files. 84-d create directories instead of installing files.
85-g GROUP $chgrp installed files to GROUP. 85-g GROUP $chgrpprog installed files to GROUP.
86-m MODE $chmod installed files to MODE. 86-m MODE $chmodprog installed files to MODE.
87-o USER $chown installed files to USER. 87-o USER $chownprog installed files to USER.
88-s strip installed files (using $stripprog). 88-s $stripprog installed files.
89-t=TRANSFORM 89-t DIRECTORY install into DIRECTORY.
90-T report an error if DSTFILE is a directory.
90--help display this help and exit. 91--help display this help and exit.
91--version display version info and exit. 92--version display version info and exit.
92 93
@@ -96,12 +97,7 @@ Environment variables override the default commands:
96 97
97while test -n "$1"; do 98while test -n "$1"; do
98 case $1 in 99 case $1 in
99 -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 100 -c) shift
100 shift
101 continue;;
102
103 -c) instcmd=$cpprog
104 shift
105 continue;; 101 continue;;
106 102
107 -d) dir_arg=true 103 -d) dir_arg=true
@@ -129,14 +125,20 @@ while test -n "$1"; do
129 shift 125 shift
130 continue;; 126 continue;;
131 127
132 -t=*) transformarg=`echo $1 | sed 's/-t=//'` 128 -t) dstarg=$2
133 shift 129 shift
134 continue;; 130 shift
131 continue;;
132
133 -T) no_target_directory=true
134 shift
135 continue;;
135 136
136 --version) echo "$0 $scriptversion"; exit 0;; 137 --version) echo "$0 $scriptversion"; exit 0;;
137 138
138 *) # When -d is used, all remaining arguments are directories to create. 139 *) # When -d is used, all remaining arguments are directories to create.
139 test -n "$dir_arg" && break 140 # When -t is used, the destination is already specified.
141 test -n "$dir_arg$dstarg" && break
140 # Otherwise, the last argument is the destination. Remove it from $@. 142 # Otherwise, the last argument is the destination. Remove it from $@.
141 for arg 143 for arg
142 do 144 do
@@ -174,13 +176,13 @@ do
174 src= 176 src=
175 177
176 if test -d "$dst"; then 178 if test -d "$dst"; then
177 instcmd=: 179 mkdircmd=:
178 chmodcmd= 180 chmodcmd=
179 else 181 else
180 instcmd=$mkdirprog 182 mkdircmd=$mkdirprog
181 fi 183 fi
182 else 184 else
183 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 185 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
184 # might cause directories to be created, which would be especially bad 186 # might cause directories to be created, which would be especially bad
185 # if $src (and thus $dsttmp) contains '*'. 187 # if $src (and thus $dsttmp) contains '*'.
186 if test ! -f "$src" && test ! -d "$src"; then 188 if test ! -f "$src" && test ! -d "$src"; then
@@ -202,6 +204,10 @@ do
202 # If destination is a directory, append the input filename; won't work 204 # If destination is a directory, append the input filename; won't work
203 # if double slashes aren't ignored. 205 # if double slashes aren't ignored.
204 if test -d "$dst"; then 206 if test -d "$dst"; then
207 if test -n "$no_target_directory"; then
208 echo "$0: $dstarg: Is a directory" >&2
209 exit 1
210 fi
205 dst=$dst/`basename "$src"` 211 dst=$dst/`basename "$src"`
206 fi 212 fi
207 fi 213 fi
@@ -229,77 +235,77 @@ do
229 pathcomp=$pathcomp$1 235 pathcomp=$pathcomp$1
230 shift 236 shift
231 if test ! -d "$pathcomp"; then 237 if test ! -d "$pathcomp"; then
232 $mkdirprog "$pathcomp" || lasterr=$? 238 $mkdirprog "$pathcomp"
233 # mkdir can fail with a `File exist' error in case several 239 # mkdir can fail with a `File exist' error in case several
234 # install-sh are creating the directory concurrently. This 240 # install-sh are creating the directory concurrently. This
235 # is OK. 241 # is OK.
236 test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; } 242 test -d "$pathcomp" || exit
237 fi 243 fi
238 pathcomp=$pathcomp/ 244 pathcomp=$pathcomp/
239 done 245 done
240 fi 246 fi
241 247
242 if test -n "$dir_arg"; then 248 if test -n "$dir_arg"; then
243 $doit $instcmd "$dst" \ 249 $doit $mkdircmd "$dst" \
244 && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ 250 && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
245 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ 251 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
246 && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ 252 && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
247 && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } 253 && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
248 254
249 else 255 else
250 # If we're going to rename the final executable, determine the name now. 256 dstfile=`basename "$dst"`
251 if test -z "$transformarg"; then
252 dstfile=`basename "$dst"`
253 else
254 dstfile=`basename "$dst" $transformbasename \
255 | sed $transformarg`$transformbasename
256 fi
257
258 # don't allow the sed command to completely eliminate the filename.
259 test -z "$dstfile" && dstfile=`basename "$dst"`
260 257
261 # Make a couple of temp file names in the proper directory. 258 # Make a couple of temp file names in the proper directory.
262 dsttmp=$dstdir/_inst.$$_ 259 dsttmp=$dstdir/_inst.$$_
263 rmtmp=$dstdir/_rm.$$_ 260 rmtmp=$dstdir/_rm.$$_
264 261
265 # Trap to clean up those temp files at exit. 262 # Trap to clean up those temp files at exit.
266 trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 263 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
267 trap '(exit $?); exit' 1 2 13 15 264 trap '(exit $?); exit' 1 2 13 15
268 265
269 # Move or copy the file name to the temp name 266 # Copy the file name to the temp name.
270 $doit $instcmd "$src" "$dsttmp" && 267 $doit $cpprog "$src" "$dsttmp" &&
271 268
272 # and set any options; do chmod last to preserve setuid bits. 269 # and set any options; do chmod last to preserve setuid bits.
273 # 270 #
274 # If any of these fail, we abort the whole thing. If we want to 271 # If any of these fail, we abort the whole thing. If we want to
275 # ignore errors from any of these, just make sure not to ignore 272 # ignore errors from any of these, just make sure not to ignore
276 # errors from the above "$doit $instcmd $src $dsttmp" command. 273 # errors from the above "$doit $cpprog $src $dsttmp" command.
277 # 274 #
278 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ 275 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
279 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ 276 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
280 && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ 277 && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
281 && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && 278 && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
282 279
283 # Now remove or move aside any old file at destination location. We
284 # try this two ways since rm can't unlink itself on some systems and
285 # the destination file might be busy for other reasons. In this case,
286 # the final cleanup might fail but the new file should still install
287 # successfully.
288 {
289 if test -f "$dstdir/$dstfile"; then
290 $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
291 || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
292 || {
293 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
294 (exit 1); exit
295 }
296 else
297 :
298 fi
299 } &&
300
301 # Now rename the file to the real destination. 280 # Now rename the file to the real destination.
302 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" 281 { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
282 || {
283 # The rename failed, perhaps because mv can't rename something else
284 # to itself, or perhaps because mv is so ancient that it does not
285 # support -f.
286
287 # Now remove or move aside any old file at destination location.
288 # We try this two ways since rm can't unlink itself on some
289 # systems and the destination file might be busy for other
290 # reasons. In this case, the final cleanup might fail but the new
291 # file should still install successfully.
292 {
293 if test -f "$dstdir/$dstfile"; then
294 $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
295 || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
296 || {
297 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
298 (exit 1); exit
299 }
300 else
301 :
302 fi
303 } &&
304
305 # Now rename the file to the real destination.
306 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
307 }
308 }
303 fi || { (exit 1); exit; } 309 fi || { (exit 1); exit; }
304done 310done
305 311