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

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

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2`"
$WGET -q ftp://sources.redhat.com/pub/bzip2/v102/
NEW=`grep $PACKAGE index.html|grep .tar|cut -d / -f 7|cut -d '"' -f 1|sed -e s/.tar.gz//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL ftp://sources.redhat.com/pub/bzip2/v102/$SRC.tar.gz
}

build() {
# Creating new
tar zxvf $DOWNL/$SRC.tar.gz
cd $SRC
make -f Makefile-libbz2_so
make install PREFIX=$PKG/usr
cp libbz2.so.1.0.2 $PKG/usr/lib
cd $PKG/usr/lib/
ln -s libbz2.so.1.0.2 libbz2.so.1.0
ln -s libbz2.so.1.0.2 libbz2.so
cd $PKG
mv $PKG/usr/bin $PKG/bin
rm $PKG/bin/bunzip2
rm $PKG/bin/bzcat
ln -s $PKG/bin/bzip2 $PKG/bin/bunzip2
ln -s $PKG/bin/bzip2 $PKG/bin/bzcat
cd $PKG
( cd bin ; rm -rf bunzip2 )
( cd bin ; ln -sf bzip2 bunzip2 )
( cd bin ; rm -rf bzcat )
( cd bin ; ln -sf bzip2 bzcat )
    postbuild
}

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