void-packages/triggers/x11-fonts
Juan RP 783dc64e4b Bah redo previous, triggers need to be 755.
--HG--
extra : convert_revision : 38fd5a6f1aea9fc17b8c9055d8a56c9e5f4b8aa7
2009-04-18 15:31:15 +02:00

62 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
#
# This trigger rebuilds the fonts.dir and fonts.scale files
# for packages that install X11 fonts, and update fontconfig's
# cache for those fonts.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install/pre-remove]
# $3 = pkgname
#
trigger="x11-fonts"
mkfontdir=./usr/bin/mkfontdir
mkfontscale=./usr/bin/mkfontscale
fccache=./usr/bin/fc-cache
case "$1" in
targets)
echo "post-install pre-remove"
;;
run)
if [ ! -x ${mkfontdir} -a ! -x ${mkfontscale} ]; then
exit 0
fi
[ -z "${font_dirs}" ] && exit 0
echo "Running $trigger trigger..."
case "$2" in
post-install)
for dir in ${font_dirs}; do
echo "Building ${dir}/fonts.dir..."
${mkfontdir} .${dir} || exit $?
echo "Building ${dir}/fonts.scale..."
${mkfontscale} .${dir} || exit $?
echo "Updating fontconfig's cache..."
${fccache} .${dir} 2>/dev/null
done
;;
pre-remove)
for dir in ${font_dirs}; do
if [ -f .${dir}/fonts.dir ]; then
rm -f .${dir}/fonts.dir
fi
if [ -f .${dir}/fonts.scale ]; then
rm -f .${dir}/fonts.scale
fi
if [ -f .${dir}/encodings.dir ]; then
rm -f .${dir}/encodings.dir
fi
done
;;
esac
;;
*)
exit 1
;;
esac
exit 0