#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-most
VERSION=4.9.5
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

mkdir -p $PKG
( cd $TMP
tar xjf $CWD/most-$VERSION.tar.bz2
cd most-$VERSION
chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
./configure --prefix=/usr $TARGET
make
make install DESTDIR=$PKG
chown -R root.bin $PKG/usr/bin
strip $PKG/usr/bin/*
gzip -9 $PKG/usr/man/man?/*
mv $PKG/usr/doc/most $PKG/usr/doc/most-$VERSION
for file in $PKG/usr/doc/most-$VERSION/* ; do
  if [ -r `basename $file` ]; then
    cp -a `basename $file` $file
  fi
done
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/most-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/most.build.log
