3 # Copyright 1999-2004 The Apache Software Foundation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # install.sh -- install a program, script or datafile
20 # Based on `install-sh' from the X Consortium's X11R5 distribution
21 # as of 89/12/18 which is freely available.
22 # Cleaned up for Apache's Autoconf-style Interface (APACI)
23 # by Ralf S. Engelschall <rse apache.org>
26 # put in absolute paths if you don't have them in your path;
31 chmodprog="${CHMODPROG-chmod}"
32 chownprog="${CHOWNPROG-chown}"
33 chgrpprog="${CHGRPPROG-chgrp}"
34 stripprog="${STRIPPROG-strip}"
50 while [ "x$1" != "x" ]; do
55 -m) chmodcmd="$chmodprog $2"
56 shift; shift; continue
58 -o) chowncmd="$chownprog $2"
59 shift; shift; continue
61 -g) chgrpcmd="$chgrpprog $2"
62 shift; shift; continue
64 -s) stripcmd="$stripprog"
67 -S) stripcmd="$stripprog $2"
68 shift; shift; continue
71 shift; shift; continue
73 *) if [ "x$src" = "x" ]; then
82 if [ "x$src" = "x" ]; then
83 echo "install.sh: no input file specified"
86 if [ "x$dst" = "x" ]; then
87 echo "install.sh: no destination specified"
92 # If destination is a directory, append the input filename; if
93 # your system does not like double slashes in filenames, you may
94 # need to add some logic
97 dst="$dst/`basename $src`"
100 # Add a possible extension (such as ".exe") to src and dst
104 # Make a temp file name in the proper directory.
105 dstdir=`dirname $dst`
106 dsttmp=$dstdir/#inst.$$#
108 # Move or copy the file name to the temp name
109 $instcmd $src $dsttmp
111 # And set any options; do chmod last to preserve setuid bits
112 if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
113 if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
114 if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
115 if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
117 # Now rename the file to the real destination.