#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-termcap

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi


cd $TMP
tar xzvf $CWD/termcap-compat_1.1.1.1.1.tar.gz
cd termcap-compat-1.1.1.1.1
zcat $CWD/termcap.h.diff.gz | patch -p0
zcat $CWD/termcap.string_h.diff.gz | patch -p1
zcat $CWD/link_path.diff.gz | patch Makefile
make 
mkdir -p $PKG/usr/info $PKG/usr/lib $PKG/usr/include $PKG/lib
make install prefix=$PKG/usr
mv $PKG/lib/libtermcap.so.2.0.8 $PKG/lib/libtermcap.so.2.0.8-incoming
mkdir -p $PKG/usr/doc/termcap-2.0.8

cp -a ChangeLog debian/changelog README $PKG/usr/doc/termcap-2.0.8
chown root.root $PKG/usr/doc/termcap-2.0.8/*

# termcap makefile forgets to install *.info when prefix is set
cp -a *.info* $PKG/usr/info
( cd $PKG/usr/info ; gzip -9 termcap.info* ; chown root.root * ; chmod 644 *)

mkdir $PKG/install
cp -a $CWD/doinst.sh $PKG/install

cd $PKG
echo "y
n" | makepkg $TMP/termcap.tgz
