<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">

<book id="debian-gnome-policy" lang="en">
  <bookinfo>
    <title>Debian GNOME Packaging Policy</title>
    <author>
      <firstname>Ross</firstname><surname>Burton</surname>
      <email>ross@debian.org</email>
    </author>
    <othercredit>
      <firstname>Mikael</firstname><surname>Hallendal</surname>
      <email>micke@codefactory.se</email>
      <contrib>Advised on correct gtk-doc usage.</contrib>
    </othercredit>
    <othercredit>
      <firstname>Christian</firstname><surname>Marillat</surname>
      <contrib>Documentation clarifications</contrib>
    </othercredit>
    <othercredit>
      <firstname>Bastien</firstname><surname>Nocera</surname>
    </othercredit>
    <othercredit>
      <firstname>Sebastian</firstname><surname>Rittau</surname>
    </othercredit>
    <othercredit>
      <firstname>Gustavo</firstname> <othername>Noronha</othername> <surname>Silva</surname>
    </othercredit>
    <othercredit>
      <firstname>Colin</firstname><surname>Walters</surname>
      <contrib>GNOME-VFS section</contrib>
    </othercredit>
    <abstract>
      <simpara>
        This document describes the policy requirements for the
        packaging of GNOME programs in Debian GNU/Linux.
      </simpara>
    </abstract>
    <revhistory>
      <revision>
        <revnumber>20030502-1</revnumber>
        <date>2003-05-03</date>
        <revremark>Clarified gtk-doc layout, added a section on the
        'gnome' section, and clarified the section for
        engines.</revremark>
      </revision>
      <revision>
        <revnumber>20030218-1</revnumber>
        <date>2003-02-18</date>
        <revremark>Rewrote section on API Documentation, after talking
        to gtk-doc developers.</revremark>
      </revision>
      <revision>
        <revnumber>20030119-1</revnumber>
        <date>2003-01-19</date>
        <revremark>Added a section on GnomeVFS, and rewrote the API
        documentation section.</revremark>
      </revision>
      <revision>
        <revnumber>20030114-1</revnumber>
        <date>2003-01-14</date>
        <revremark>Reformatted in DocBook.</revremark>
      </revision>
    </revhistory>
    <copyright>
      <year>2003</year>
      <holder>Ross Burton</holder>
    </copyright>
    <legalnotice>
      <remark>TODO: insert Open Content License or similar here</remark>
    </legalnotice>
  </bookinfo>

  <toc>
    <title>Table of Contents</title>
  </toc>

  <chapter>
    <title>Introduction</title>
    <para>
      This document describes the policy requirements for the
      packaging of <application>GNOME</application> programs.
    </para>
    <para>
      This document is currently a draft, as it evolves it should
      become more organised.
    </para>
    <para>
      This document only mentions packaging guidelines appropriate for
      GNOME packages. The Debian Policy still applies to all packages.
    </para>
  </chapter>

  <chapter>
    <title>General Packaging Guidelines</title>
    <sect1>
      <title>Package Naming</title>
      <para>
        Programs that the end user can actually run (such as
        <application>File Roller</application>) should be packaged as
        the name of the program. Do not suffix the package with a
        <literal>2</literal> to represent the GNOME 2 package; if
        upstream is maintaining both GNOME 1 and GNOME 2 releases,
        then name the GNOME 1 package <literal>foo-gnome1</literal>
        instead.
      </para>
      <para>
        If the binaries accept the standard GTK+/GNOME options, in the
        manual pages refer to the GNOME options manual
        page. <remark>TODO: what was the status with this? Is it
        packaged anywhere?</remark>
      </para>
    </sect1>
    <sect1>
      <title>Package Section</title>
      <para>
        GNOME applications (not libraries) should be in the
        <literal>gnome</literal> section unless they are used by
        multiple environments (such as KDE).
      </para>
    </sect1>
    <sect1>
      <title>API Documentation</title>
      <para>
        If the upstream tarball contains documentation for a library
        which is generated using <application>gtk-doc</application> or
        <application>doxygen</application>, it should not be
        regenerated during the Debian package build process. In the
        case of gtk-doc, this means passing the
        <literal>--disable-gtk-doc</literal> flag to
        <command>configure</command>. An exception to this rule is if
        the upstream tarball contains incomplete or old API
        documentation, or if it is not installed when
        <literal>--disable-gtk-doc</literal> is used.
      </para>
      <para>
        API documentation should be included in the
        <filename>-dev</filename> package if relatively small,
        otherwise in a separate <filename>-doc</filename> package.
        API docs should be available in
        <filename>/usr/share/doc/[package]/</filename>, normally in a
        directory named after the type of file (such as
        <filename>html/</filename>). This is so that multiple formats
        can be packaged (PDF for example).
      </para>
      <para>
        If gtk-doc is used to generate the API documentation, the
        documentation should be installed in the default location,
        <filename>/usr/share/gtk-doc/html/[package]</filename>, with a
        symbolic link in
        <filename>/usr/share/doc/[package]/html</filename>.
        <footnote>
          <para>
            Alternatively, the documentation can be installed into
            <filename>/usr/share/doc/...</filename> and a symlink to
            it created in the correct place in
            <filename>/usr/share/gtk-doc/html</filename>.
          </para>
        </footnote> This ensures that gtk-doc and other tools which
        use the gtk-doc metadata (such as
        <application>DevHelp</application>) can find the
        documentation.
      </para>
      <para>
        <remark>TODO: There is the issue of rebuilding documentation
        if upstream didn't generate it with cross-references. Ideally
        all types will be cross-referenced, down to gint.</remark>
      </para>
    </sect1>
    <sect1>
      <title>Use of GConf</title>
      <para>
        Many GNOME applications use <application>GConf</application>
        for preferences, and they should all provide schemas for the
        keys they set. These must be installed specially.  Before
        running <command>make install</command>, the variable
        <varname>GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL</varname> must
        be set to 1. This will ensure that the schemas are not
        installed on your machine in the package build tree. Then, in
        the <filename>postinst</filename> maintainer script, register
        the schemas manually with the following code snippet.
      </para>
      <programlisting>
if [ "$1" = "configure" ]; then
    SCHEMA_FILES="foo.schemas bar.schemas"
    for SCHEMA in $SCHEMA_FILES; do
        if [ -e /etc/gconf/schemas/$SCHEMA ]; then
            HOME=/root GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
            gconftool-2 \
            --makefile-install-rule /etc/gconf/schemas/$SCHEMA > /dev/null
        fi
    done
fi
      </programlisting>
      <para>
        Change the value of <varname>SCHEMA_FILES</varname> to list
        all of the schema files, in
        <filename>/etc/gconf/schemas</filename>.
      </para>
      <para>
        When <application>gconftool</application> supports it, the
        <filename>prerm</filename> script must also un-apply the
        schemas when the package is being purged. This is currently
        implemented only in the development
        <application>gconftool</application> at present.
      </para>
      <para>
        A DebHelper script, <application>dh_gconf</application>, is
        being written.  This will mean that you do not have to
        manually create the scripts, but simply call
        <command>dh_gconf</command> in the <varname>binary-*</varname>
        target. It will find any GConf schemas which need to be
        installed, and register them correctly.
      </para>
      <para>
        <remark>GConf schemas are installed into
          <filename>/etc/gconf/schemas</filename>, but they are not
          configuration files. Havoc has said that this was a mistake,
          and they should be in <filename>/usr/share</filename>. I
          really want to force a relocation of GConf schemas into
          <filename>/usr/share/gconf/schemas</filename>. Havoc has
          said that this may expose lots of bugs in programs install
          rules. I don't believe it will be that many. I think that if
          we put our collective feet down and move schemas to
          <filename>/usr/share</filename> where they belong, we can
          fix any bugs we find and then upstream GConf can be
          corrected.</remark>
      </para>
    </sect1>
    <sect1>
      <title>Use of Scrollkeeper</title>
      <para>
        If user documentation exists, and an OMF file is provided, the
        package must depend on <varname>scrollkeeper (>=
        0.3.8)</varname>, and update the ScrollKeeper database in the
        <filename>postinst</filename> and <filename>postrm</filename>
        scripts. A DebHelper script to do this is currently being
        written, but for now use the following snippets.
      </para>
      <para>
        postinst:
        <programlisting>
if [ "$1" = "configure" ]; then
    scrollkeeper-update -q
fi
        </programlisting>
        postrm:
        <programlisting>
if [ "$1" = "remove" ]; then
    scrollkeeper-update -q
fi
        </programlisting>
      </para>
      <para>
        Currently, Debian has no XML catalogue of available
        DTDs. <remark>However, it looks like it is coming at
        last.</remark> This means that when Scrollkeeper registers the
        documentation, it will try and connect to the Internet to
        download a DTD. As a temporary measure, you must replace the
        URL with an absolute local path<footnote><simpara>For the
        details of this, see bug #155129.</simpara> </footnote>.
      </para>
      <para>
        An example snippet of code to remove the remote URLs:
      </para>
      <programlisting>
find -name '*.xml' -exec perl -i -pe 's,http://www.oasis-open.org/docbook/xml/([^/]+)/docbookx.dtd,/usr/share/sgml/docbook/dtd/xml/\1/docbookx.dtd,' {} \;
find -name '*.omf' -exec perl -i -pe 's,http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd,/usr/share/xml/scrollkeeper/dtds/scrollkeeper-omf.dtd,' {} \;
      </programlisting>
      <para>
        Run these lines before running <command>make</command>, and
        the reverse transformation in the <varname>clean</varname>
        target (to avoid redundant lines in the diff).
      </para>
    </sect1>
  </chapter>

  <chapter>
    <title>Specific Packaging Guidelines</title>
    <sect1>
      <title>Panel Applets</title>
      <para>
        <remark>TODO: Panel applets -- "gnome-applet-foo" or
        "foo-applet" or "gnome-foo-applet"?</remark>
      </para>
      <para>
        Panel applets must be installed into
        <filename>/usr/lib/gnome-panel</filename> as they are never
          directly executabled by the user. This applies to both
        shared library and executable panel applets. <remark>TODO: Or should
          they go into
          <filename>/usr/share/gnome-applets</filename>?</remark>
      </para>
    </sect1>
    <sect1>
      <title>Nautilus View</title>
      <para>
        Nautilus views should be packaged as
        <filename>nautilus-[viewname]</filename>. As they are not
        executable by the user, the binaries must be installed into
        <filename>/usr/lib/nautilus/</filename>, not
        <filename>/usr/bin/</filename> or
        <filename>/usr/lib/</filename>. Note that often upstream
        <filename>.server</filename> files hard-code paths and this
        will require editing of the <filename>.server</filename>
        files.
      </para>
    </sect1>
    <sect1>
      <title>Themes and Theme Engines</title>
      <para>
        GTK+ 1.x engines must be named
        <filename>gtk-engines-[name]</filename>, and GTK+ 2.x engines
        must named <filename>gtk2-engines-[name]</filename>.  All
        engines should be in the <literal>gnome</literal> section.
      </para>
      <para>
        Unless there are special requirements, GTK+ themes should not
        specify a font. This is because a font specified in a theme
        can not be changed by the user trivially.
      </para>
      <para>
        <remark>TODO: How do we package pure gtkrc themes which use
        engines (such as GitM, which uses mist)?  Should engine
        packages include a set of decent themes for this engine, even
        if they were not written by the same author?</remark>
      </para>
      <para>
        <remark>TODO: Icon themes?  Metacity themes?</remark>
      </para>
    </sect1>
    <sect1>
      <title>GnomeVFS Methods</title>
      <para>
        It is recommended that any GnomeVFS methods included with a
        program should be packaged separately, with just the necessary
        shared library and the GnomeVFS module configuration file.  If
        a package provides just a single method, it should be named
        like <filename>gnomevfs-method-[prefix]</filename>, where
        <varname>[prefix]</varname> is the URI prefix that the method
        provides.
      </para>
      <para>
        If a single upstream source package provides multiple methods,
        it may either be packaged as
        <filename>gnomevfs-methods-[name]</filename>, where
        <varname>[name]</varname> is the name of the upstream source,
        or it may be split into multiple individual packages as above.
      </para>
    </sect1>
  </chapter>

  <chapter>
    <title>License</title>
    <para><remark>TODO: insert OCL</remark></para>
  </chapter>
</book>
