Whole document tree
    

Whole document tree

Developers' Guide to Defoma - Application Package's HOWTO
[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ]

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.

  1. 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.

  2. Edit debian/rules to call dh_installdefoma in binary-arch or binary-indep phase.
         		(ex: debian/rules)
         		binary-indep: build install
         		       dh_testdir
         		       dh_testroot
         		       dh_installdebconf
         		       dh_installdefoma
         		       dh_installdocs
                                ...
    

    FYI, dh_installdefoma actually performs the following steps.

    • Edit debian/rules file to install the script into usr/share/defoma/scripts.
           		      (ex: debian/rules)
           		      DIR = `pwd`/debian/<package-name>
           		      ...
           		      install: build
           		      ...
           		      install -m 644 debian/<package-name>.defoma \
           		      $(DIR)/usr/share/defoma/scripts
      
    • Edit debian/dirs file to create usr/share/defoma/scripts and var/lib/defoma/<package-name>.d directories.
           		      (ex: debian/dirs)
           		      usr/share/defoma/scripts
           		      var/lib/defoma/<package-name>.d
      
    • 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
           		      ...
      
  3. 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
    
  4. Edit debian/control to make the package depend on defoma.
         		(ex: debian/control)
         		Build-Depends: defoma (>= 0.7.0)
         		...
         		Depends: defoma (>= x.y.z)
         		...
    

    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.

  5. It is recommended to provide README.Defoma which describes categories which the script accepts and installs to, and HintTypes which the script particularly uses.


[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ]
Developers' Guide to Defoma
Yasuhiro Take (take@debian.org)