3 # fontconfig/config/install.sh
5 # install - install a program, script, or datafile
6 # This comes from X11R5.
8 # Calling this script install-sh is preferred over install.sh, to prevent
9 # `make' implicit rules from creating a file called install from it
10 # when there is no Makefile.
12 # This script is compatible with the BSD install script, but was written
17 # set DOITPROG to echo to test this script
19 # Don't use :- since 4.3BSD and earlier shells don't like it.
23 # put in absolute paths if you don't have them in your path; or use env. vars.
27 chmodprog="${CHMODPROG-chmod}"
28 chownprog="${CHOWNPROG-chown}"
29 chgrpprog="${CHGRPPROG-chgrp}"
30 stripprog="${STRIPPROG-strip}"
32 mkdirprog="${MKDIRPROG-mkdir}"
37 chmodcmd="$chmodprog 0755"
47 while [ x"$1" != x ]; do
57 -m) chmodcmd="$chmodprog $2"
62 -o) chowncmd="$chownprog $2"
67 -g) chgrpcmd="$chgrpprog $2"
72 -s) stripcmd="$stripprog"
76 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
80 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
88 # this colon is to work around a 386BSD /bin/sh bug
99 echo "install: no input file specified"
105 if [ x"$dir_arg" != x ]; then
116 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
117 # might cause directories to be created, which would be especially bad
118 # if $src (and thus $dsttmp) contains '*'.
120 if [ -f $src -o -d $src ]
124 echo "install: $src does not exist"
130 echo "install: no destination specified"
136 # If destination is a directory, append the input filename; if your system
137 # does not like double slashes in filenames, you may need to add some logic
141 dst="$dst"/`basename $src`
147 ## this sed command emulates the dirname command
148 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
150 # Make sure that the destination directory exists.
151 # this part is taken from Noah Friedman's mkinstalldirs script
153 # Skip lots of stat calls in the usual case.
154 if [ ! -d "$dstdir" ]; then
157 IFS="${IFS-${defaultIFS}}"
160 # Some sh's can't handle IFS=/ for some reason.
162 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
167 while [ $# -ne 0 ] ; do
168 pathcomp="${pathcomp}${1}"
171 if [ ! -d "${pathcomp}" ] ;
173 $mkdirprog "${pathcomp}"
178 pathcomp="${pathcomp}/"
182 if [ x"$dir_arg" != x ]
184 $doit $instcmd $dst &&
186 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
187 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
188 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
189 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
192 # If we're going to rename the final executable, determine the name now.
194 if [ x"$transformarg" = x ]
196 dstfile=`basename $dst`
198 dstfile=`basename $dst $transformbasename |
199 sed $transformarg`$transformbasename
202 # don't allow the sed command to completely eliminate the filename
204 if [ x"$dstfile" = x ]
206 dstfile=`basename $dst`
211 # Make a temp file name in the proper directory.
213 dsttmp=$dstdir/#inst.$$#
215 # Move or copy the file name to the temp name
217 $doit $instcmd $src $dsttmp &&
219 trap "rm -f ${dsttmp}" 0 &&
221 # and set any options; do chmod last to preserve setuid bits
223 # If any of these fail, we abort the whole thing. If we want to
224 # ignore errors from any of these, just make sure not to ignore
225 # errors from the above "$doit $instcmd $src $dsttmp" command.
227 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
228 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
229 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
230 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
232 # Now rename the file to the real destination.
234 $doit $rmcmd -f $dstdir/$dstfile &&
235 $doit $mvcmd $dsttmp $dstdir/$dstfile