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