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

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

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED=`ls -1 $PACKAGES/packages/|grep $PACKAGE-|cut -d "-" -f 1,2`
$WGET -q ftp://ftp.isc.org/isc/bind9/
NEW="$PACKAGE-`grep $PACKAGE index.html|grep "/9."|grep -v rc|grep -v beta|cut -d / -f 6|tail -1`"
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL ftp://ftp.isc.org/isc/bind9/`echo $SRC|cut -d - -f 2`/$SRC.tar.gz
}

build() {
# Creating new
tar zxvf $DOWNL/$SRC.tar.gz
cd $SRC
zcat $CWD/patches/bind.var.run.named.diff.gz | patch -p1 --verbose --backup --suffix=.orig
./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --with-libtool \
    --enable-shared \
    --disable-threads \
    --with-openssl=/usr \
    --enable-ipv6 \
    $TARGET || exit
make || exit
make install DESTDIR=$PKG || exit
chmod 755 $PKG/usr/lib/*
mkdir -p $PKG/etc/rc.d
cp $CWD/rc.named $PKG/etc/rc.d/
if [ -r /etc/rc.d/rc.named ];then
mv $PKG/etc/rc.d/rc.named $PKG/etc/rc.d/rc.named.new
fi
    postbuild
}

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

