]>
git.ipfire.org Git - thirdparty/cups.git/blob - install-sh
3 # install - install a program, script, or datafile
4 # This comes from X11R5 (mit/util/scripts/install.sh).
6 # Library stripping changes Copyright 2008 by Apple Inc.
7 # Copyright 1991 by the Massachusetts Institute of Technology
9 # Permission to use, copy, modify, distribute, and sell this software and its
10 # documentation for any purpose is hereby granted without fee, provided that
11 # the above copyright notice appear in all copies and that both that
12 # copyright notice and this permission notice appear in supporting
13 # documentation, and that the name of M.I.T. not be used in advertising or
14 # publicity pertaining to distribution of the software without specific,
15 # written prior permission. M.I.T. makes no representations about the
16 # suitability of this software for any purpose. It is provided "as is"
17 # without express or implied warranty.
19 # Calling this script install-sh is preferred over install.sh, to prevent
20 # `make' implicit rules from creating a file called install from it
21 # when there is no Makefile.
23 # This script is compatible with the BSD install script, but was written
24 # from scratch. It can only install one file at a time, a restriction
25 # shared with many OS's install programs.
28 # set DOITPROG to echo to test this script
30 # Don't use :- since 4.3BSD and earlier shells don't like it.
34 # put in absolute paths if you don't have them in your path; or use env. vars.
38 chmodprog
="${CHMODPROG-chmod}"
39 chownprog
="${CHOWNPROG-chown}"
40 chgrpprog
="${CHGRPPROG-chgrp}"
41 stripprog
="${STRIPPROG-strip}"
43 mkdirprog
="${MKDIRPROG-mkdir}"
48 chmodcmd
="$chmodprog 0755"
58 while [ x
"$1" != x
]; do
68 -m) chmodcmd
="$chmodprog $2"
73 -o) chowncmd
="$chownprog $2"
78 -g) chgrpcmd
="$chgrpprog $2"
83 -s) stripcmd
="$stripprog"
87 -t=*) transformarg
=`echo $1 | sed 's/-t=//'`
91 -b=*) transformbasename
=`echo $1 | sed 's/-b=//'`
99 # this colon is to work around a 386BSD /bin/sh bug
110 echo "install: no input file specified"
116 if [ x
"$dir_arg" != x
]; then
128 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
129 # might cause directories to be created, which would be especially bad
130 # if $src (and thus $dsttmp) contains '*'.
132 if [ -f $src -o -d $src ]
136 echo "install: $src does not exist"
142 echo "install: no destination specified"
148 # If destination is a directory, append the input filename; if your system
149 # does not like double slashes in filenames, you may need to add some logic
153 dst
="$dst"/`basename $src`
159 ## this sed command emulates the dirname command
160 dstdir
=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
162 # Make sure that the destination directory exists.
163 # this part is taken from Noah Friedman's mkinstalldirs script
165 # Skip lots of stat calls in the usual case.
166 if [ ! -d "$dstdir" ]; then
169 IFS
="${IFS-${defaultIFS}}"
172 # Some sh's can't handle IFS=/ for some reason.
174 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
179 while [ $# -ne 0 ] ; do
180 pathcomp
="${pathcomp}${1}"
183 if [ ! -d "${pathcomp}" ] ;
185 $mkdirprog "${pathcomp}" &&
186 if [ x
"$chowncmd" != x
]; then $doit $chowncmd "$pathcomp"; else : ; fi &&
187 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd "$pathcomp"; else : ; fi
192 pathcomp
="${pathcomp}/"
196 if [ x
"$dir_arg" != x
]
198 $doit $instcmd $dst &&
200 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dst; else : ; fi &&
201 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dst; else : ; fi &&
202 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dst; else : ; fi
205 # If we're going to rename the final executable, determine the name now.
207 if [ x
"$transformarg" = x
]
209 dstfile
=`basename $dst`
211 dstfile
=`basename $dst $transformbasename |
212 sed $transformarg`$transformbasename
215 # don't allow the sed command to completely eliminate the filename
217 if [ x
"$dstfile" = x
]
219 dstfile
=`basename $dst`
224 # Check the destination file - for libraries just use the "-x" option to strip
226 *.a |
*.dylib |
*.sl |
*.sl.
* |
*.so |
*.so.
*)
234 # Make a temp file name in the proper directory.
236 dsttmp
=$dstdir/#inst.$$#
238 # Move or copy the file name to the temp name
240 $doit $instcmd $src $dsttmp &&
242 trap "rm -f ${dsttmp}" 0 &&
244 # and set any options; do chmod last to preserve setuid bits
246 # If any of these fail, we abort the whole thing. If we want to
247 # ignore errors from any of these, just make sure not to ignore
248 # errors from the above "$doit $instcmd $src $dsttmp" command.
250 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dsttmp; else :;fi &&
251 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dsttmp; else :;fi &&
252 if [ x
"$stripcmd" != x
]; then $doit $stripcmd $stripopt $dsttmp; else :;fi &&
253 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dsttmp; else :;fi &&
255 # Now rename the file to the real destination.
257 $doit $rmcmd -f $dstdir/$dstfile &&
258 $doit $mvcmd $dsttmp $dstdir/$dstfile