#!/bin/sh
# Heavily based on the Slackware 12.0 SlackBuild
# http://www.pd.istc.cnr.it/FESTIVAL/home/download-MBROLA.htm
# 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_italian
NAME=festvox_mbrola_italian
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
unzip -o $CWD/lp_mbrola_unix.zip 
unzip -o $CWD/pc_mbrola_unix.zip )

( cd $PKG/usr/share/festival/lib/voices/italian/pc_mbrola
unzip -o $CWD/it3-010304.zip
cd ../lp_mbrola
unzip -o $CWD/it4-010926.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 -p $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

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