#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-ncftp
VERSION=3.2.2
ARCH=alpha
BUILD=1
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf ncftp-$VERSION
tar xjf $CWD/ncftp-$VERSION-src.tar.bz2
cd ncftp-$VERSION
chown -R root.root .
./configure \
 --prefix=/usr \
 --build=$TARGET || exit 1
make -j2 || exit 1
mkdir -p $PKG/usr/bin
( cd bin
 for file in ncftp ncftpbatch ncftpbookmarks ncftpget ncftpls ncftpput ; do
 strip --strip-unneeded $file
 cat $file > $PKG/usr/bin/$file
 done
)
( cd $PKG/usr/bin
 rm -f ncftpspooler
 ln -sf ncftpbatch ncftpspooler
 chmod 755 *
 chown -R root.bin .
)
mkdir -p $PKG/usr/man/man1
( cd doc/man
 for file in *.1 ; do
 cat $file | gzip -9c > $PKG/usr/man/man1/$file.gz
 done )
mkdir -p $PKG/usr/doc/ncftp-$VERSION
cp -a doc/* $PKG/usr/doc/ncftp-$VERSION
# Useless redundancy:
rm -r $PKG/usr/doc/ncftp-$VERSION/man $PKG/usr/doc/ncftp-$VERSION/html
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/ncftp-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/ncftp.build.log
