#!/bin/sh
#
# emacsen install script for the gri package
# -
# This script is installed by the Gri package `rules' file to 
#  /usr/lib/emacsen-common/packages/install/gri
# It is run by Gri package `postinst' which calls 
#  /usr/lib/emacsen-common/emacs-package-install gri
# The Gri package `postinst' is installed as /var/lib/dpkg/info/gri.postinst
set -e

flavour=$1

package=gri
files="gri-mode.el"
source=/usr/share/emacs/site-lisp/
destination=/usr/share/${flavour}/site-lisp/
flags="-q --no-site-file -no-site-file --batch -f batch-byte-compile"
LOG=`tempfile -pelc_ -s.log -m644`

if [ ${flavour} != emacs ]
then
    echo install/${package}: Handling ${flavour}, logged in ${LOG}

    # Copy the temp .el files into the destination directory
    install -c -m 0755 -d ${destination}
    for i in $files
    do 
	cp $source/$i $destination
    done

    # Byte compile them 
    cd ${destination}
    echo ${flavour} ${flags} ${files} >> ${LOG}
    ${flavour} ${flags} ${files} >> ${LOG} &> ${LOG} 
    rm ${files}
else
    echo install/${package}: Ignoring emacsen flavour ${flavour}
fi

exit 0;

