Developers' Guide to Defoma
Chapter 2 Application Package's HOWTO
Applications that are configurable about fonts and have users configure about
fonts by some means are able to achieve dynamic configuration about fonts
through Defoma framework. This chapter describes how to build a Defoma-aware
application package step by step.
Prepare a Defoma-configuration script. This script is provided by each
application that uses the Defoma framework and configures fonts for its
application. It is called whenever a font is installed or removed, so that it
updates the configuration about fonts. How to write a Defoma-configuration
script is not described in this document, so please refer others.
The Defoma configuration script must be put under debian/
subdirectory and its name should be <package-name>.defoma.
Edit debian/rules to call dh_installdefoma in binary-arch or
binary-indep phase.
When the application package is installed, the Defoma-configuration script
needs to configure about installed fonts for the application. To make it
possible, edit debian/postinst file to call defoma-app with update
command.
(ex: debian/postinst)
...
if [ "$1" = configure ]; then
/usr/bin/defoma-app update <package-name>
fi
...
When the application package is removed/upgraded, the Defoma-configuration
script needs to clean up the configuration. Edit debian/prerm
file to call defoma-app with purge/clean command respectively.
(ex: debian/prerm)
...
if [ "$1" = remove ]; then
/usr/bin/defoma-app purge <package-name>
fi
if [ "$1" = upgrade ]; then
/usr/bin/defoma-app clean <package-name>
fi
...
In addition, when the application package is removed,
/var/lib/defoma/<package-name>.d directory MUST be removed
without fail. Edit debian/postrm file to remove the directory.
(ex: debian/postrm)
...
if [ "$1" = remove ]; then
/bin/rm -fr /var/lib/defoma/<package-name>.d
fi
...
If the application package provides a public subst-rule (see Defoma::Subst
manpage), the rulefile should be created at postinst if the rulefile doesn't
exist. Edit debian/postinst file to call defoma-subst with
new-rule command. It should be called before defoma-app.
(ex: debian/postinst)
...
if [ "$1" = configure ]; then
if [ ! -f "/etc/defoma/<rulename>.subst-rule ]; then
/usr/bin/defoma-subst new-rule <rulename>
fi
..
/usr/bin/defoma-app update <package-name>
fi
Created rulefile is considered as conffile, so it must be removed when the
package is purged. Edit debian/postrm file to remove the rulefile
at purge.
(ex: debian/postrm)
...
FILE='/etc/defoma/<rulename>.subst-rule'
if [ "$1" = purge ]; then
/bin/rm -f $FILE $FILE~
fi
Edit debian/control to make the package depend on defoma.
Which version to depend is decided by what function the script makes use of.
See /usr/share/doc/defoma-doc/version-dependency.txt for more
detail.
It is recommended to provide README.Defoma which describes categories which the
script accepts and installs to, and HintTypes which the script particularly
uses.