SliTaz Packages

Community Doc Forum Pro Shop Bugs Hg
.

Receipt for package "apache"

# SliTaz package receipt.

PACKAGE="apache"
VERSION="2.4.59"
CATEGORY="network"
TAGS="webserver http server"
SHORT_DESC="Secure, efficient and extensible HTTP server."
MAINTAINER="pascal.bellard@slitaz.org"
LICENSE="Apache"
WEB_SITE="https://www.apache.org/"

SOURCE="httpd"
TARBALL="$SOURCE-$VERSION.tar.bz2"
WGET_URL="https://archive.apache.org/dist/$SOURCE/$TARBALL"

PROVIDE="lighttpd"
DEPENDS="apr apr-util expat openssl pcre util-linux-uuid zlib"
BUILD_DEPENDS="apr-dev apr-util-dev bash expat-dev lua5.1-dev 
    openldap-dev openssl-dev sed util-linux-uuid-dev zlib-dev"

CONFIG_FILES="/etc/apache /var/www /etc/ssl/apache"
TAZPANEL_DAEMON="edit::/etc/apache/httpd.conf|web::$WEB_SITE"

# What is the latest version available today?
current_version()
{
    wget -O - https://downloads.apache.org/httpd/ 2>/dev/null | \
    sed "/$SOURCE-/!d;/tar/!d;s|.*$SOURCE-\\(.*\\).tar.*|\\1|" | sort -Vr | sed q
}

# Rules to configure and make the package.
compile_rules()
{
    grep -q Slitaz config.layout || \
        cat $stuff/slitaz.layout >> config.layout

    ./configure                \
        --mandir=/usr/share/man        \
        --enable-mods-shared=all    \
        --enable-proxy            \
        --enable-ssl            \
        --enable-layout=Slitaz        \
        $CONFIGURE_ARGS &&
    make $MAKEFLAGS &&
    make -j 1 DESTDIR=$DESTDIR install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
    mkdir -p $fs/usr/share/apache
    mkdir -p $fs/etc/init.d
    mkdir -p $fs/etc/apache/conf.d
    mkdir -p $fs/etc/apache/extra
    mkdir -p $fs/etc/ssl/apache

    cp -a $install/usr/share/apache/icons    $fs/usr/share/apache
    cp -a $install/usr/share/apache/error    $fs/usr/share/apache
    cp -a $install/usr/share/apache/modules    $fs/usr/share/apache
    cp -a $install/usr/bin            $fs/usr
    rm -r                    $fs/usr/bin/apxs
    cp -a $install/etc            $fs
    rm -rf                    $fs/etc/apache/original
    cp -a $install/var            $fs
    
    cp -a $stuff/apache            $fs/etc/init.d
    cp -a $stuff/fix-range-CVE-2011-3192.conf $fs/etc/apache/extra

    sed -i  -e 's|User daemon|User www|' \
        -e 's|Group daemon|Group www|' \
        -e 's|ServerAdmin you@example.com|ServerAdmin root@localhost|' \
        -e 's|#Include /etc/apache/extra/httpd-ssl.conf|Include /etc/apache/extra/httpd-ssl.conf|' \
        -e 's|/etc/apache/server.crt|/etc/ssl/apache/apache.pem|' \
        -e 's|/etc/apache/server.key|/etc/ssl/apache/apache.pem|' \
        -e 's|#LoadModule ssl_module|LoadModule ssl_module|' \
        $fs/etc/apache/httpd.conf \
        $fs/etc/apache/extra/httpd-ssl.conf

    echo "Include /etc/apache/conf.d" >> $fs/etc/apache/httpd.conf
    sed -i 's/^SSLSessionCache /#&/' $fs/etc/apache/extra/httpd-ssl.conf

    cat >> $fs/etc/apache/extra/httpd-ssl.conf <<EOT

# Unsafe, see CVE-2014-3566 POODLE
SSLProtocol All -SSLv2 -SSLv3
EOT
}

# Pre and post install commands for Tazpkg.
# We stop the server by default in case of upgrade.
pre_install()
{
    [ -z "$1" ] &&
    for i in httpd lighttpd ngnix cherokee $PACKAGE
      do
        [ -f /etc/init.d/$i ] && /etc/init.d/$i stop
      done
}

post_install()
{
    local lang=$(. $1/etc/locale.conf 2>/dev/null; echo ${LANG#*_} | sed 's/.UTF-8//')
    local tz=$(cat $1/etc/TZ 2>/dev/null)
    local hostname=$(cat $1/etc/hostname 2>/dev/null)

    # Just in case.
    chown www.www "$1/var/log/$PACKAGE"
    ping -c 2 $(hostname) > /dev/null 2>&1 || 
        sed -i "s/localhost/$(hostname) localhost/" "$1/etc/hosts"
    sed -i -e "s/^#\(LoadModule.*slotmem_shm.*\)$/\1/" \
        -e "s/.*ServerName www.example.*/ServerName ${hostname:-slitaz}/" \
        $1/etc/apache/httpd.conf $1/etc/apache/extra/httpd-ssl.conf
    grep -qs Apache $1/var/www/index.html &&
    sed -i 's|^LighTTPD.*|&\nApache configs      : /etc/apache|' \
        $1/var/www/index.html
    [ -s "$1/etc/ssl/apache/apache.pem" ] ||
    openssl req -new -x509 -keyout "$1/etc/ssl/apache/apache.pem" \
        -out "$1/etc/ssl/apache/apache.pem" -days 3650 -nodes <<EOT
${lang:-US}
${tz:-Somewhere}



${hostname:-slitaz}

EOT
    [ -z "$quiet" ] && echo # Start new line
    ( cd "$1/$INSTALLED/" ; grep -l /etc/apache/conf.d/ */receipt ) | \
    while read file
      do
        pkg=$(dirname $file)
        [ "$pkg" = "$PACKAGE" ] && continue
        [ -z "$quiet" ] && echo "Reconfiguring $pkg for $PACKAGE..."
        tazpkg reconfigure $pkg
      done
    [ -f "$1/etc/php.ini" ] && tazpkg get-install php-apache --root="$1"
    [ "$1" ] || netstat -ltn 2> /dev/null | grep -q :80 ||
    /etc/init.d/$PACKAGE start
}

# Rules to clean extras dirs or files
clean_wok()
{
    rm -rf $WOK/$PACKAGE/${PACKAGE}.${VERSION}
}
6025 packages and 203154 files in current database (Thu Apr 25 06:17:47 2024)