]> granicus.if.org Git - apache/blob - build/install.sh
mod_proxy_http: don't pretend we are sending a body before ProxyErrorOverride
[apache] / build / install.sh
1 #!/bin/sh
2 #
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
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
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.
17 #
18 #
19 # install.sh -- install a program, script or datafile
20 #
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>
25
26 #
27 #   put in absolute paths if you don't have them in your path; 
28 #   or use env. vars.
29 #
30 mvprog="${MVPROG-mv}"
31 cpprog="${CPPROG-cp}"
32 chmodprog="${CHMODPROG-chmod}"
33 chownprog="${CHOWNPROG-chown}"
34 chgrpprog="${CHGRPPROG-chgrp}"
35 stripprog="${STRIPPROG-strip}"
36 rmprog="${RMPROG-rm}"
37
38 #
39 #   parse argument line
40 #
41 instcmd="$mvprog"
42 chmodcmd=""
43 chowncmd=""
44 chgrpcmd=""
45 stripcmd=""
46 rmcmd="$rmprog -f"
47 mvcmd="$mvprog"
48 ext=""
49 src=""
50 dst=""
51 while [ "x$1" != "x" ]; do
52     case $1 in
53         -c) instcmd="$cpprog"
54             shift; continue
55             ;;
56         -m) chmodcmd="$chmodprog $2"
57             shift; shift; continue
58             ;;
59         -o) chowncmd="$chownprog $2"
60             shift; shift; continue
61             ;;
62         -g) chgrpcmd="$chgrpprog $2"
63             shift; shift; continue
64             ;;
65         -s) stripcmd="$stripprog"
66             shift; continue
67             ;;
68         -S) stripcmd="$stripprog $2"
69             shift; shift; continue
70             ;;
71         -e) ext="$2"
72             shift; shift; continue
73             ;;
74         *)  break
75             ;;
76     esac
77 done
78 if test $# -eq 0 ; then
79     echo "install.sh: no input file(s) specified"
80     exit 1
81 fi
82 if test $# -eq 1 ; then
83     echo "install.sh: no destination specified"
84     exit 1
85 fi
86 for arg in "$@" ; do
87     dstarg="$arg"
88 done
89
90 while test $# -gt 1 ; do
91     dst="$dstarg"
92     src="$1"
93     shift
94     #
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
98     #
99     if [ -d $dst ]; then
100         dst="$dst/`basename $src`"
101     fi
102
103     #  Add a possible extension (such as ".exe") to src and dst
104     src="$src$ext"
105     dst="$dst$ext"
106
107     #  Make a temp file name in the proper directory.
108     dstdir=`dirname $dst`
109     dsttmp=$dstdir/#inst.$$#
110
111     #  Move or copy the file name to the temp name
112     $instcmd $src $dsttmp
113
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
119
120     #  Now rename the file to the real destination.
121     $rmcmd $dst
122     $mvcmd $dsttmp $dst
123
124 done
125
126 exit 0
127