]> granicus.if.org Git - apache/blob - build/binbuild.sh
Final phase of shell programming style consistancy check.
[apache] / build / binbuild.sh
1 #!/bin/sh
2 #
3 # binbuild.sh - Builds an Apache binary distribution.
4 # Initially written by Lars Eilebrecht <lars@apache.org>.
5 #
6 # This script falls under the Apache License.
7 # See http://www.apache.org/docs/LICENSE
8
9
10 APDIR=`pwd`
11 APDIR=`basename $APDIR`
12 VER=`echo $APDIR |sed s/apache-//`
13 OS=`src/helpers/GuessOS`
14 USER="`src/helpers/buildinfo.sh -n %u@%h%d`"
15 TAR="`src/helpers/PrintPath tar`"
16 GTAR="`src/helpers/PrintPath gtar`"
17 GZIP="`src/helpers/PrintPath gzip`"
18 CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max"
19
20 if [ ! -f ./ABOUT_APACHE ]
21 then
22   echo "ERROR: The current directory contains no valid Apache distribution."
23   echo "Please change the directory to the top level directory of a freshly"
24   echo "unpacked Apache 1.3 source distribution and re-execute the script"
25   echo "'./src/helpers/bindbuild.sh'." 
26   exit 1;
27 fi
28
29 if [ -d ./CVS ]
30 then
31   echo "ERROR: The current directory is a CVS checkout of Apache."
32   echo "Only a standard Apache 1.3 source distribution should be used to"
33   echo "create a binary distribution."
34   exit 1;
35 fi
36
37 echo "Building Apache $VER binary distribution..."
38 echo "Platform is \"$OS\"..."
39
40 ( echo "Build log for Apache binary distribution" && \
41   echo "----------------------------------------------------------------------" && \
42   ./configure $CONFIGPARAM && \
43   echo "----------------------------------------------------------------------" && \
44   make clean && \
45   rm -rf bindist install-bindist.sh *.bindist
46   echo "----------------------------------------------------------------------" && \
47   make && \
48   echo "----------------------------------------------------------------------" && \
49   make install-quiet root="bindist/" && \
50   echo "----------------------------------------------------------------------" && \
51   make clean && \
52   echo "----------------------------------------------------------------------" && \
53   echo "[EOF]" \
54 ) > build.log 2>&1
55
56 if [ ! -f ./bindist/bin/httpd ]
57 then
58   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
59   exit 1;
60 fi
61
62 echo "Binary images successfully created..."
63 echo "Creating supplementary files..."
64
65 ( echo " " && \
66   echo "Apache $VER binary distribution" && \
67   echo "================================" && \
68   echo " " && \
69   echo "This binary distribution is usable on a \"$OS\"" && \
70   echo "system and was built by \"$USER\"." && \
71   echo "" && \
72   echo "The distribution contains all standard Apache modules as shared" && \
73   echo "objects. This allows you to enable or disable particular modules" && \
74   echo "with the LoadModule/AddModule directives in the configuration file" && \
75   echo "without the need to re-compile Apache." && \
76   echo "" && \
77   echo "See \"INSTALL.bindist\" on how to install the distribution." && \
78   echo " " && \
79   echo "NOTE: Please do not send support-related mails to the address mentioned" && \
80   echo "      above or to any member of the Apache Group! Support questions" && \
81   echo "      should be directed to the \"comp.infosystems.www.servers.unix\"" && \
82   echo "      or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
83   echo "      (as appropriate for the platform you use), where some of the" && \
84   echo "      Apache team lurk, in the company of many other Apache gurus" && \
85   echo "      who should be able to help." && \
86   echo "      If you think you found a bug in Apache or have a suggestion please" && \
87   echo "      visit the bug report page at http://www.apache.org/bug_report.html" && \
88   echo " " && \
89   echo "----------------------------------------------------------------------" && \
90   ./bindist/bin/httpd -V && \
91   echo "----------------------------------------------------------------------" \
92 ) > README.bindist
93 cp README.bindist ../apache-$VER-$OS.README
94
95 ( echo " " && \
96   echo "Apache $VER binary installation" && \
97   echo "================================" && \
98   echo " " && \
99   echo "To install this binary distribution you have to execute the installation" && \
100   echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
101   echo " " && \
102   echo "The script takes the ServerRoot directory into which you want to install" && \
103   echo "Apache as an option. If you ommit the option the default path" && \
104   echo "\"/usr/local/apache\" is used." && \
105   echo "Make sure you have write permissions in the target directory, e.g. switch" && \
106   echo "to user \"root\" before you execute the script." && \
107   echo " " && \
108   echo "See \"README.bindist\" for further details about this distribution." && \
109   echo " " && \
110   echo "Please note that this distribution includes the complete Apache source code." && \
111   echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
112   echo "installation on your system." && \
113   echo "See \"INSTALL\" for details on how to accomplish this." && \
114   echo " " \
115 ) > INSTALL.bindist
116
117 ( echo "#!/bin/sh" && \
118   echo "#" && \
119   echo "# Usage: install-bindist.sh [ServerRoot]" && \
120   echo "# This script installs the Apache binary distribution and" && \
121   echo "# was automatically created by binbuild.sh." && \
122   echo " " && \
123   echo "if [ .\$1 = . ]" && \
124   echo "then" && \
125   echo "  SR=/usr/local/apache" && \
126   echo "else" && \
127   echo "  SR=\$1" && \
128   echo "fi" && \
129   echo "echo \"Installing binary distribution for platform $OS\"" && \
130   echo "echo \"into directory \$SR ...\"" && \
131   echo "./src/helpers/mkdir.sh \$SR" && \
132   echo "cp -r bindist/proxy \$SR/proxy" && \
133   echo "cp -r bindist/man \$SR/man" && \
134   echo "cp -r bindist/logs \$SR/logs" && \
135   echo "cp -r bindist/libexec \$SR/libexec" && \
136   echo "cp -r bindist/include \$SR/include" && \
137   echo "cp -r bindist/icons \$SR/icons" && \
138   echo "cp -r bindist/cgi-bin \$SR/cgi-bin" && \
139   echo "cp -r bindist/bin \$SR/bin" && \
140   echo "if [ -d \$SR/conf ]" && \
141   echo "then" && \
142   echo "  echo \"[Preserving existing configuration files.]\"" && \
143   echo "  cp -r bindist/conf/*.default \$SR/conf/" && \
144   echo "else" && \
145   echo "  cp -r bindist/conf \$SR/conf" && \
146   echo "fi" && \
147   echo "if [ -d \$SR/htdocs ]" && \
148   echo "then" && \
149   echo "  echo \"[Preserving existing htdocs directory.]\"" && \
150   echo "else" && \
151   echo "  cp -r bindist/htdocs \$SR/htdocs" && \
152   echo "fi" && \
153   echo "sed -e s%/usr/local/apache%\$SR/% \$SR/conf/httpd.conf.default > \$SR/conf/httpd.conf" && \
154   echo "sed -e s%PIDFILE=%PIDFILE=\$SR/% -e s%HTTPD=%HTTPD=\\\"\$SR/% -e \"s%/httpd$%/httpd -d \$SR\\\"%\" bindist/bin/apachectl > \$SR/bin/apachectl" && \
155   echo " " && \
156   echo "echo \"Ready.\"" && \
157   echo "echo \" +--------------------------------------------------------+\"" && \
158   echo "echo \" | You now have successfully installed the Apache $VER   |\"" && \
159   echo "echo \" | HTTP server. To verify that Apache actually works      |\"" && \
160   echo "echo \" | correctly you now should first check the (initially    |\"" && \
161   echo "echo \" | created or preserved) configuration files              |\"" && \
162   echo "echo \" |                                                        |\"" && \
163   echo "echo \" |   \$SR/conf/httpd.conf\"" && \
164   echo "echo \" |                                                        |\"" && \
165   echo "echo \" | and then you should be able to immediately fire up     |\"" && \
166   echo "echo \" | Apache the first time by running:                      |\"" && \
167   echo "echo \" |                                                        |\"" && \
168   echo "echo \" |   \$SR/bin/apachectl start \"" &&\
169   echo "echo \" |                                                        |\"" && \
170   echo "echo \" | Thanks for using Apache.       The Apache Group        |\"" && \
171   echo "echo \" |                                http://www.apache.org/  |\"" && \
172   echo "echo \" +--------------------------------------------------------+\"" && \
173   echo "echo \" \"" \
174 ) > install-bindist.sh
175 chmod 755 install-bindist.sh
176
177 sed -e "s%\"/htdocs%\"/usr/local/apache/htdocs%" \
178     -e "s%\"/icons%\"/usr/local/apache/icons%" \
179     -e "s%\"/cgi-bin%\"/usr/local/apache/cgi-bin%" \
180     -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
181     -e "s%#ServerName.*%#ServerName localhost%" \
182     -e "s%Port 8080%Port 80%" \
183     bindist/conf/httpd.conf.default > bindist/conf/httpd.conf
184 cp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
185
186 echo "Creating distribution archive and readme file..."
187  
188 if [ ".`grep -i error build.log > /dev/null`" != . ]
189 then
190   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
191   exit 1;
192 else
193   if [ "$GTAR" != "" ]
194   then
195     $GTAR -zcf ../apache-$VER-$OS.tar.gz -C .. --owner=root --group=root apache-$VER
196   else
197     if [ "$TAR" != "" ]
198     then
199       $TAR -cf ../apache-$VER-$OS.tar -C .. apache-$VER
200       if [ "$GZIP" != "" ]
201       then
202         $GZIP ../apache-$VER-$OS.tar
203       fi
204     else
205       echo "ERROR: Could not find a 'tar' program!"
206       echo "       Please execute the following commands manually:"
207       echo "         tar -cf ../apache-$VER-$OS.tar ."
208       echo "         gzip ../apache-$VER-$OS.tar"
209     fi
210   fi
211
212   if [ -f ../apache-$VER-$OS.tar.gz ] && [ -f ../apache-$VER-$OS.README ]
213   then
214     echo "Ready."
215     echo "You can find the binary archive (apache-$VER-$OS.tar.gz)"
216     echo "and the readme file (apache-$VER-$OS.README) in the"
217     echo "parent directory."
218     exit 0;
219   else
220     exit 1;
221   fi
222 fi