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

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

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE-|cut -d "-" -f 1,2`"
$WGET -q ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/
NEW=`grep $PACKAGE index.html|grep .tar|grep -v i386|cut -d / -f 8|cut -d '"' -f 1|sed -e s/.tar.*//|sort -n|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/$SRC.tar.gz
}

build() {
# Creating new
VER=`echo $SRC|cut -d - -f 2`
tar zxvf $DOWNL/$SRC.tar.gz
cd $SRC
./configure \
    --prefix=/usr \
    $TARGET || exit
make || exit
make install DESTDIR=$PKG || exit
cd $PKG/usr/lib/rpm
ln -s rpmpopt-$VER rpmpopt
    postbuild
}

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

