]> granicus.if.org Git - apache/blob - build/binbuild.sh
Fix some changed assumptions in config file format.
[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 CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max"
11 APDIR=`pwd`
12 APDIR=`basename $APDIR`
13 VER=`echo $APDIR |sed s/apache_//`
14 OS=`src/helpers/GuessOS`
15 TAR="`src/helpers/PrintPath tar`"
16 GTAR="`src/helpers/PrintPath gtar`"
17 GZIP="`src/helpers/PrintPath gzip`"
18
19 if [ x$1 != x ]
20 then
21   USER=$1
22 else
23   USER="`src/helpers/buildinfo.sh -n %u@%h%d`"
24 fi
25
26 if [ ! -f ./ABOUT_APACHE ]
27 then
28   echo "ERROR: The current directory contains no valid Apache distribution."
29   echo "Please change the directory to the top level directory of a freshly"
30   echo "unpacked Apache 1.3 source distribution and re-execute the script"
31   echo "'./src/helpers/bindbuild.sh'." 
32   exit 1;
33 fi
34
35 if [ -d ./CVS ]
36 then
37   echo "ERROR: The current directory is a CVS checkout of Apache."
38   echo "Only a standard Apache 1.3 source distribution should be used to"
39   echo "create a binary distribution."
40   exit 1;
41 fi
42
43 echo "Building Apache $VER binary distribution..."
44 echo "Platform is \"$OS\"..."
45
46 ( echo "Build log for Apache binary distribution" && \
47   echo "----------------------------------------------------------------------" && \
48   ./configure $CONFIGPARAM && \
49   echo "----------------------------------------------------------------------" && \
50   make clean && \
51   rm -rf bindist install-bindist.sh *.bindist
52   echo "----------------------------------------------------------------------" && \
53   make && \
54   echo "----------------------------------------------------------------------" && \
55   make install-quiet root="bindist/" && \
56   echo "----------------------------------------------------------------------" && \
57   make clean && \
58   echo "----------------------------------------------------------------------" && \
59   echo "[EOF]" \
60 ) > build.log 2>&1
61
62 if [ ! -f ./bindist/bin/httpd ]
63 then
64   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
65   exit 1;
66 fi
67
68 echo "Binary image successfully created..."
69
70 ./bindist/bin/httpd -v
71
72 echo "Creating supplementary files..."
73
74 ( echo " " && \
75   echo "Apache $VER binary distribution" && \
76   echo "================================" && \
77   echo " " && \
78   echo "This binary distribution is usable on a \"$OS\"" && \
79   echo "system and was built by \"$USER\"." && \
80   echo "" && \
81   echo "The distribution contains all standard Apache modules as shared" && \
82   echo "objects. This allows you to enable or disable particular modules" && \
83   echo "with the LoadModule/AddModule directives in the configuration file" && \
84   echo "without the need to re-compile Apache." && \
85   echo "" && \
86   echo "See \"INSTALL.bindist\" on how to install the distribution." && \
87   echo " " && \
88   echo "NOTE: Please do not send support-related mails to the address mentioned" && \
89   echo "      above or to any member of the Apache Group! Support questions" && \
90   echo "      should be directed to the \"comp.infosystems.www.servers.unix\"" && \
91   echo "      or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
92   echo "      (as appropriate for the platform you use), where some of the" && \
93   echo "      Apache team lurk, in the company of many other Apache gurus" && \
94   echo "      who should be able to help." && \
95   echo "      If you think you found a bug in Apache or have a suggestion please" && \
96   echo "      visit the bug report page at http://www.apache.org/bug_report.html" && \
97   echo " " && \
98   echo "----------------------------------------------------------------------" && \
99   ./bindist/bin/httpd -V && \
100   echo "----------------------------------------------------------------------" \
101 ) > README.bindist
102 cp README.bindist ../apache_$VER-$OS.README
103
104 ( echo " " && \
105   echo "Apache $VER binary installation" && \
106   echo "================================" && \
107   echo " " && \
108   echo "To install this binary distribution you have to execute the installation" && \
109   echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
110   echo " " && \
111   echo "The script takes the ServerRoot directory into which you want to install" && \
112   echo "Apache as an option. If you ommit the option the default path" && \
113   echo "\"/usr/local/apache\" is used." && \
114   echo "Make sure you have write permissions in the target directory, e.g. switch" && \
115   echo "to user \"root\" before you execute the script." && \
116   echo " " && \
117   echo "See \"README.bindist\" for further details about this distribution." && \
118   echo " " && \
119   echo "Please note that this distribution includes the complete Apache source code." && \
120   echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
121   echo "installation on your system." && \
122   echo "See \"INSTALL\" for details on how to accomplish this." && \
123   echo " " \
124 ) > INSTALL.bindist
125
126 ( echo "#!/bin/sh" && \
127   echo "#" && \
128   echo "# Usage: install-bindist.sh [ServerRoot]" && \
129   echo "# This script installs the Apache binary distribution and" && \
130   echo "# was automatically created by binbuild.sh." && \
131   echo " " && \
132   echo "lmkdir()" && \
133   echo "{" && \
134   echo "  path=\"\"" && \
135   echo "  dirs=\`echo \$1 | sed -e 's%/% %g'\`" && \
136   echo "  mode=\$2" && \
137   echo " " && \
138   echo "  set -- \${dirs}" && \
139   echo " " && \
140   echo "  for d in \${dirs}" && \
141   echo "  do" && \
142   echo "    path=\"\${path}/\$d\"" && \
143   echo "    if test ! -d \"\${path}\" ; then" && \
144   echo "      mkdir \${path}" && \
145   echo "      if test \$? -ne 0 ; then" && \
146   echo "        echo \"Failed to create directory: \${path}\"" && \
147   echo "        exit 1" && \
148   echo "      fi" && \
149   echo "      chmod \${mode} \${path}" && \
150   echo "    fi" && \
151   echo "  done" && \
152   echo "}" && \
153   echo " " && \
154   echo "lcopy()" && \
155   echo "{" && \
156   echo "  from=\$1" && \
157   echo "  to=\$2" && \
158   echo "  dmode=\$3" && \
159   echo "  fmode=\$4" && \
160   echo " " && \
161   echo "  test -d \${to} || lmkdir \${to} \${dmode}" && \
162   echo "  (cd \${from} && tar -cf - *) | (cd \${to} && tar -xf -)" && \
163   echo " " && \
164   echo "  if test \"X\${fmode}\" != X ; then" && \
165   echo "    find \${to} -type f -print | xargs chmod \${fmode}" && \
166   echo "  fi" && \
167   echo "  if test \"X\${dmode}\" != X ; then" && \
168   echo "    find \${to} -type d -print | xargs chmod \${dmode}" && \
169   echo "  fi" && \
170   echo "}" && \
171   echo " " && \
172   echo "##" && \
173   echo "##  determine path to (optional) Perl interpreter" && \
174   echo "##" && \
175   echo "PERL=no-perl5-on-this-system" && \
176   echo "perls='perl5 perl'" && \
177   echo "path=\`echo \$PATH | sed -e 's/:/ /g'\`" && \
178   echo " " && \
179   echo "for dir in \${path} ;  do" && \
180   echo "  for pperl in \${perls} ; do" && \
181   echo "    if test -f \"\${dir}/\${pperl}\" ; then" && \
182   echo "      if \`\${dir}/\${pperl} -v | grep 'version 5\.' >/dev/null 2>&1\` ; then" && \
183   echo "        PERL=\"\${dir}/\${pperl}\"" && \
184   echo "        break" && \
185   echo "      fi" && \
186   echo "    fi" && \
187   echo "  done" && \
188   echo "done" && \
189   echo " " && \
190   echo "if [ .\$1 = . ]" && \
191   echo "then" && \
192   echo "  SR=/usr/local/apache" && \
193   echo "else" && \
194   echo "  SR=\$1" && \
195   echo "fi" && \
196   echo "echo \"Installing binary distribution for platform $OS\"" && \
197   echo "echo \"into directory \$SR ...\"" && \
198   echo "lmkdir \$SR 755" && \
199   echo "lmkdir \$SR/proxy 750" && \
200   echo "lmkdir \$SR/logs 750" && \
201   echo "lcopy bindist/man \$SR/man 755 644" && \
202   echo "lcopy bindist/libexec \$SR/libexec 750 644" && \
203   echo "lcopy bindist/include \$SR/include 755 644" && \
204   echo "lcopy bindist/icons \$SR/icons 755 644" && \
205   echo "lcopy bindist/cgi-bin \$SR/cgi-bin 750 750" && \
206   echo "lcopy bindist/bin \$SR/bin 750 750" && \
207   echo "if [ -d \$SR/conf ]" && \
208   echo "then" && \
209   echo "  echo \"[Preserving existing configuration files.]\"" && \
210   echo "  cp bindist/conf/*.default \$SR/conf/" && \
211   echo "else" && \
212   echo "  lcopy bindist/conf \$SR/conf 750 640" && \
213   echo "fi" && \
214   echo "if [ -d \$SR/htdocs ]" && \
215   echo "then" && \
216   echo "  echo \"[Preserving existing htdocs directory.]\"" && \
217   echo "else" && \
218   echo "  lcopy bindist/htdocs \$SR/htdocs 755 644" && \
219   echo "fi" && \
220   echo " " && \
221   echo "sed -e \"s;^#!/.*;#!\$PERL;\" -e \"s;\@prefix\@;\$SR;\" -e \"s;\@sbindir\@;\$SR/bin;\" \\" && \
222   echo "        -e \"s;\@libexecdir\@;\$SR/libexec;\" -e \"s;\@includedir\@;\$SR/include;\" \\" && \
223   echo "        -e \"s;\@sysconfdir\@;\$SR/conf;\" bindist/bin/apxs > \$SR/bin/apxs" && \
224   echo "sed -e \"s;^#!/.*;#!\$PERL;\" bindist/bin/dbmmanage > \$SR/bin/dbmmanage" && \
225   echo "sed -e \"s%/usr/local/apache%\$SR%\" \$SR/conf/httpd.conf.default > \$SR/conf/httpd.conf" && \
226   echo "sed -e \"s%PIDFILE=%PIDFILE=\$SR/%\" -e \"s%HTTPD=%HTTPD=\\\"\$SR/%\" -e \"s%httpd\$%httpd -d \$SR\\\"%\" bindist/bin/apachectl > \$SR/bin/apachectl" && \
227   echo " " && \
228   echo "echo \"Ready.\"" && \
229   echo "echo \" +--------------------------------------------------------+\"" && \
230   echo "echo \" | You now have successfully installed the Apache $VER   |\"" && \
231   echo "echo \" | HTTP server. To verify that Apache actually works      |\"" && \
232   echo "echo \" | correctly you should first check the (initially        |\"" && \
233   echo "echo \" | created or preserved) configuration files:             |\"" && \
234   echo "echo \" |                                                        |\"" && \
235   echo "echo \" |   \$SR/conf/httpd.conf\"" && \
236   echo "echo \" |                                                        |\"" && \
237   echo "echo \" | You should then be able to immediately fire up         |\"" && \
238   echo "echo \" | Apache the first time by running:                      |\"" && \
239   echo "echo \" |                                                        |\"" && \
240   echo "echo \" |   \$SR/bin/apachectl start \"" &&\
241   echo "echo \" |                                                        |\"" && \
242   echo "echo \" | Thanks for using Apache.       The Apache Group        |\"" && \
243   echo "echo \" |                                http://www.apache.org/  |\"" && \
244   echo "echo \" +--------------------------------------------------------+\"" && \
245   echo "echo \" \"" \
246 ) > install-bindist.sh
247 chmod 755 install-bindist.sh
248
249 sed -e "s%\"htdocs%\"/usr/local/apache/htdocs%" \
250     -e "s%\"icons%\"/usr/local/apache/icons%" \
251     -e "s%\"cgi-bin%\"/usr/local/apache/cgi-bin%" \
252     -e "s%\"proxy%\"/usr/local/apache/proxy%" \
253     -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
254     -e "s%#ServerName.*%#ServerName localhost%" \
255     -e "s%Port 8080%Port 80%" \
256     bindist/conf/httpd.conf.default > bindist/conf/httpd.conf
257 cp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
258
259 echo "Creating distribution archive and readme file..."
260  
261 if [ ".`grep -i error build.log > /dev/null`" != . ]
262 then
263   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
264   exit 1;
265 else
266   if [ "x$GTAR" != "x" ]
267   then
268     $GTAR -zcf ../apache_$VER-$OS.tar.gz -C .. apache_$VER
269   else
270     if [ "x$TAR" != "x" ]
271     then
272       $TAR -cf ../apache_$VER-$OS.tar -C .. apache_$VER
273       if [ "x$GZIP" != "x" ]
274       then
275         $GZIP ../apache_$VER-$OS.tar
276       fi
277     else
278       echo "ERROR: Could not find a 'tar' program!"
279       echo "       Please execute the following commands manually:"
280       echo "         tar -cf ../apache_$VER-$OS.tar ."
281       echo "         gzip ../apache_$VER-$OS.tar"
282     fi
283   fi
284
285   if [ -f ../apache_$VER-$OS.tar.gz ] && [ -f ../apache_$VER-$OS.README ]
286   then
287     echo "Ready."
288     echo "You can find the binary archive (apache_$VER-$OS.tar.gz)"
289     echo "and the readme file (apache_$VER-$OS.README) in the"
290     echo "parent directory."
291     exit 0;
292   else
293     exit 1;
294   fi
295 fi