diff options
author | jlam <jlam> | 2005-12-29 03:44:38 +0000 |
---|---|---|
committer | jlam <jlam> | 2005-12-29 03:44:38 +0000 |
commit | 5c20ba02ebdb97c30955b1d418e91980b2e49dd5 (patch) | |
tree | c20aafd6166d5a05124edfecc876c076baf99c06 /mk/install | |
parent | e885a99bf682e4b13f530cca5a573254e08b0cca (diff) | |
download | pkgsrc-5c20ba02ebdb97c30955b1d418e91980b2e49dd5.tar.gz |
Re-implement the pkgsrc fonts-handling by integrating it into the
pkginstall framework:
* Rewrite the mk/install/fonts script fragment as a scriptlet that's
generated by the +INSTALL script during package installation.
* Rename the FONTS_<TYPE>_DIRS variables to FONTS_DIRS.<type> to
be more consistent with how "families" of variables are currently
named in pkgsrc.
* Rewrite mk/fonts.mk so that it's implemented in terms of the new
functionality in the pkginstall framework. This file will be
obsoleted in the near future after packages have been transitioned
to use the new functionality in the pkginstall framework. Currently,
packages will continue to work with no changes.
Integrating the fonts-handling into the pkginstall framework has the
benefit of generating a +FONTS scriptlet that may be run independently
of the +INSTALL scripts to (idempotently) update the fonts databases
and fix package installation errors.
Diffstat (limited to 'mk/install')
-rw-r--r-- | mk/install/bsd.pkginstall.mk | 83 | ||||
-rw-r--r-- | mk/install/deinstall | 7 | ||||
-rw-r--r-- | mk/install/fonts | 110 | ||||
-rw-r--r-- | mk/install/install | 7 |
4 files changed, 164 insertions, 43 deletions
diff --git a/mk/install/bsd.pkginstall.mk b/mk/install/bsd.pkginstall.mk index 0a43ebeded2..844a5968ae6 100644 --- a/mk/install/bsd.pkginstall.mk +++ b/mk/install/bsd.pkginstall.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkginstall.mk,v 1.30 2005/12/05 22:07:07 rillig Exp $ +# $NetBSD: bsd.pkginstall.mk,v 1.31 2005/12/29 03:44:38 jlam Exp $ # # This Makefile fragment is included by bsd.pkg.mk to use the common # INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply: @@ -541,6 +541,87 @@ ${INSTALL_SHELL_FILE}: ../../mk/install/shell ${MV} -f ${.TARGET}.tmp ${.TARGET} .endif +# FONTS_DIRS.<type> are lists of directories in which the font databases +# are updated. If this is non-empty, then the appropriate tools is +# used to update the fonts database for the font type. The supported +# types are: +# +# ttf TrueType fonts +# type1 Type1 fonts +# x11 Generic X fonts, e.g. PCF, SNF, BDF, etc. +# +FONTS_DIRS.ttf?= # empty +FONTS_DIRS.type1?= # empty +FONTS_DIRS.x11?= # empty + +INSTALL_FONTS_FILE= ${WRKDIR}/.install-fonts +INSTALL_FONTS_MEMBERS= ${FONTS_DIRS.ttf} ${FONTS_DIRS.type1} ${FONTS_DIRS.x11} +INSTALL_UNPACK_TMPL+= ${INSTALL_FONTS_FILE} + +# Directories with TTF and Type1 fonts also need to run mkfontdir, so +# list them as "x11" font directories as well. +# +.if !empty(FONTS_DIRS.ttf:M*) +USE_TOOLS+= ttmkfdir:run +FILES_SUBST+= TTMKFDIR=${TOOLS_PATH.ttmkfdir:Q} +FONTS_DIRS.x11+= ${FONTS_DIRS.ttf} +.endif +.if !empty(FONTS_DIRS.type1:M*) +USE_TOOLS+= type1inst:run +FILES_SUBST+= TYPE1INST=${TOOLS_PATH.type1inst:Q} +FONTS_DIRS.x11+= ${FONTS_DIRS.type1} +.endif +.if !empty(FONTS_DIRS.x11:M*) +USE_TOOLS+= mkfontdir:run +FILES_SUBST+= MKFONTDIR=${TOOLS_PATH.mkfontdir:Q} +.endif + +.if empty(INSTALL_FONTS_MEMBERS:M*) +${INSTALL_FONTS_FILE}: + ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET} +.else +${INSTALL_FONTS_FILE}: ../../mk/install/fonts + ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET} ${.TARGET}.tmp + ${_PKG_SILENT}${_PKG_DEBUG} \ + ${_FUNC_STRIP_PREFIX}; \ + exec 1>>${.TARGET}.tmp; \ + ${ECHO} "# start of install-fonts"; \ + ${ECHO} "#"; \ + ${ECHO} "# Generate a +FONTS script that updates fonts databases."; \ + ${ECHO} "#"; \ + ${ECHO} "case \$${STAGE} in"; \ + ${ECHO} "PRE-INSTALL|UNPACK)"; \ + ${ECHO} " \$${CAT} > ./+FONTS << 'EOF_FONTS'"; \ + ${SED} ${FILES_SUBST_SED} ../../mk/install/fonts; \ + ${ECHO} ""; \ + set -- dummy ${FONTS_DIRS.ttf}; shift; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; shift; \ + dir=`strip_prefix "$$dir"`; \ + ${ECHO} "# FONTS: $$dir ttf"; \ + done; \ + set -- dummy ${FONTS_DIRS.type1}; shift; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; shift; \ + dir=`strip_prefix "$$dir"`; \ + ${ECHO} "# FONTS: $$dir type1"; \ + done; \ + set -- dummy ${FONTS_DIRS.x11}; shift; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; shift; \ + dir=`strip_prefix "$$dir"`; \ + ${ECHO} "# FONTS: $$dir x11"; \ + done; \ + ${ECHO} "EOF_FONTS"; \ + ${ECHO} " \$${CHMOD} +x ./+FONTS"; \ + ${ECHO} " ;;"; \ + ${ECHO} "esac"; \ + ${ECHO} ""; \ + ${ECHO} "# end of install-fonts"; \ + exec 1>/dev/null; \ + ${MV} -f ${.TARGET}.tmp ${.TARGET} +.endif + # PKG_CREATE_USERGROUP indicates whether the INSTALL script should # automatically add any needed users/groups to the system using # useradd/groupadd. It is either YES or NO and defaults to YES. diff --git a/mk/install/deinstall b/mk/install/deinstall index fb451e9907f..ec75988d222 100644 --- a/mk/install/deinstall +++ b/mk/install/deinstall @@ -1,7 +1,7 @@ # -*- sh -*- # start of deinstall # -# $NetBSD: deinstall,v 1.36 2005/08/19 22:24:10 jlam Exp $ +# $NetBSD: deinstall,v 1.37 2005/12/29 03:44:38 jlam Exp $ case ${STAGE} in VIEW-DEINSTALL) @@ -48,6 +48,11 @@ POST-DEINSTALL) ${RMDIR} -p `${DIRNAME} ${PKG_SYSCONFDIR}` 2>/dev/null || ${TRUE} fi # + # Update any fonts databases. + # + ${TEST} ! -x ./+FONTS || + ./+FONTS ${PKG_METADATA_DIR} + # # Remove empty directories and unused users/groups. # ${TEST} ! -x ./+DIRS || diff --git a/mk/install/fonts b/mk/install/fonts index 1ec70710f90..5501c8a1c8e 100644 --- a/mk/install/fonts +++ b/mk/install/fonts @@ -1,47 +1,77 @@ -# $NetBSD: fonts,v 1.6 2004/12/28 14:38:03 wiz Exp $ +#!@SH@ # -# Handle font databases; used by fonts.mk. +# $NetBSD: fonts,v 1.7 2005/12/29 03:44:38 jlam Exp $ +# +# +FONTS - font database management script +# +# Usage: ./+FONTS [metadatadir] +# +# This scripts rebuilds font databases needed by the package associated +# with <metadatadir>. +# +# Lines starting with "# FONTS: " are data read by this script that name +# the directories in which the font database will be rebuilt. +# +# # FONTS: /usr/pkg/lib/X11/fonts/TTF ttf +# # FONTS: /usr/pkg/lib/X11/fonts/Type1 type1 +# # FONTS: /usr/pkg/lib/X11/fonts/misc x11 +# +# For each FONTS entry, if the path is relative, that it is taken to be +# relative to ${PKG_PREFIX}. # -FONTS_TTF="@FONTS_TTF@" -FONTS_TTF_DIRS="@FONTS_TTF_DIRS@" -FONTS_TYPE1="@FONTS_TYPE1@" -FONTS_TYPE1_DIRS="@FONTS_TYPE1_DIRS@" -FONTS_X11="@FONTS_X11@" -FONTS_X11_DIRS="@FONTS_X11_DIRS@" +ECHO="@ECHO@" +GREP="@GREP@" +LS="@LS@" +MKFONTDIR="@MKFONTDIR@" +PWD_CMD="@PWD_CMD@" +RM="@RM@" +SED="@SED@" +SORT="@SORT@" +TEST="@TEST@" +TRUE="@TRUE@" TTMKFDIR="@TTMKFDIR@" TYPE1INST="@TYPE1INST@" -MKFONTDIR="@MKFONTDIR@" -case ${STAGE} in -POST-INSTALL|POST-DEINSTALL) - ${ECHO} "===> Updating font databases" - if [ "${FONTS_TTF}" = "YES" ]; then - for d in ${FONTS_TTF_DIRS}; do - if [ -z "`cd $d ; ${LS} | ${GREP} -v .pkgsrc | ${GREP} -v ^fonts | ${GREP} -v ^Fontmap`" ]; then - ${RM} -f $d/fonts* $d/Fontmap* - else - ( cd $d && ${TTMKFDIR} >/dev/null 2>&1 ) - fi - done - fi - if [ "${FONTS_TYPE1}" = "YES" ]; then - for d in ${FONTS_TYPE1_DIRS}; do - if [ -z "`cd $d ; ${LS} | ${GREP} -v .pkgsrc | ${GREP} -v ^fonts | ${GREP} -v ^Fontmap`" ]; then - ${RM} -f $d/fonts* $d/Fontmap* - else - ( cd $d && ${TYPE1INST} >/dev/null 2>&1 ) - fi - done - fi - if [ "${FONTS_X11}" = "YES" ]; then - for d in ${FONTS_X11_DIRS}; do - if [ -z "`cd $d ; ${LS} | ${GREP} -v .pkgsrc | ${GREP} -v ^fonts | ${GREP} -v ^Fontmap`" ]; then - ${RM} -f $d/fonts* $d/Fontmap* - else - ${MKFONTDIR} $d >/dev/null 2>&1 - fi - done - fi +SELF=$0 +PKG_METADATA_DIR="${1-`${PWD_CMD}`}" +: ${PKGNAME=${PKG_METADATA_DIR##*/}} +: ${PKG_PREFIX=@PREFIX@} + +${SED} -n "/^\# FONTS: /{s/^\# FONTS: //;p;}" ${SELF} | ${SORT} -u | +{ while read dir font_type; do + case $dir in + "") continue ;; + [!/]*) dir="${PKG_PREFIX}/$dir" ;; + esac + ${TEST} -d "$dir" || continue + case "$printed_header" in + yes) ;; + *) printed_header=yes + ${ECHO} "===========================================================================" + ${ECHO} "Updating font databases in the following directories:" + ${ECHO} "" + ;; + esac + ( ${ECHO} " $dir ($font_type)" + cd $dir + case $font_type in + [tT][tT][fF]) update_cmd="${TTMKFDIR}" ;; + [tT][yY][pP][eE]1) update_cmd="${TYPE1INST}" ;; + [xX]11) update_cmd="${MKFONTDIR}" ;; + esac + ${TEST} -f "$update_cmd" || update_cmd="${TRUE}" + $update_cmd >/dev/null + # + # Remove fonts databases if there are no fonts in the directory. + # We filter out the encodings.dir, fonts.{alias,dirs,scale}, and + # Fontmap database files from the directory listing. + # + ${LS} | ${GREP} -v "^encodings.dir" | ${GREP} -v "^fonts\." | ${GREP} -v "^Fontmap" >/dev/null || ${RM} -f fonts.* Fontmap* + ) +done +case "$printed_header" in +yes) ${ECHO} "" + ${ECHO} "===========================================================================" ;; -esac +esac; } diff --git a/mk/install/install b/mk/install/install index 3fa0182ed9c..0a701413846 100644 --- a/mk/install/install +++ b/mk/install/install @@ -1,7 +1,7 @@ # -*- sh -*- # start of install # -# $NetBSD: install,v 1.41 2005/08/19 22:24:10 jlam Exp $ +# $NetBSD: install,v 1.42 2005/12/29 03:44:38 jlam Exp $ case ${STAGE} in PRE-INSTALL) @@ -50,6 +50,11 @@ POST-INSTALL) # ${TEST} ! -x ./+PERMS || ./+PERMS ${PKG_METADATA_DIR} + # + # Update any fonts databases. + # + ${TEST} ! -x ./+FONTS || + ./+FONTS ${PKG_METADATA_DIR} # Check for any missing bits after we're finished installing. # |