#!/bin/sh
# Heavily based on the Slackware 12.0 SlackBuild
# http://tcts.fpms.ac.be/synthesis/mbrola.html
# Packager Andrea Sciucca ( gohanz at infinito.it)
# http://www.slacky.it
# Required: Festival, Speech_tools,Mbrola

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package/festvox_mbrola_us
NAME=festvox_mbrola_us
VERSION=`date +%Y%m%d`
ARCH=${ARCH:-noarch}
BUILD=1as

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP

mkdir -p $PKG/usr/share

( cd $PKG/usr/share
 tar xvzf $CWD/festvox_us1.tar.gz 
 tar xvzf $CWD/festvox_us2.tar.gz
 tar xvzf $CWD/festvox_us3.tar.gz )

( cd $PKG/usr/share/festival/lib/voices/english/us1_mbrola
unzip -o $CWD/us1-980512.zip
cd ../us2_mbrola
unzip -o $CWD/us2-980812.zip 
cd ../us3_mbrola
unzip -o $CWD/us3-990208.zip  )

echo -e "\E[0;32m+--------------------------------------------------+\E[0;0m"
echo -e "\E[0;32m| Start SlackBuild $NAME-$VERSION |\E[0;0m"
echo -e "\E[0;32m+--------------------------------------------------+\E[0;0m"

mkdir -p $PKG/usr/doc/$NAME-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild

cd $PKG
chown -R root:root .
requiredbuilder -y -v -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP
fi
