]>
git.ipfire.org Git - thirdparty/cups.git/blob - install-sh
5 # Install a program, script, or datafile.
7 # Copyright 2008-2012 by Apple Inc.
9 # This script is not compatible with BSD (or any other) install program, as it
10 # allows owner and group changes to fail with a warning and makes sure that the
11 # destination directory permissions are as specified - BSD install and the
12 # original X11 install script did not change permissions of existing
13 # directories. It also does not support the transform options since CUPS does
16 # Original script from X11R5 (mit/util/scripts/install.sh)
17 # Copyright 1991 by the Massachusetts Institute of Technology
19 # Permission to use, copy, modify, distribute, and sell this software and its
20 # documentation for any purpose is hereby granted without fee, provided that
21 # the above copyright notice appear in all copies and that both that
22 # copyright notice and this permission notice appear in supporting
23 # documentation, and that the name of M.I.T. not be used in advertising or
24 # publicity pertaining to distribution of the software without specific,
25 # written prior permission. M.I.T. makes no representations about the
26 # suitability of this software for any purpose. It is provided "as is"
27 # without express or implied warranty.
29 # Calling this script install-sh is preferred over install.sh, to prevent
30 # `make' implicit rules from creating a file called install from it
31 # when there is no Makefile.
33 # set DOITPROG to echo to test this script
34 # Don't use :- since 4.3BSD and earlier shells don't like it.
37 # Force umask to 022...
40 # put in absolute paths if you don't have them in your path; or use env. vars.
43 chmodprog
="${CHMODPROG-chmod}"
44 chownprog
="${CHOWNPROG-chown}"
45 chgrpprog
="${CHGRPPROG-chgrp}"
46 stripprog
="${STRIPPROG-strip}"
48 mkdirprog
="${MKDIRPROG-mkdir}"
49 gzipprog
="${GZIPPROG-gzip}"
54 chmodcmd
="$chmodprog 0755"
66 $gzipprog -9 <"$1" >"$2"
69 while [ x
"$1" != x
]; do
84 chmodcmd
="$chmodprog $2"
91 chowncmd
="$chownprog $2"
98 chgrpcmd
="$chgrpprog $2"
105 stripcmd
="$stripprog"
117 if [ x
"$src" = x
]; then
128 if [ x
"$src" = x
]; then
129 echo "install-sh: No input file specified"
133 if [ x
"$dir_arg" != x
]; then
137 if [ -d "$dst" ]; then
143 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
144 # might cause directories to be created, which would be especially bad
145 # if $src (and thus $dsttmp) contains '*'.
146 if [ ! -f "$src" -a ! -d "$src" ]; then
147 echo "install: $src does not exist"
151 if [ x
"$dst" = x
]; then
152 echo "install: No destination specified"
156 # If destination is a directory, append the input filename.
157 if [ -d "$dst" ]; then
158 dst
="$dst/`basename $src`"
162 ## this sed command emulates the dirname command
163 dstdir
="`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`"
165 # Make sure that the destination directory exists.
166 # This part is taken from Noah Friedman's mkinstalldirs script
168 # Skip lots of stat calls in the usual case.
169 if [ ! -d "$dstdir" ]; then
172 IFS
="${IFS-${defaultIFS}}"
175 # Some sh's can't handle IFS=/ for some reason.
177 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
182 while [ $# -ne 0 ] ; do
183 pathcomp
="${pathcomp}${1}"
186 if [ ! -d "${pathcomp}" ]; then $doit $mkdirprog "${pathcomp}"; fi
188 pathcomp
="${pathcomp}/"
192 if [ x
"$dir_arg" != x
]; then
193 # Make a directory...
194 $doit $instcmd $dst ||
exit 1
196 # Allow chown/chgrp to fail, but log a warning
197 if [ x
"$chowncmd" != x
]; then $doit $chowncmd $dst ||
echo "warning: Unable to change owner of $dst!"; fi
198 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd $dst ||
echo "warning: Unable to change group of $dst!"; fi
199 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd $dst ||
exit 1; fi
202 dstfile
="`basename $dst`"
204 # Check the destination file - for libraries just use the "-x" option
207 *.a |
*.dylib |
*.sl |
*.sl.
* |
*.so |
*.so.
*)
215 # Make a temp file name in the proper directory.
216 dsttmp
="$dstdir/#inst.$$#"
218 # Move or copy the file name to the temp name
219 $doit $instcmd $src $dsttmp ||
exit 1
221 # Update permissions and strip as needed, then move to the final name.
222 # If the chmod, strip, rm, or mv commands fail, remove the installed
224 if [ x
"$stripcmd" != x
]; then $doit $stripcmd $stripopt "$dsttmp" ||
echo "warning: Unable to strip $dst!"; fi
225 if [ x
"$chowncmd" != x
]; then $doit $chowncmd "$dsttmp" ||
echo "warning: Unable to change owner of $dst!"; fi
226 if [ x
"$chgrpcmd" != x
]; then $doit $chgrpcmd "$dsttmp" ||
echo "warning: Unable to change group of $dst!"; fi
228 trap "rm -f ${dsttmp}" 0 &&
229 if [ x
"$chmodcmd" != x
]; then $doit $chmodcmd "$dsttmp"; fi &&
230 $doit $rmcmd -f "$dstdir/$dstfile" &&
231 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"