#!/bin/bash # # ELS script to build php-5.3.3. # # PHP is a popular server-side scripting language. # # Note: You must install Apache httpd first for PHP to build. # # Source is available from http://www.php.net/download # # # This script is public domain software and may be freely copied. # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # # Define the package name, source directory, build directory and # staging directory paths. Prefixes to directories may be overridden # by setting shell variables SRC, BUILD and STAGING. For example, # doing "export SRC=/root/foo" before calling this script will override # the default /usr/src and set SRC_DIR to /root/foo/$PKG_NAME instead. # PKG_NAME=$(basename $0) SRC_DIR=${SRC:-/usr/src}/$PKG_NAME BUILD_DIR=${BUILD:-/var/tmp/build}/$PKG_NAME STAGING_DIR=${STAGING:-/var/tmp/staging}/$PKG_NAME # Check that the source directory really exits and bail out if not. if ! [ -d $SRC_DIR ]; then echo "$PKG_NAME: Cannot find source code directory $SRC_DIR." exit 1 fi # Do not overwrite existing build directory. if [ -d $BUILD_DIR ]; then echo "$PKG_NAME: Build directory $BUILD_DIR already exists." exit 2 else mkdir -p $BUILD_DIR fi # Do not overwrite existing staging directory. if [ -d $STAGING_DIR ]; then echo "$PKG_NAME: Staging directory $STAGING_DIR already exists." exit 4 else mkdir -p $STAGING_DIR fi # Copy the Apache config file to the staging directory since PHP # will try to modify it and installation will fail if httpd.conf is # not there. APACHE_DIR=/opt/httpd-2.2.* if ! [ -d $APACHE_DIR ]; then echo "$PKG_NAME: Can't find Apache directory." exit 8 else cp --parents $APACHE_DIR/conf/httpd.conf $STAGING_DIR fi # Configure the package for FHS compliance and i586 processor. The # configuration relies on the included SQLite database rather than # requiring an external database like MySQL or PostgreSQL. export CC="gcc -march=i586" cd $BUILD_DIR $SRC_DIR/configure \ --build=i586-pc-linux-gnu \ --prefix=/opt/$PKG_NAME \ --with-apxs2=/opt/bin/apxs \ --with-config-file-path=/etc/opt/php \ --with-zlib # Check return status and bail out if it's non-zero. if [ $? -gt 0 ]; then echo "$PKG_NAME: Configuration failed!" exit 8 fi # Build the package. make # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Build failed!" exit 16 fi # Install. make INSTALL_ROOT=$STAGING_DIR install # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Installation failed!" exit 32 fi # Move the php module from the Apache directory to the PHP directory # and then remove the Apache stuff from the staging directory. mv $STAGING_DIR/$APACHE_DIR/modules $STAGING_DIR/opt/$PKG_NAME rm -R $STAGING_DIR/$APACHE_DIR # Keep a copy of the license document. install -D -o root -g root -m 644 $SRC_DIR/LICENSE \ $STAGING_DIR/opt/$PKG_NAME/doc/LICENSE # Strip binaries and compress documentation to save space. strip $STAGING_DIR/opt/$PKG_NAME/bin/* gzip -r $STAGING_DIR/opt/$PKG_NAME/man gzip -r $STAGING_DIR/opt/$PKG_NAME/doc # Create the package cd $STAGING_DIR tar -zcf ../$PKG_NAME.i586.tar.gz * # end of blueprint