pkgsrc/mk/pkginstall/fonts
joerg 7545d135e6 - Compute CHEKCK_FILES filter on the entries requested and keep it
as tight as possible. Files we don't handle shouldn't be skipped.
- fonts.alias is not created automatically, so don't remove it.
- create fonts.encoding with mkfontdir using -e X11_ENCODINGSDIR.
  On platforms not following the X11R6 loayout this might need to
  be overriden.
- Fix type1inst calls.
- Modify packages which installed fonts.alias before to actually
  include it in the PLIST and bump the revisions accordingly.
- Modify xorg-fonts* packages to use FONTS_DIRS.* to build indices
  at run time.

Discussed with wiz and jlam.
2006-09-22 21:53:56 +00:00

109 lines
2.9 KiB
Text

# $NetBSD: fonts,v 1.3 2006/09/22 21:53:58 joerg Exp $
#
# Generate a +FONTS script that updates font databases for the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+FONTS)
${CAT} > ./+FONTS << 'EOF'
#!@SH@
#
# +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}.
#
ECHO="@ECHO@"
FIND="@FIND@"
GREP="@GREP@"
MKFONTDIR="@MKFONTDIR@"
PWD_CMD="@PWD_CMD@"
RM="@RM@"
SED="@SED@"
SORT="@SORT@"
TEST="@TEST@"
TRUE="@TRUE@"
TTMKFDIR="@TTMKFDIR@"
TYPE1INST="@TYPE1INST@"
X11_ENCODINGSDIR="@X11_ENCODINGSDIR@"
SELF=$0
CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${1-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_PREFIX=@PREFIX@}
case "${PKG_UPDATE_FONTS_DB:-@PKG_UPDATE_FONTS_DB@}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_UPDATE_FONTS_DB=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_UPDATE_FONTS_DB=no
;;
esac
${SED} -n "/^\# FONTS: /{s/^\# FONTS: //;p;}" ${SELF} | ${SORT} -u |
{ while read dir font_type; do
case ${_PKG_UPDATE_FONTS_DB} in
no) continue ;;
esac
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
update_args=
post_update_cmd=
case $font_type in
[tT][tT][fF]) update_cmd="${TTMKFDIR}" ;;
[tT][yY][pP][eE]1) update_cmd="${TYPE1INST}"
post_update_cmd="${RM} type1inst.log" ;;
[xX]11) update_cmd="${MKFONTDIR}"
[ ! -z "${X11_ENCODINGSDIR}" ] && update_args="-e ${X11_ENCODINGSDIR}" ;;
esac
${TEST} -f "$update_cmd" || update_cmd="${TRUE}"
$update_cmd $update_args >/dev/null
$post_update_cmd
#
# Remove fonts databases if there are no fonts in the directory.
# We filter out the encodings.dir, fonts.{dirs,scale}, and
# Fontmap database files from the directory listing.
#
${FIND} . -type f | ${GREP} -v "/encodings.dir" | ${GREP} -v "/fonts\.scale" | ${GREP} -v "/fonts\.dir" | ${GREP} -v "/Fontmap" >/dev/null || ${RM} -f fonts.dir fonts.scale Fontmap* encodings.dir > /dev/null
)
done
case "$printed_header" in
yes) ${ECHO} ""
${ECHO} "==========================================================================="
;;
esac; }
EOF
${SED} -n "/^\# FONTS: /p" ${SELF} >> ./+FONTS
${CHMOD} +x ./+FONTS
;;
esac