Debian packaging workflow

Published by mithat on Thursday, 25 June 2009

The following is a summary of the current SkinnyDebbie packaging workflow for making Debian packages.

File Structure

Create the following file structure for each package you want to create.

{package-root}

{package-root} is {someplace-convenient}/{package-name}, where {package-name} is the name of the package without version or platform info. For example, if {package-name} is foobar, {package-root} might be:

/home/mithat/package-dev/foobar

The {package-root} structure

+ {package-root}
    + debian
        + DEBIAN
            control
            postinst
            prerm
            [other-control-files]
        + {mirror-of-file-system-with-binaries-etc}
    + docs
        + man
            + man[1-9] ...
                {package-name}.[1-9]
        changelog.Debian
        copyright
    build.sh

Discussion

{package-root}/debian

This is just a wrapper for the whole deal. This structure (with DEBIAN and {mirror-of-file-system-with-binaries-etc} directories inside) is an attempt to be consistent with the regular Debian build process (which assumes separate source and binary files).

{package-root}/docs

Contains documentation in a centralized location to make it easier to maintain. The stuff here is copied into {package-root}/debian as needed by build.sh (see below).

{package-root}/docs/man

Man pages for the package go here in plaintext. /docs/man/man1 has {whatever}.1 man files, /docs/man/man8 has {whatever}.8 man files, etc. Man files are required by Debian policy for anything in /usr/bin or /usr/sbin.

A decent summary of what’s needed to make man pages can be found here.

{package-root}/docs/changelog.Debian

Changelog for the release in plaintext, formatted according to Debian policy requirements. According to my reading of the official Debian policy, this file should actually be called “changelog” since the upstream and package maintainers are the same and therefore share a changelog, but I can’t get a clean lintian check whithout naming the the version that appears in the final package “changelog.Debian.gz”. The changelog file is required by Debian policy.

{package-root}/docs/copyright

Copyright info in plaintext, formatted according to Debian policy requirements. The copyright file is required by Debian policy.

{package-root}/build.sh

The big fun. The file build.sh does the actual building of the package. It will copy over the documentation files (above) into the right places in the right form in /debian/DEBIAN/{mirror-of-file-system-with-binaries-etc} and then make the package. Note that by using fakeroot the package files can be owned and the build executed by user. In other words, sudo is not required.

A copy of build.sh used to make the skinny-xdm-beautify can be had here. In its present form, you will have to hand-tweak the PACKAGENAME variable as well as the names and places of the manpages.

The process

1 ) Build the package:

cd {package-root}
./build.sh

2 ) Test the package:

lintian {name-of-package-file}

Example:

lintian foobar_0.9.0-2_all.deb

3 ) Copy the new package to {local-repository}/binary and delete the old version.

4 ) Recreate the Packages.gz file for the repository. Example:

cd {local-repository}
dpkg-scanpackages binary /dev/null | gzip -9c >> binary/Packages.gz

5 ) Upload/sync changes to the online repository. Example:

<TBD>