1 |
< |
#! /bin/sh |
1 |
> |
#!/bin/sh |
2 |
|
# |
3 |
|
# install - install a program, script, or datafile |
4 |
< |
# This comes from X11R5. |
4 |
> |
# This comes from X11R5 (mit/util/scripts/install.sh). |
5 |
> |
# |
6 |
> |
# Copyright 1991 by the Massachusetts Institute of Technology |
7 |
> |
# |
8 |
> |
# Permission to use, copy, modify, distribute, and sell this software and its |
9 |
> |
# documentation for any purpose is hereby granted without fee, provided that |
10 |
> |
# the above copyright notice appear in all copies and that both that |
11 |
> |
# copyright notice and this permission notice appear in supporting |
12 |
> |
# documentation, and that the name of M.I.T. not be used in advertising or |
13 |
> |
# publicity pertaining to distribution of the software without specific, |
14 |
> |
# written prior permission. M.I.T. makes no representations about the |
15 |
> |
# suitability of this software for any purpose. It is provided "as is" |
16 |
> |
# without express or implied warranty. |
17 |
|
# |
18 |
|
# Calling this script install-sh is preferred over install.sh, to prevent |
19 |
|
# `make' implicit rules from creating a file called install from it |
20 |
|
# when there is no Makefile. |
21 |
|
# |
22 |
|
# This script is compatible with the BSD install script, but was written |
23 |
< |
# from scratch. |
24 |
< |
# |
23 |
> |
# from scratch. It can only install one file at a time, a restriction |
24 |
> |
# shared with many OS's install programs. |
25 |
|
|
26 |
|
|
27 |
|
# set DOITPROG to echo to test this script |
41 |
|
rmprog="${RMPROG-rm}" |
42 |
|
mkdirprog="${MKDIRPROG-mkdir}" |
43 |
|
|
44 |
< |
tranformbasename="" |
44 |
> |
transformbasename="" |
45 |
|
transform_arg="" |
46 |
|
instcmd="$mvprog" |
47 |
|
chmodcmd="$chmodprog 0755" |
109 |
|
echo "install: no input file specified" |
110 |
|
exit 1 |
111 |
|
else |
112 |
< |
true |
112 |
> |
: |
113 |
|
fi |
114 |
|
|
115 |
|
if [ x"$dir_arg" != x ]; then |
118 |
|
|
119 |
|
if [ -d $dst ]; then |
120 |
|
instcmd=: |
121 |
+ |
chmodcmd="" |
122 |
|
else |
123 |
< |
instcmd=mkdir |
123 |
> |
instcmd=$mkdirprog |
124 |
|
fi |
125 |
|
else |
126 |
|
|
128 |
|
# might cause directories to be created, which would be especially bad |
129 |
|
# if $src (and thus $dsttmp) contains '*'. |
130 |
|
|
131 |
< |
if [ -f $src -o -d $src ] |
131 |
> |
if [ -f "$src" ] || [ -d "$src" ] |
132 |
|
then |
133 |
< |
true |
133 |
> |
: |
134 |
|
else |
135 |
|
echo "install: $src does not exist" |
136 |
|
exit 1 |
141 |
|
echo "install: no destination specified" |
142 |
|
exit 1 |
143 |
|
else |
144 |
< |
true |
144 |
> |
: |
145 |
|
fi |
146 |
|
|
147 |
|
# If destination is a directory, append the input filename; if your system |
151 |
|
then |
152 |
|
dst="$dst"/`basename $src` |
153 |
|
else |
154 |
< |
true |
154 |
> |
: |
155 |
|
fi |
156 |
|
fi |
157 |
|
|
163 |
|
|
164 |
|
# Skip lots of stat calls in the usual case. |
165 |
|
if [ ! -d "$dstdir" ]; then |
166 |
< |
defaultIFS=' |
167 |
< |
' |
166 |
> |
defaultIFS=' |
167 |
> |
' |
168 |
|
IFS="${IFS-${defaultIFS}}" |
169 |
|
|
170 |
|
oIFS="${IFS}" |
183 |
|
then |
184 |
|
$mkdirprog "${pathcomp}" |
185 |
|
else |
186 |
< |
true |
186 |
> |
: |
187 |
|
fi |
188 |
|
|
189 |
|
pathcomp="${pathcomp}/" |
194 |
|
then |
195 |
|
$doit $instcmd $dst && |
196 |
|
|
197 |
< |
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && |
198 |
< |
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && |
199 |
< |
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && |
200 |
< |
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi |
197 |
> |
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && |
198 |
> |
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && |
199 |
> |
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && |
200 |
> |
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi |
201 |
|
else |
202 |
|
|
203 |
|
# If we're going to rename the final executable, determine the name now. |
216 |
|
then |
217 |
|
dstfile=`basename $dst` |
218 |
|
else |
219 |
< |
true |
219 |
> |
: |
220 |
|
fi |
221 |
|
|
222 |
|
# Make a temp file name in the proper directory. |
235 |
|
# ignore errors from any of these, just make sure not to ignore |
236 |
|
# errors from the above "$doit $instcmd $src $dsttmp" command. |
237 |
|
|
238 |
< |
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && |
239 |
< |
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && |
240 |
< |
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && |
241 |
< |
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && |
238 |
> |
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && |
239 |
> |
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && |
240 |
> |
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && |
241 |
> |
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && |
242 |
|
|
243 |
|
# Now rename the file to the real destination. |
244 |
|
|