#!/bin/sh
#
# kTm port by Juzer
#
#       regards to hns & psych
#

# local config:
BUILD="1"
PACKAGE="php"

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2`"
$WGET -q http://downloads.php.net/ilia/
NEW=`grep $PACKAGE index.html|grep .tar.bz2|cut -d "'" -f 2|grep -v RC|sed -e s/.tar.*//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL http://downloads.php.net/ilia/$SRC.tar.bz2
}

build() {
# Creating new
tar xjvf $DOWNL/$SRC.tar.bz2
cd $SRC
./configure \
    --prefix=/usr \
    --with-apxs2=/usr/sbin/apxs \
    --with-config-file-path=/etc/httpd \
    --sysconfdir=/etc \
    --with-mysql=/usr \
    --with-layout=RedHat \
    $TARGET || exit
make || exit
mkdir -p $PKG/etc/httpd
cp /etc/httpd/httpd.conf $PKG/etc/httpd
cp php.ini-dist $PKG/etc/httpd
make install INSTALL_ROOT=$PKG || exit
mv -f $PKG/etc/httpd $PKG/etc/httpd.new
cd $PKG
    postbuild
}

source "${DATA:-/usr/lib/ktm}/ktm.ports.sh"
