pkgsrc/mk/pkginstall/fonts
jlam 83f1c3afae * Add a user-settable variable to tune the default verbosity of the
+INSTALL and +DEINSTALL scripts:

  PKGINSTALL_VERBOSE
	A list of scriptlets that will be verbose and output a message
	noting the actions taken.

	* "all" is a special value that implies all of the other items
	* "fonts" for +FONTS
	* "info-files" for +INFO_FILES

	Default value: "all" for PKG_DEVELOPERs, empty otherwise.

* Be "one-liner brief" when doing the default actions.  For example,
  the info files output now looks like:

	gmake-3.81: registering info file /usr/pkg/info/make.info

  We retain the current verbosity for the CHECK-* actions.
2007-07-12 19:41:46 +00:00

106 lines
2.8 KiB
Text

# $NetBSD: fonts,v 1.5 2007/07/12 19:41:46 jlam 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@"
TTF_INDEX_CMD="@TTF_INDEX_CMD@"
TYPE1_INDEX_CMD="@TYPE1_INDEX_CMD@"
TYPE1_POSTINDEX_CMD="@TYPE1_POSTINDEX_CMD@"
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
case "${FONTS_VERBOSE:-@FONTS_VERBOSE@}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
echo="${ECHO}"
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
echo=":"
;;
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
( $echo "${PKGNAME}: updating font database in $dir ($font_type)"
cd $dir
update_args=
post_update_cmd=
case $font_type in
[tT][tT][fF]) update_cmd="${TTF_INDEX_CMD}" ;;
[tT][yY][pP][eE]1) update_cmd="${TYPE1_INDEX_CMD}"
post_update_cmd="${TYPE1_POSTINDEX_CMD}" ;;
[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
EOF
${SED} -n "/^\# FONTS: /p" ${SELF} >> ./+FONTS
${CHMOD} +x ./+FONTS
;;
esac