Subject: pkg/18903: Automate registration of fonts in ms-ttf
To: None <gnats-bugs@gnats.netbsd.org>
From: Julio Merino <jmmv@menta.net>
List: netbsd-bugs
Date: 11/03/2002 20:55:59
>Number:         18903
>Category:       pkg
>Synopsis:       Automate registration of fonts in ms-ttf
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 03 11:52:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Julio Merino
>Release:        NetBSD 1.6J
>Organization:
HispaBSD
>Environment:
	
	
System: NetBSD darkstar.local 1.6J NetBSD 1.6J (DARKSTAR) #34: Sun Oct 27 00:22:56 CEST 2002 jmmv@darkstar.local:/var/build/kernel/DARKSTAR i386
Architecture: i386
Machine: i386
>Description:
	The package ms-ttf installs a serie of TrueType fonts; although, the
	administrator needs to setup everything for they to work: install
	ttmkfdir, generate the fonts.dir file by hand and at last change
	X configuration (or X font server setup).

	I've modified the ms-ttf package to automate the first two steps:
	it will now install ttmkfdir and use it to generate the fonts.dir file
	when installing (obvious) and when deinstalling (if there are other
	truetype fonts, fonts.dir must remain there but updated).
>How-To-Repeat:
	
>Fix:
	Apply this patch:

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/fonts/ms-ttf/Makefile,v
retrieving revision 1.5
diff -u -u -r1.5 Makefile
--- Makefile	2002/10/11 10:09:30	1.5
+++ Makefile	2002/11/03 19:45:23
@@ -2,7 +2,7 @@
 
 DISTNAME=	# empty
 PKGNAME=	ms-ttf-20020306
-PKGREVISION=	1
+PKGREVISION=	2
 CATEGORIES=	fonts
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE:=corefonts/}
 DISTFILES=	andale32.exe webdin32.exe trebuc32.exe georgi32.exe \
@@ -13,6 +13,7 @@
 HOMEPAGE=	http://corefonts.sourceforge.net/
 COMMENT=	TrueType fonts from Microsoft
 
+DEPENDS+=	ttmkfdir-[0-9]*:../../fonts/ttmkfdir
 BUILD_DEPENDS+=	cabextract-[0-9]*:../../archivers/cabextract
 
 LICENSE=        ms-ttf-license
@@ -34,6 +35,13 @@
 FONTDIR=	${PREFIX}/lib/X11/fonts/TrueType
 DOCDIR=		${PREFIX}/share/doc/ms-ttf
 
+DEINSTALL_EXTRA_TMPL=	${.CURDIR}/INSTALL
+INSTALL_EXTRA_TMPL=	${.CURDIR}/INSTALL
+
+FILES_SUBST+=	TTMKFDIR="${LOCALBASE}/bin/ttmkfdir"
+FILES_SUBST+=	FONTDIR="${FONTDIR}"
+MESSAGE_SUBST+=	FONTDIR="${FONTDIR}"
+
 post-extract:
 	${_PKG_SILENT}${_PKG_DEBUG}					\
 	for f in ${WRKSRC}/*.TTF ; do					\
@@ -48,4 +56,5 @@
 	done
 	${INSTALL_DATA} ${.CURDIR}/../../licenses/${LICENSE} ${DOCDIR}
 
+.include "../../mk/bsd.pkg.install.mk"
 .include "../../mk/bsd.pkg.mk"
Index: PLIST
===================================================================
RCS file: /cvsroot/pkgsrc/fonts/ms-ttf/PLIST,v
retrieving revision 1.2
diff -u -u -r1.2 PLIST
--- PLIST	2002/03/07 13:22:33	1.2
+++ PLIST	2002/11/03 19:45:23
@@ -31,4 +31,3 @@
 lib/X11/fonts/TrueType/trebucit.ttf
 share/doc/ms-ttf/ms-ttf-license
 @dirrm share/doc/ms-ttf
-@unexec ${RMDIR} %D/lib/X11/fonts/TrueType 2>/dev/null || true



	Now you need the INSTALL script; I've tried to do this with @exec
	and @unexec from the PLIST, but by some reason it was not able to
	create the fonts.dir file (I think @exec is executed too early
	during installation, not sure). But well, INSTALL does the job
	perfectly:

#!/bin/sh
#
# $NetBSD$

TTMKFDIR=@TTMKFDIR@
FONTDIR=@FONTDIR@

case ${STAGE} in
POST-INSTALL)
	cd ${FONTDIR} && ${TTMKFDIR} > fonts.dir
	;;

POST-DEINSTALL)
	cd ${FONTDIR} && ${TTMKFDIR} > fonts.dir
	if [ "`${CAT} ${FONTDIR}/fonts.dir`" = "0" ]; then
		${RM} -f ${FONTDIR}/fonts.dir
	fi
	${RMDIR} ${FONTDIR} 2>/dev/null || true
	;;
esac




	And, at last, the MESSAGE:

===========================================================================
$NetBSD$

The ms-ttf package has installed several TrueType fonts inside

	${FONTDIR}

and has generated the index fonts.dir file for you. If you are using
XFree86 4.x you will need to add these lines to the configuration file:

	# In section Module
	Load "freetype"
	# In section Files
	FontPath "${FONTDIR}"	

===========================================================================


	Thanks!
>Release-Note:
>Audit-Trail:
>Unformatted: