binbuild.sh revision df202f09032c0717cd4279320c24115084bbefeb
888d5172c9670a1a6278556625f1f6199ec53a2dfielding#!/bin/sh
888d5172c9670a1a6278556625f1f6199ec53a2dfielding#
888d5172c9670a1a6278556625f1f6199ec53a2dfielding# binbuild.sh - Builds an Apache binary distribution.
888d5172c9670a1a6278556625f1f6199ec53a2dfielding# Initially written by Lars Eilebrecht <lars@apache.org>.
888d5172c9670a1a6278556625f1f6199ec53a2dfielding#
888d5172c9670a1a6278556625f1f6199ec53a2dfielding# This script falls under the Apache License.
888d5172c9670a1a6278556625f1f6199ec53a2dfielding# See http://www.apache.org/docs/LICENSE
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
8e157dab9212d6770973543a56bf644387e5a178jimAPDIR=`pwd`
8e157dab9212d6770973543a56bf644387e5a178jimAPDIR=`basename $APDIR`
8e157dab9212d6770973543a56bf644387e5a178jimVER=`echo $APDIR |sed s/apache-//`
8e157dab9212d6770973543a56bf644387e5a178jimOS=`src/helpers/GuessOS`
8e157dab9212d6770973543a56bf644387e5a178jimUSER="`src/helpers/buildinfo.sh -n %u@%h%d`"
8e157dab9212d6770973543a56bf644387e5a178jimTAR="`src/helpers/PrintPath tar`"
8e157dab9212d6770973543a56bf644387e5a178jimGTAR="`src/helpers/PrintPath gtar`"
8e157dab9212d6770973543a56bf644387e5a178jimGZIP="`src/helpers/PrintPath gzip`"
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingCONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingif [ ! -f ./ABOUT_APACHE ]
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingthen
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "ERROR: The current directory contains no valid Apache distribution."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Please change the directory to the top level directory of a freshly"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "unpacked Apache 1.3 source distribution and re-execute the script"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "'./src/helpers/bindbuild.sh'."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding exit 1;
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingfi
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingif [ -d ./CVS ]
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingthen
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "ERROR: The current directory is a CVS checkout of Apache."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Only a standard Apache 1.3 source distribution should be used to"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "create a binary distribution."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding exit 1;
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingfi
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingecho "Building Apache $VER binary distribution..."
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingecho "Platform is \"$OS\"..."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfielding( echo "Build log for Apache binary distribution" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding ./configure $CONFIGPARAM && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding make clean && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding rm -rf bindist install-bindist.sh *.bindist
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding make && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding make install-quiet root="bindist/" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding make clean && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "[EOF]" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding) > build.log 2>&1
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingif [ ! -f ./bindist/bin/httpd ]
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingthen
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "ERROR: Failed to build Apache. See \"build.log\" for details."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding exit 1;
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingfi
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingecho "Binary images successfully created..."
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingecho "Creating supplementary files..."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfielding( echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Apache $VER binary distribution" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "================================" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "This binary distribution is usable on a \"$OS\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "system and was built by \"$USER\"." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "The distribution contains all standard Apache modules as shared" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "objects. This allows you to enable or disable particular modules" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "with the LoadModule/AddModule directives in the configuration file" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "without the need to re-compile Apache." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "See \"INSTALL.bindist\" on how to install the distribution." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "NOTE: Please do not send support-related mails to the address mentioned" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " above or to any member of the Apache Group! Support questions" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " should be directed to the \"comp.infosystems.www.servers.unix\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " (as appropriate for the platform you use), where some of the" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " Apache team lurk, in the company of many other Apache gurus" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " who should be able to help." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " If you think you found a bug in Apache or have a suggestion please" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " visit the bug report page at http://www.apache.org/bug_report.html" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding ./bindist/bin/httpd -V && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "----------------------------------------------------------------------" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding) > README.bindist
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingcp README.bindist ../apache-$VER-$OS.README
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfielding( echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Apache $VER binary installation" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "================================" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "To install this binary distribution you have to execute the installation" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "The script takes the ServerRoot directory into which you want to install" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Apache as an option. If you ommit the option the default path" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "\"/usr/local/apache\" is used." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Make sure you have write permissions in the target directory, e.g. switch" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "to user \"root\" before you execute the script." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "See \"README.bindist\" for further details about this distribution." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Please note that this distribution includes the complete Apache source code." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "installation on your system." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "See \"INSTALL\" for details on how to accomplish this." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding) > INSTALL.bindist
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfielding( echo "#!/bin/sh" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "#" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "# Usage: install-bindist.sh [ServerRoot]" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "# This script installs the Apache binary distribution and" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "# was automatically created by binbuild.sh." && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "if [ .\$1 = . ]" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "then" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " SR=/usr/local/apache" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "else" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " SR=\$1" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "fi" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \"Installing binary distribution for platform $OS\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \"into directory \$SR ...\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "./src/helpers/mkdir.sh \$SR" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/proxy \$SR/proxy" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/man \$SR/man" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/logs \$SR/logs" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/libexec \$SR/libexec" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/include \$SR/include" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/icons \$SR/icons" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/cgi-bin \$SR/cgi-bin" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "cp -r bindist/bin \$SR/bin" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "if [ -d \$SR/conf ]" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "then" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " echo \"[Preserving existing configuration files.]\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " cp -r bindist/conf/*.default \$SR/conf/" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "else" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " cp -r bindist/conf \$SR/conf" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "fi" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "if [ -d \$SR/htdocs ]" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "then" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " echo \"[Preserving existing htdocs directory.]\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "else" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " cp -r bindist/htdocs \$SR/htdocs" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "fi" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "sed -e s%/usr/local/apache%\$SR/% \$SR/conf/httpd.conf.default > \$SR/conf/httpd.conf" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "sed -e s%PIDFILE=%PIDFILE=\$SR/% -e s%HTTPD=%HTTPD=\\\"\$SR/% -e \"s%/httpd$%/httpd -d \$SR\\\"%\" bindist/bin/apachectl > \$SR/bin/apachectl" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " " && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \"Ready.\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" +--------------------------------------------------------+\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | You now have successfully installed the Apache $VER |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | HTTP server. To verify that Apache actually works |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | correctly you now should first check the (initially |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | created or preserved) configuration files |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | \$SR/conf/httpd.conf\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | and then you should be able to immediately fire up |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | Apache the first time by running: |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | \$SR/bin/apachectl start \"" &&\
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | Thanks for using Apache. The Apache Group |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" | http://www.apache.org/ |\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" +--------------------------------------------------------+\"" && \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "echo \" \"" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding) > install-bindist.sh
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingchmod 755 install-bindist.sh
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingsed -e "s%\"/htdocs%\"/usr/local/apache/htdocs%" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding -e "s%\"/icons%\"/usr/local/apache/icons%" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding -e "s%\"/cgi-bin%\"/usr/local/apache/cgi-bin%" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding -e "s%#ServerName.*%#ServerName localhost%" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding -e "s%Port 8080%Port 80%" \
888d5172c9670a1a6278556625f1f6199ec53a2dfielding bindist/conf/httpd.conf.default > bindist/conf/httpd.conf
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingcp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingecho "Creating distribution archive and readme file..."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingif [ ".`grep -i error build.log > /dev/null`" != . ]
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingthen
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "ERROR: Failed to build Apache. See \"build.log\" for details."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding exit 1;
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingelse
df202f09032c0717cd4279320c24115084bbefebjim if [ "x$GTAR" != "x" ]
888d5172c9670a1a6278556625f1f6199ec53a2dfielding then
888d5172c9670a1a6278556625f1f6199ec53a2dfielding $GTAR -zcf ../apache-$VER-$OS.tar.gz -C .. --owner=root --group=root apache-$VER
888d5172c9670a1a6278556625f1f6199ec53a2dfielding else
df202f09032c0717cd4279320c24115084bbefebjim if [ "x$TAR" != "x" ]
888d5172c9670a1a6278556625f1f6199ec53a2dfielding then
888d5172c9670a1a6278556625f1f6199ec53a2dfielding $TAR -cf ../apache-$VER-$OS.tar -C .. apache-$VER
df202f09032c0717cd4279320c24115084bbefebjim if [ "x$GZIP" != "x" ]
888d5172c9670a1a6278556625f1f6199ec53a2dfielding then
888d5172c9670a1a6278556625f1f6199ec53a2dfielding $GZIP ../apache-$VER-$OS.tar
888d5172c9670a1a6278556625f1f6199ec53a2dfielding fi
888d5172c9670a1a6278556625f1f6199ec53a2dfielding else
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "ERROR: Could not find a 'tar' program!"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " Please execute the following commands manually:"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " tar -cf ../apache-$VER-$OS.tar ."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo " gzip ../apache-$VER-$OS.tar"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding fi
888d5172c9670a1a6278556625f1f6199ec53a2dfielding fi
888d5172c9670a1a6278556625f1f6199ec53a2dfielding
888d5172c9670a1a6278556625f1f6199ec53a2dfielding if [ -f ../apache-$VER-$OS.tar.gz ] && [ -f ../apache-$VER-$OS.README ]
888d5172c9670a1a6278556625f1f6199ec53a2dfielding then
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "Ready."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "You can find the binary archive (apache-$VER-$OS.tar.gz)"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "and the readme file (apache-$VER-$OS.README) in the"
888d5172c9670a1a6278556625f1f6199ec53a2dfielding echo "parent directory."
888d5172c9670a1a6278556625f1f6199ec53a2dfielding exit 0;
888d5172c9670a1a6278556625f1f6199ec53a2dfielding else
888d5172c9670a1a6278556625f1f6199ec53a2dfielding exit 1;
888d5172c9670a1a6278556625f1f6199ec53a2dfielding fi
888d5172c9670a1a6278556625f1f6199ec53a2dfieldingfi