8618aec6691806732d6dea9664bff297b978df39
3 # Copyright 1991 by the Massachusetts Institute of Technology
5 # Permission to use, copy, modify, distribute, and sell this software and its
6 # documentation for any purpose is hereby granted without fee, provided that
7 # the above copyright notice appear in all copies and that both that
8 # copyright notice and this permission notice appear in supporting
9 # documentation, and that the name of M.I.T. not be used in advertising or
10 # publicity pertaining to distribution of the software without specific,
11 # written prior permission. M.I.T. makes no representations about the
12 # suitability of this software for any purpose. It is provided "as is"
13 # without express or implied warranty.
15 # install - install a program, script, or datafile
16 # The original version of this script came from X11R5
17 # (mit/util/scripts/install.sh); it is not part of GNU.
19 # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
21 # This script is compatible with the BSD install script, but was written
24 # At Cygnus this script is duplicated as:
32 # if you change one of these, you will probably want to change them
33 # all. Variants of it also appear in:
38 # however these versions are the versions of this script from the
39 # original Tcl/Tk distribution, and are somewhat different, and so
40 # changing these will result in divergences from the Tcl/Tk
45 # set DOITPROG to echo to test this script
47 # Don't use :- since 4.3BSD and earlier shells don't like it.
51 # put in absolute paths if you don't have them in your path; or use env. vars.
55 chmodprog
="${CHMODPROG-chmod}"
56 chownprog
="${CHOWNPROG-chown}"
57 chgrpprog
="${CHGRPPROG-chgrp}"
58 stripprog
="${STRIPPROG-strip}"
60 mkdirprog
="${MKDIRPROG-mkdir}"
65 chmodcmd
="$chmodprog 0755"
75 while [ x
"$1" != x
]; do
85 -m) chmodcmd
="$chmodprog $2"
90 -o) chowncmd
="$chownprog $2"
95 -g) chgrpcmd
="$chgrpprog $2"
100 -s) stripcmd
="$stripprog"
104 -t=*) transformarg
=`echo $1 | sed 's/-t=//'`
108 -b=*) transformbasename
=`echo $1 | sed 's/-b=//'`
112 *) if [ x
"$src" = x
]
116 # this colon is to work around a 386BSD /bin/sh bug
127 echo "install: no input file specified"
133 if [ x
"$dir_arg" != x
]; then
144 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
145 # might cause directories to be created, which would be especially bad
146 # if $src (and thus $dsttmp) contains '*'.
148 if [ -f $src -o -d $src ]
152 echo "install: $src does not exist"
158 echo "install: no destination specified"
164 # If destination is a directory, append the input filename; if your system
165 # does not like double slashes in filenames, you may need to add some logic
169 dst
="$dst"/`basename $src`
175 ## this sed command emulates the dirname command
176 dstdir
=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
178 # Make sure that the destination directory exists.
179 # this part is taken from Noah Friedman's mkinstalldirs script
181 # Skip lots of stat calls in the usual case.
182 if [ ! -d "$dstdir" ]; then
185 IFS
="${IFS-${defaultIFS}}"
188 # Some sh's can't handle IFS=/ for some reason.
190 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
195 while [ $# -ne 0 ] ; do
196 pathcomp
="${pathcomp}${1}"
199 if [ ! -d "${pathcomp}" ] ;
201 $mkdirprog "${pathcomp}"
206 pathcomp
="${pathcomp}/"
210 if [ x
"$dir_arg" != x
]
212 $doit $instcmd $dst &&
214 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dst; else true
; fi &&
215 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dst; else true
; fi &&
216 if [ x
"$stripcmd" != x
]; then $doit $stripcmd $dst; else true
; fi &&
217 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dst; else true
; fi
220 # If we're going to rename the final executable, determine the name now.
222 if [ x
"$transformarg" = x
]
224 dstfile
=`basename $dst`
226 dstfile
=`basename $dst $transformbasename |
227 sed $transformarg`$transformbasename
230 # don't allow the sed command to completely eliminate the filename
232 if [ x
"$dstfile" = x
]
234 dstfile
=`basename $dst`
239 # Make a temp file name in the proper directory.
241 dsttmp
=$dstdir/#inst.$$#
243 # Move or copy the file name to the temp name
245 $doit $instcmd $src $dsttmp &&
247 trap "rm -f ${dsttmp}" 0 &&
249 # and set any options; do chmod last to preserve setuid bits
251 # If any of these fail, we abort the whole thing. If we want to
252 # ignore errors from any of these, just make sure not to ignore
253 # errors from the above "$doit $instcmd $src $dsttmp" command.
255 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dsttmp; else true
;fi &&
256 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dsttmp; else true
;fi &&
257 if [ x
"$stripcmd" != x
]; then $doit $stripcmd $dsttmp; else true
;fi &&
258 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dsttmp; else true
;fi &&
260 # Now rename the file to the real destination.
262 $doit $rmcmd -f $dstdir/$dstfile &&
263 $doit $mvcmd $dsttmp $dstdir/$dstfile
This page took 0.035246 seconds and 4 git commands to generate.