#!/bin/sh
#
# kTm port by Juzer & kom4r
#
umask 022
DESTPKG=/tmp/ktm-`mcookie`
DESTTGZ=/httpd/html/ktm/current/
CVSDIR=/usr/src/CVS
mkdir -p $DESTPKG/
cd $CVSDIR/base
cp -rv . $DESTPKG/
cd $DESTPKG
find . -name CVS* -type d -exec rm -rf "{}" \;
#find . -name CVS -type d -exec rm -rf "{}" \;
ZM=`ls $DESTTGZ/ktm-* |tail -1|cut -d '-' -f 4|sed -e s/.tgz//`
SUMA=$(( $ZM + 1 ))
mv $DESTTGZ/ktm-*.tgz $DESTTGZ/old
chown root.root . -R
if [ -r /etc/ports.conf ];then
mv $DESTPKG/etc/ports.conf $DESTPKG/etc/ports.conf.new
fi
find . -type d -exec chmod 755 "{}" \;
find . -type f -exec chmod 644 "{}" \;
find . -type d \( -path '*/bin' -o -path '*/sbin' \) -exec chmod 755 "{}" -R \;
find . -type d \( -path '*/bin' -o -path '*/sbin' \) -exec chown root.bin "{}" -R \;
makepkg -l y -c n $DESTTGZ/ktm-0.3.1.2-noarch-$SUMA.tgz
rm -rf $DESTPKG
