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

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

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED=`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2`
$WGET -q http://www.squid-cache.org/Versions/v2/2.5/
NEW=`grep $PACKAGE index.html|grep .tar.bz2|cut -d '"' -f 2|sort -n|sed -e s/.tar.*.//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL http://www.squid-cache.org/Versions/v2/2.5/$SRC.tar.bz2
}

build() {
# Creating new
tar jxvf $DOWNL/$SRC.tar.bz2
cd $SRC
gunzip -c $CWD/squid-2.5.STABLE5-ToS_Hit.patch-2004-04-27.gz | patch -p1
./configure \
    --prefix=/usr \
    --with-openssl \
    --enable-linux-netfilter \
    --enable-useragent-log  \
    --enable-cache-digests \
    --enable-delay-pools \
    --disable-internal-dns \
    --enable-referer-log \
    --enable-icmp \
    --sysconfdir=/etc/squid  \
    --enable-default-err-language=Polish \
    --enable-err-languages=Polish \
    --enable-arp-acl \
    --enable-snmp \
    --enable-wccpv2 \
    --enable-storeio=ufs,aufs,diskd \
    --enable-removal-policies=heap,lru \
    --with-aio \
    --with-dl \
    --with-pthreads \
    --enable-carp \
    --enable-htcp \
    --enable-http-violations \
    $TARGET || exit
make || exit
make install prefix=$PKG/usr sysconfdir=$PKG/etc/squid oldincludedir=$PKG/usr/include || exit
mkdir $PKG/etc/rc.d/
cp $CWD/rc.squid $PKG/etc/rc.d/
if [ -r /etc/rc.d/rc.squid ];then
mv $PKG/etc/rc.d/rc.squid $PKG/etc/rc.d/rc.squid.new
fi
if [ -d /etc/squid ]; then
mv $PKG/etc/squid $PKG/etc/squid.new
fi
    postbuild
}

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

