#!/bin/sh
#
# This is an installation script for groff-latin2 package.
# The original groff_cz was written by Henryk Paluch,
# This script was written by Jan "Yenya" Kasprzak
#
# Sun May 12 14:48:06 MET DST 1996
#
: ${ROOT:=/}
: ${MANDIR:=/usr/local/man/man7}
: ${PATCH:=yes}

umask 022

test -d ${ROOT}/${MANDIR} || mkdir -p ${ROOT}/${MANDIR}
rm -f ${ROOT}/${MANDIR}/groff_cz.7 ${ROOT}/${MANDIR}/groff_cz.7.gz
rm -f ${ROOT}/${MANDIR}/groff_latin2.7 ${ROOT}/${MANDIR}/groff_latin2.7.gz
gzip -9 <groff_latin2.7 >${ROOT}/${MANDIR}/groff_latin2.7.gz

rm -rf ${ROOT}/usr/lib/groff/font/devlatin2 \
	${ROOT}/usr/lib/groff/font/devlatin2cp852
mkdir -p ${ROOT}/usr/lib/groff/font/devlatin2 \
	${ROOT}/usr/lib/groff/font/devlatin2cp852
cp devlatin2/* ${ROOT}/usr/lib/groff/font/devlatin2
cp devlatin2cp852/* ${ROOT}/usr/lib/groff/font/devlatin2cp852

chmod 755 ${ROOT}/usr/lib/groff/font/devlatin2 \
	${ROOT}/usr/lib/groff/font/devlatin2cp852
chmod 644 ${ROOT}/${MANDIR}/groff_latin2.7.gz \
	${ROOT}/usr/lib/groff/font/devlatin2/* \
	${ROOT}/usr/lib/groff/font/devlatin2cp852/*

if [ "$PATCH" = "yes" ]
then
	if test -r ${ROOT}/usr/lib/groff/tmac
	then
		if grep -q latin2 ${ROOT}/usr/lib/groff/tmac/troffrc
		then echo "troffrc already contains a \"latin2\" string, no patch applied."
		else
			patch -p0 -s -d ${ROOT}/usr/lib/groff/tmac <$PATCH \
				|| exit 1
		fi
	else echo "troffrc does not exist, no patch applied."
	fi
fi
exit 0

