Develop and Download Open Source Software

Browse CVS Repository

Contents of /canna/www/tryinstall-sh

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Sat Oct 19 18:56:53 2002 UTC (21 years, 6 months ago) by aida_s
Branch: AIDA, MAIN
CVS Tags: www_first, HEAD
Changes since 1.1: +0 -0 lines
Initial WWW page.

1 #!/bin/sh
2 #
3 # tryinstall - install a program, script, or datafile
4 # This comes from GNU autoconf.
5 #
6 # This version of install-sh supports FreeBSD-alike "-C" option.
7 # But this is no completely compatible to FreeBSD's install command.
8 # $Id: tryinstall-sh,v 1.2 2002/10/19 18:41:25 shinra Exp $
9 #
10 # install - install a program, script, or datafile
11 # This comes from X11R5 (mit/util/scripts/install.sh).
12 #
13 # Copyright 1991 by the Massachusetts Institute of Technology
14 #
15 # Permission to use, copy, modify, distribute, and sell this software and its
16 # documentation for any purpose is hereby granted without fee, provided that
17 # the above copyright notice appear in all copies and that both that
18 # copyright notice and this permission notice appear in supporting
19 # documentation, and that the name of M.I.T. not be used in advertising or
20 # publicity pertaining to distribution of the software without specific,
21 # written prior permission. M.I.T. makes no representations about the
22 # suitability of this software for any purpose. It is provided "as is"
23 # without express or implied warranty.
24 #
25 # Calling this script install-sh is preferred over install.sh, to prevent
26 # `make' implicit rules from creating a file called install from it
27 # when there is no Makefile.
28 #
29 # This script is compatible with the BSD install script, but was written
30 # from scratch. It can only install one file at a time, a restriction
31 # shared with many OS's install programs.
32
33
34 # set DOITPROG to echo to test this script
35
36 # Don't use :- since 4.3BSD and earlier shells don't like it.
37 doit="${DOITPROG-}"
38
39
40 # put in absolute paths if you don't have them in your path; or use env. vars.
41
42 mvprog="${MVPROG-mv}"
43 cpprog="${CPPROG-cp}"
44 chmodprog="${CHMODPROG-chmod}"
45 chownprog="${CHOWNPROG-chown}"
46 chgrpprog="${CHGRPPROG-chgrp}"
47 stripprog="${STRIPPROG-strip}"
48 rmprog="${RMPROG-rm}"
49 mkdirprog="${MKDIRPROG-mkdir}"
50 cmpprog="${CMP-cmp}"
51
52 transformbasename=""
53 transform_arg=""
54 instcmd="$mvprog"
55 chmodcmd="$chmodprog 0755"
56 chowncmd=""
57 chgrpcmd=""
58 stripcmd=""
59 rmcmd="$rmprog -f"
60 mvcmd="$mvprog"
61 src=""
62 dst=""
63 dir_arg=""
64 onlyifdiffer=false
65
66 while [ x"$1" != x ]; do
67 case $1 in
68 -c) instcmd="$cpprog"
69 shift
70 continue;;
71
72 -C) instcmd="$cpprog"
73 onlyifdiffer=:
74 shift
75 continue;;
76
77 -d) dir_arg=true
78 shift
79 continue;;
80
81 -m) chmodcmd="$chmodprog $2"
82 shift
83 shift
84 continue;;
85
86 -o) chowncmd="$chownprog $2"
87 shift
88 shift
89 continue;;
90
91 -g) chgrpcmd="$chgrpprog $2"
92 shift
93 shift
94 continue;;
95
96 -s) stripcmd="$stripprog"
97 shift
98 continue;;
99
100 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
101 shift
102 continue;;
103
104 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
105 shift
106 continue;;
107
108 *) if [ x"$src" = x ]
109 then
110 src=$1
111 else
112 # this colon is to work around a 386BSD /bin/sh bug
113 :
114 dst=$1
115 fi
116 shift
117 continue;;
118 esac
119 done
120
121 if [ x"$src" = x ]
122 then
123 echo "install: no input file specified"
124 exit 1
125 else
126 :
127 fi
128
129 if [ x"$dir_arg" != x ]; then
130 dst=$src
131 src=""
132
133 if [ -d $dst ]; then
134 instcmd=:
135 chmodcmd=""
136 else
137 instcmd=$mkdirprog
138 fi
139 else
140
141 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
142 # might cause directories to be created, which would be especially bad
143 # if $src (and thus $dsttmp) contains '*'.
144
145 if [ -f $src -o -d $src ]
146 then
147 :
148 else
149 echo "install: $src does not exist"
150 exit 1
151 fi
152
153 if [ x"$dst" = x ]
154 then
155 echo "install: no destination specified"
156 exit 1
157 else
158 :
159 fi
160
161 # If destination is a directory, append the input filename; if your system
162 # does not like double slashes in filenames, you may need to add some logic
163
164 if [ -d $dst ]
165 then
166 dst="$dst"/`basename $src`
167 else
168 :
169 fi
170 fi
171
172 ## this sed command emulates the dirname command
173 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
174
175 # Make sure that the destination directory exists.
176 # this part is taken from Noah Friedman's mkinstalldirs script
177
178 # Skip lots of stat calls in the usual case.
179 if [ ! -d "$dstdir" ]; then
180 defaultIFS='
181 '
182 IFS="${IFS-${defaultIFS}}"
183
184 oIFS="${IFS}"
185 # Some sh's can't handle IFS=/ for some reason.
186 IFS='%'
187 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
188 IFS="${oIFS}"
189
190 pathcomp=''
191
192 while [ $# -ne 0 ] ; do
193 pathcomp="${pathcomp}${1}"
194 shift
195
196 if [ ! -d "${pathcomp}" ] ;
197 then
198 $mkdirprog "${pathcomp}"
199 else
200 :
201 fi
202
203 pathcomp="${pathcomp}/"
204 done
205 fi
206
207 if [ x"$dir_arg" != x ]
208 then
209 $doit $instcmd $dst &&
210
211 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
212 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
213 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
214 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
215 else
216
217 # If we're going to rename the final executable, determine the name now.
218
219 if [ x"$transformarg" = x ]
220 then
221 dstfile=`basename $dst`
222 else
223 dstfile=`basename $dst $transformbasename |
224 sed $transformarg`$transformbasename
225 fi
226
227 # don't allow the sed command to completely eliminate the filename
228
229 if [ x"$dstfile" = x ]
230 then
231 dstfile=`basename $dst`
232 else
233 :
234 fi
235
236 # check if src and dst is differ.
237 if $onlyifdiffer && [ -r $dstdir/$dstfile ]; then
238 $cmpprog -s $src $dstdir/$dstfile && exit 0
239 fi
240
241 # Make a temp file name in the proper directory.
242
243 dsttmp=$dstdir/#inst.$$#
244
245 # Move or copy the file name to the temp name
246
247 $doit $instcmd $src $dsttmp &&
248
249 trap "rm -f ${dsttmp}" 0 &&
250
251 # and set any options; do chmod last to preserve setuid bits
252
253 # If any of these fail, we abort the whole thing. If we want to
254 # ignore errors from any of these, just make sure not to ignore
255 # errors from the above "$doit $instcmd $src $dsttmp" command.
256
257 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
258 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
259 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
260 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
261
262 # Now rename the file to the real destination.
263
264 $doit $rmcmd -f $dstdir/$dstfile &&
265 $doit $mvcmd $dsttmp $dstdir/$dstfile
266
267 fi &&
268
269
270 exit 0

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26