usr/src/cmd/apache2/install-apache2-64
author Jon Tibble <meths@btinternet.com>
Mon, 04 May 2015 14:04:39 +0100
branchoi_151a
changeset 254 9c2a4ac793f0
parent 234 698b51923b4d
permissions -rw-r--r--
Bash patch catchup including shellshock

#!/usr/bin/ksh93

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)install-apache2-64	1.8	09/10/26 SMI"
#

set -o errexit

. ${SRC}/tools/install.subr
. ${SRC}/cmd/apr/apr-1.3/apr.build.env
. ${SRC}/cmd/apr-util/apr-util-1.3/apr-util.build.env
. ${SRC}/cmd/apache2/apache.build.env

# functions - search for "START HERE" to find start of control flow

ins_file() {
    iprog=$1
    idir=$2
    imode=$3
    _install N ${iprog} ${idir}/${iprog} ${imode}
}

ins_file_modified() {
    iprog=$1
    idir=$2
    idestfile=$3
    imode=$4
    _install N ${iprog} ${idir}/${idestfile} ${imode}
}

disable_suexec() {
    cd ${BINDIR}
    if [ -f "./suexec" ]; then
        mv suexec suexec.disabled
    fi
}

fix_config_files() {
    cd ${TOP}/Solaris
    ins_file modules-64.load ${CONFDIR}/conf.d 644

    cd ${CONFDIR}

    # Strip the 64-bit LoadModule directives from httpd.conf and put them in a
    # separate file
    grep "^LoadModule " ${TOP}/Solaris/64/httpd.conf >> conf.d/modules-64.load
    sed -f ${TOP}/Solaris/64/loadmodules.sed conf.d/modules-64.load > conf.d/modules-64.load.new
    sed -e "s;/${MACH64}/;/64/;g" conf.d/modules-64.load.new > conf.d/modules-64.load
    rm -f conf.d/modules-64.load.new

    set +e
    cd ${BINDIR}
    # Add logic to source the user-customizable envvars file
    ENVVAR_INCLUDE=`grep "/envvars" envvars`
    if [ "x${ENVVAR_INCLUDE}" = "x" ]; then
        sed -f ${TOP}/Solaris/envvars.sed envvars > envvars.1
        mv envvars.1 envvars
    fi
    set -e
}

install_real_bins() {
    cd ${TOP}/${APACHE_WORKER_DIR64}/.libs
    ins_file_modified httpd ${BINDIR} httpd.worker 555

    cd ${TOP}/${APACHE_PREFORK_DIR64}/.libs
    ins_file httpd ${BINDIR} 555

    cd ${TOP}/${APACHE_PREFORK_DIR64}/support/.libs
    for i in \
        ab \
        checkgid \
        htcacheclean \
        htdbm \
        htdigest \
        htpasswd \
        httxt2dbm \
        logresolve \
        rotatelogs
    do
        ins_file ${i} ${BINDIR} 555
    done
}

install_smf_hooks() {
    cd ${TOP}/Solaris/64
    ins_file http-apache22 ${ROOT}/lib/svc/method 555
}

install_auth_gss() {
    cd ${MOD_AUTH_GSS_DIR}
    ins_file mod_auth_gss.so ${LIBEXECDIR} 555
}

post_process() {
    cd ${BINDIR}
    for i in \
        ab \
        checkgid \
        htcacheclean \
        htdbm \
        htdigest \
        htpasswd \
        httpd \
        httpd.worker \
        httxt2dbm \
        logresolve \
        rotatelogs \
        suexec.disabled
    do
        chmod u+w ${i}
        ${SRC}/tools/post_process ${i}
        chmod u-w ${i}
    done

    cd ${LIBEXECDIR}
    for i in *.so
    do
        chmod u+w ${i}
        ${SRC}/tools/post_process_so ${i}
        chmod u-w ${i}
    done
}

# apache2 stores all kinds of info about the build environment
# in $ROOT/usr/apache2/build.  We need to massage this so it
# is all relative to an installed machine, rather than a build
# proto area.
fix_build_config() {
    cd ${BUILDDIR}
    ${GPATCH} ${GPATCH_FLAGS} < ${TOP}/patches/64/rules.mk.patch.install
    ${GPATCH} ${GPATCH_FLAGS} < ${TOP}/patches/64/special.mk.patch.install
}

# create soft links to the binaries in ${BINDIR} from /usr/bin
# e.g.,  /usr/bin/amd64/ab --> /usr/apache2/2.2/bin/amd64/ab
#        /usr/bin/sparcv9/ab --> /usr/apache2/2.2/bin/sparcv9/ab
# Also, create symlink "64" to $ISA directory
# e.g., /usr/apache2/2.2/bin/64 -> amd64
create_sym_links() {
    cd ${BINDIR}
    for i in \
            ab \
            apxs \
            dbmmanage \
            htcacheclean \
            htdbm \
            htdigest \
            htpasswd \
            httxt2dbm \
            logresolve \
            rotatelogs
    do
        _install L ../../${APACHE_DIR_PREFIX}/bin/${MACH64}/${i} ${ROOT}/usr/bin/${MACH64}/${i}
    done

    for i in ${PREFIX} ${VARDIR}; do
        cd ${i}
        for j in `ls -p`; do
            if test -d "${j}/${MACH64}"; then
                _install L ${MACH64} ${j}/64
            fi
        done
    done
}

# replace build environment specific paths 
replace_build_path() {
    cd ${BUILDDIR}
    for i in `ls -Lp | grep -v '/$'`; do
        sed -e "s;${ROOT};;g" \
            -e "s;-M ${MAPFILE_NOEXSTK} ;;g" \
            -e "s;${SPRO_VROOT}/bin/;;g" \
            -e "s;${APR_SRC_DIR64};${APR_USR_PREFIX};g" \
            -e "s;${APR_UTIL_SRC_DIR64};${APR_UTIL_USR_PREFIX};g" \
            -e "s;${APACHE_SRC_PREFORK_DIR64};${APACHE_USR_PREFIX};g" \
            -e "s;${APACHE_SRC_WORKER_DIR64};${APACHE_USR_PREFIX};g" < ${i} > ${i}.tmp
        cp -f ${i}.tmp ${i}
        rm -f ${i}.tmp
    done
}

# remove the bundled but disabled (by default) modules from modules-64.load
remove_disabled_modules() {
    cd ${TOP}/Solaris
    sed -e 's/#.*//' -e '/^$/ d' ./disabled-module.list > ./tmp-disabled.list
    for i in `cat ./tmp-disabled.list`; do
        sed -e '/LoadModule.*'${i}'.so/ d' ${CONFDIR}/conf.d/modules-64.load > ${CONFDIR}/conf.d/tmp-64.load
        mv ${CONFDIR}/conf.d/tmp-64.load ${CONFDIR}/conf.d/modules-64.load
    done
    rm -f ./tmp-disabled.list
}

# START HERE - actual script processing starts here

# Even though this is called "install-apache", it doesn't really
# install the whole thing.  Much of apache itself is installed by
# make install - we need to fix permissions.  What we install here
# are modules that apache won't install as part of its normal build.
# Each install task is a function, so it's relatively easy to add new
# stuff.

TOP=`pwd`

PREFIX=${ROOT}${APACHE_USR_PREFIX}
CONFDIR=${ROOT}${APACHE_ETC_PREFIX}
VARDIR=${ROOT}${APACHE_VAR_PREFIX}

BINDIR=${PREFIX}/bin/${MACH64}
BUILDDIR=${PREFIX}/build/${MACH64}
LIBDIR=${PREFIX}/lib/${MACH64}
LIBEXECDIR=${PREFIX}/libexec/${MACH64}
MOD_AUTH_GSS_DIR=${TOP}/mod_auth_gss-64/.libs
APACHE_SRC_PREFORK_DIR64=${TOP}/${APACHE_PREFORK_DIR64}
APACHE_SRC_WORKER_DIR64=${TOP}/${APACHE_WORKER_DIR64}
APR_SRC_DIR64=${SRC}/cmd/apr/apr-${APR_VERSION_DIR}/${APR_DIR64}
APR_UTIL_SRC_DIR64=${SRC}/cmd/apr-util/apr-util-${APR_UTIL_VERSION_DIR}/${APR_UTIL_DIR64}

disable_suexec
install_real_bins
fix_config_files
install_smf_hooks
install_auth_gss
post_process
fix_build_config
remove_disabled_modules
replace_build_path
create_sym_links
# the 32-bit installl runs after this, so don't fix file permissions here

exit 0