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

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

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2,3,4,5,6`"
$WGET http://download.mks.com.pl/download/linux/
NEW=`grep $PACKAGE index.html |cut -d '"' -f 8|sed -e s/.tgz//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL http://download.mks.com.pl/download/linux/$SRC.tgz || exit
}

build() {
# Creating new
tar zxvf $DOWNL/$SRC.tgz || exit
cd $SRC
mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/local/mks/bazy4/
mkdir -p $PKG/etc/cron.daily/
cp mks32.static $PKG/usr/bin/mks32
cp mks_vir.cfg $PKG/etc
chown root.root $PKG/etc/mks_vir.cfg
chmod 644 $PKG/etc/mks_vir.cfg
chmod 750 $PKG/usr/local/mks
chmod 750 $PKG/usr/local/mks
chown root.mks -R $PKG/usr/local/mks/bazy4/
chmod 755 $PKG/usr/local/mks/bazy4
cp $CWD/mks-update $PKG/etc/cron.daily/
    postbuild
}

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