3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 # install.sh -- install a program, script or datafile
21 # Based on `install-sh' from the X Consortium's X11R5 distribution
22 # as of 89/12/18 which is freely available.
23 # Cleaned up for Apache's Autoconf-style Interface (APACI)
24 # by Ralf S. Engelschall <rse apache.org>
27 # put in absolute paths if you don't have them in your path;
32 chmodprog="${CHMODPROG-chmod}"
33 chownprog="${CHOWNPROG-chown}"
34 chgrpprog="${CHGRPPROG-chgrp}"
35 stripprog="${STRIPPROG-strip}"
51 while [ "x$1" != "x" ]; do
56 -m) chmodcmd="$chmodprog $2"
57 shift; shift; continue
59 -o) chowncmd="$chownprog $2"
60 shift; shift; continue
62 -g) chgrpcmd="$chgrpprog $2"
63 shift; shift; continue
65 -s) stripcmd="$stripprog"
68 -S) stripcmd="$stripprog $2"
69 shift; shift; continue
72 shift; shift; continue
78 if test $# -eq 0 ; then
79 echo "install.sh: no input file(s) specified"
82 if test $# -eq 1 ; then
83 echo "install.sh: no destination specified"
90 while test $# -gt 1 ; do
95 # If destination is a directory, append the input filename; if
96 # your system does not like double slashes in filenames, you may
97 # need to add some logic
100 dst="$dst/`basename $src`"
103 # Add a possible extension (such as ".exe") to src and dst
107 # Make a temp file name in the proper directory.
108 dstdir=`dirname $dst`
109 dsttmp=$dstdir/#inst.$$#
111 # Move or copy the file name to the temp name
112 $instcmd $src $dsttmp
114 # And set any options; do chmod last to preserve setuid bits
115 if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
116 if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
117 if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
118 if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
120 # Now rename the file to the real destination.