#!/bin/sh

# libtermcap.build
# by Stuart Winter <stuart@armedslack.org>
# Heavily based the original Slackware build script. 

# Get version from trackbuild script:
VERSION=$1

# Extract source into slacktrack's scratchdir:
cd ${SLACKTRACKSCRATCHDIR}
tar xzvf $CWD/termcap-compat_$VERSION.tar.gz
cd termcap-compat-$VERSION
slackhousekeeping

# Apply patches:
zcat $CWD/termcap-compat_$VERSION.diff.gz | patch -p1 --verbose --backup --suffix=.orig
zcat $CWD/termcap.h.diff.gz | patch -p0 --verbose --backup --suffix=.orig
zcat $CWD/termcap.bufsize.diff.gz | patch -p1 --verbose --backup --suffix=.orig

# Make:
make

# Install:
make install

# Install docs:
mkdir -p /usr/doc/termcap-$VERSION
cp -a ChangeLog debian/changelog README /usr/doc/termcap-$VERSION

# Update /etc/ld.so.cache
# this doesn't when building under slacktrack but it will if you
# use altertrack, so I'll leave it in.
( cd /lib ; ldconfig . )

# Fix crazy ownerships & delete some junk:
( cd ${SLACKTRACKFAKEROOT}
  rm -rf lib/backup etc
  chown -R root:root . )

# Install package description:
rm -rf /install
mkdir -p /install
install -m644 $CWD/slack-desc /install

# This is just to make sure we don't get burned with the bunk termcap...  reinstall etc to fix.
rm -f /etc/termcap

