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

# local config:
BUILD="1"
PACKAGE="cyrus-sasl"

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED=`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2,3`
$WGET -q ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
NEW=`grep $PACKAGE index.html|grep .tar|cut -d / -f 6|cut -d '"' -f 1|sed -e s/.tar.*//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/$SRC.tar.gz
}

build() {
# Creating new
tar zxvf $DOWNL/$SRC.tar.gz
cd $SRC
./configure \
    --prefix=/usr \
    --enable-login \
    --enable-plain \
    --with-gnu-ld \
    --with-saslauthd \
    $TARGET || exit
make || exit
make install DESTDIR=$PKG || exit
mkdir $PKG/var/state/saslauthd
chown root.root $PKG/var/state/saslauthd
chmod 755 $PKG/var/state/saslauthd
echo "pwcheck_method: saslauthd" > $PKG/usr/lib/sasl2/smtpd.conf
strip --strip-unneeded $PKG/usr/lib/sasl2/*
mkdir -p $PKG/etc/rc.d
cp $CWD/rc.saslauthd $PKG/etc/rc.d/
if [ -r /etc/rc.d/rc.saslauthd ];then
mv $PKG/etc/rc.d/rc.saslauthd $PKG/etc/rc.d/rc.saslauthd.new
fi
    postbuild
}

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

