5 # install - install a program, script, or datafile
6 # This comes from X11R5; it is not part of GNU.
8 # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
10 # This script is compatible with the BSD install script, but was written
15 # set DOITPROG to echo to test this script
17 # Don't use :- since 4.3BSD and earlier shells don't like it.
21 # put in absolute paths if you don't have them in your path; or use env. vars.
25 chmodprog
="${CHMODPROG-chmod}"
26 chownprog
="${CHOWNPROG-chown}"
27 chgrpprog
="${CHGRPPROG-chgrp}"
28 stripprog
="${STRIPPROG-strip}"
30 mkdirprog
="${MKDIRPROG-mkdir}"
44 while [ x
"$1" != x
]; do
50 -m) chmodcmd
="$chmodprog $2"
55 -o) chowncmd
="$chownprog $2"
60 -g) chgrpcmd
="$chgrpprog $2"
65 -s) stripcmd
="$stripprog"
69 -t=*) transformarg
=`echo $1 | sed 's/-t=//'`
73 -b=*) transformbasename
=`echo $1 | sed 's/-b=//'`
81 # this colon is to work around a 386BSD /bin/sh bug
92 echo "install: no input file specified"
98 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
99 # might cause directories to be created, which would be especially bad
100 # if $src (and thus $dsttmp) contains '*'.
102 if [ -f $src -o -d $src ]
106 echo "install: $src does not exist"
112 echo "install: no destination specified"
118 # If destination is a directory, append the input filename; if your system
119 # does not like double slashes in filenames, you may need to add some logic
123 dst
="$dst"/`basename $src`
129 # Make a temp file name in the proper directory.
131 ## this sed command emulates the dirname command
132 dstdir
=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
133 dsttmp
=$dstdir/#inst.$$#
135 # Make sure that the destination directory exists.
136 # this part is taken from Noah Friedman's mkinstalldirs script
140 IFS
="${IFS-${defaultIFS}}"
143 # Some sh's can't handle IFS=/ for some reason.
145 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
150 while [ $# -ne 0 ] ; do
151 pathcomp
="${pathcomp}${1}"
154 if [ ! -d "${pathcomp}" ] ;
156 $mkdirprog "${pathcomp}"
161 pathcomp
="${pathcomp}/"
164 # If we're going to rename the final executable, determine the name now.
166 if [ x
"$transformarg" = x
]
168 dstfile
=`basename $dst`
170 dstfile
=`basename $dst $transformbasename | sed $transformarg`$transformbasename
173 # don't allow the sed command to completely eliminate the filename
175 if [ x
"$dstfile" = x
]
177 dstfile
=`basename $dst`
182 # Move or copy the file name to the temp name
184 $doit $instcmd $src $dsttmp &&
186 trap "rm -f ${dsttmp}" 0 &&
188 # and set any options; do chmod last to preserve setuid bits
190 # If any of these fail, we abort the whole thing. If we want to
191 # ignore errors from any of these, just make sure not to ignore
192 # errors from the above "$doit $instcmd $src $dsttmp" command.
194 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dsttmp; else true
; fi &&
195 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dsttmp; else true
; fi &&
196 if [ x
"$stripcmd" != x
]; then $doit $stripcmd $dsttmp; else true
; fi &&
197 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dsttmp; else true
; fi &&
199 # Now rename the file to the real destination.
201 $doit $rmcmd -f $dstdir/$dstfile &&
202 $doit $mvcmd $dsttmp $dstdir/$dstfile &&
This page took 0.032747 seconds and 4 git commands to generate.