#!/bin/sh
#
# Instructions:
# 
# install cabextract: http://www.cabextract.org.uk/
#
# get all the font files from here: http://corefonts.sourceforge.net/
#
# put the font files in the same dir as the slackbuild scripts and desc
# files:
#
#   msftfonts.SlackBuild
#   slack-desc
#   msftfonts-arial.SlackBuild
#   slack-desc-arial
#
# Depending on what fonts you want (all or Arial), run one of the
# following:
#
# 	sudo sh msftfonts.SlackBuild
#
# or
#
# 	sudo sh msftfonts-arial.SlackBuild
#
# The results will be in /tmp/build
#

APP=msftfonts-arial
VERSION=1.0
ARCH=noarch
BUILD=1beej

#FONTFILES="andale32.exe arial32.exe arialb32.exe comic32.exe 
#	courie32.exe georgi32.exe impact32.exe times32.exe trebuc32.exe 
#	verdan32.exe wd97vwr32.exe webdin32.exe"

FONTFILES="arial32.exe arialb32.exe"

STARTDIR=`pwd`

TTFFONTDIR=usr/share/fonts/TTF

PACKAGENAME=$APP-$VERSION-$ARCH-$BUILD.tgz
PACKAGEDEST=/tmp/build   # final resting place of package

BUILDBASE=/tmp/build/$APP
BUILDDEST=$BUILDBASE/dest

DOCLEANUP="true"

#--------------------------------------------------------------------
# set up build area
#
mkdir -p $BUILDBASE $BUILDDEST

#--------------------------------------------------------------------
# extract and install
#
mkdir -p $BUILDDEST/$TTFFONTDIR
for a in $FONTFILES; do
	cabextract -F \*.TTF -d $BUILDDEST/$TTFFONTDIR $STARTDIR/$a
done

#--------------------------------------------------------------------
# install setup files
#
installdir=$BUILDDEST/install
mkdir $installdir
if [ -f slack-desc-arial ]; then 
    cp slack-desc-arial $installdir/slack-desc
fi
if [ -f doinst.sh ]; then 
    cp doinst.sh $installdir
fi

#--------------------------------------------------------------------
# set ownership
#
chown -R root:root $BUILDDEST

#--------------------------------------------------------------------
# make package
#
(
	cd $BUILDDEST
	makepkg -l y -c y $PACKAGENAME
) || exit 6

mv $BUILDDEST/$PACKAGENAME $PACKAGEDEST

#--------------------------------------------------------------------
# cleanup
#
if [ $DOCLEANUP = "true" ]; then
    rm -rf $BUILDBASE
fi
