This tutorial may be used under the terms the GNU General Public License version 2 or higher.

The debmake command is the helper script for the Debian packaging.

Caution
The debmake command only provides good template files. These template files must be manually adjusted to their perfection to comply with the strict quality requirements of the Debian archive.

This simple tutorial should be enough for you to get started with the debmake command, if you already know the Debian packaging.

There is also the debmake manpage which explains all the command options. It is included here in the appendix.

If you are new to the Debian packaging, do not worry about the details and just get the big picture instead. Please read the more detailed guide such as Debian Maintainers' Guide with debmake.

Feature overview

The debmake command is intended to replace functions offered historically by deb-make
[This new debmake package starts its version from 4.0 to avoid version overlaps with its predecessor provided the deb-make command.]
and dh_make commands.

Its features include:

  • use of dh syntax under the new debhelper (> 9.0) package

    • extensive check of copyright for DEP-5 (debian/copyright)

    • substvar supports for binary packages (debian/control)

    • support of compiler hardening options (debian/rules)

  • keep pre-existing Debian package configuration files untouched

    • automatic generation of the missing template packaging files

    • easy verification of the debian/copyright file against the current source. (-k option)

  • easy packaging command line UI supporting

    • non-stop execution with clean results

    • direct operation on the tarball archive

    • direct operation on the source tree from VCS

    • direct generation of the binary package from the python module

    • the multiarch Debian package

    • the multi binary Debian package

    • the non-native Debian packages from the VCS snapshot

    • seamless work with debuild, pdebuild, etc.

These are realized with the following approaches:

  • It doesn’t overwrite existing configuration files in the debian/ directory.

  • It always sets most of the obvious option states and values to reasonable defaults.

    • It aims to address typical packaging situation (90% of cases) only.

    • It has the -s option to copy the package description from the upstream meta data.

  • It supports the multiarch package.

    • It always prepares to build the source for the multiarch package, unless -m option is explicitly specified.

    • It always prepares to build the non-native Debian package with the "3.0 (quilt)" format, unless -n option is explicitly specified.

  • It creates good template files such as the debian/copyright file complient to DEP-5.

    • It makes template files for the Debian packaging in the upstream source based on the type (the -b option).

    • Use bin as the fallback type for the compiled program without its own type.

    • Use script as the fallback type for the interpreted program without its own type.

  • It delegates most of the heavy lifting to its back-end packages: debhelper, dpkg-dev, devscripts, pbuilder, etc.

  • It can integrate the whole packaging process from the source archive to the binary package.

    • It has the -a option to make it work directly with the tarball.

    • It has the -t and -d options to make it work well with the snapshot source in VCS. These options also allow to make the non-native Debian package from the VCS source tree with the package-version/debian/ directory.

    • It has the -b option to make it work with various cases of Debian binary packages.

    • It has the -i option to run the debuild command as its subprocess.

Tip
Make sure to protect the arguments of the -b, -f, -l, and -w options from the shell interference by quoting them properly.
Tip
The non-native Debian package is the normal Debian package.
Note
The generation of the debian/copyright file, and the outputs from the -c and -k options involve heuristic operations on the copyright and license information. They may produce some erroneous results.

Binary package

Let’s consider a simple C source following the GNU Coding Standards and FHS, package-1.0.tar.gz.

The Debian packaging of this package-1.0.tar.gz into a single binary package can be done with the debmake command as follows.

 $ tar -xvzf package-1.0.tar.gz
 $ cd package-1.0
 $ debmake
   ... Make manual adjustments of generated configuration files
 $ debuild

If manual adjustments of generated configuration files are skipped, the generated binary package lacks meaningful package description but still functions well under the dpkg command to be used for your local deployment.

Tip
The debuild command in these examples may be substituted by the equivalent commands such as the pdebuild command.

debmake -b

The -b option of the debmake command provides intuitive and flexible methods to customize packaging parameters in the debian/control file. It sets the following stanza values.

  • Package:

  • Architecture:

  • Multi-Arch:

  • Depends:

  • Pre-Depends:

Let’s quote the pertinent part from the debmake manpage here.

-b "binarypackage[:type],…", --binaryspec "binarypackage[:type],…"

set binary package specs by the comma separated list of binarypackage:type pairs, e.g., in full form "foo:bin,foo-doc:doc,libfoo1:lib,libfoo1-dbg:dbg,libfoo-dev:dev" or in short form ",-doc,libfoo1,libfoo1-dbg, libfoo-dev".

Here, binarypackage is the binary package name; and optional type is chosen from the following type values:

  • bin: C/C++ compiled ELF binary code package (any, foreign) (default, alias: "", i.e., null-string)

  • data: Data (fonts, graphics, …) package (all, foreign) (alias: da)

  • dbg: Debug symbol package (any, same) (alias: db)

  • dev: Library development package (any, same) (alias: de)

  • doc: Documentation package (all, foreign) (alias: do)

  • lib: Library package (any, same) (alias: l)

  • perl: Perl script package (all, foreign) (alias: pl)

  • python: Python script package (all, foreign) (alias: py)

  • python3: Python3 script package (all, foreign) (alias: py3)

  • ruby: Ruby script package (all, foreign) (alias: rb)

  • script: Shell script package (all, foreign) (alias: sh)

The pair values in the parentheses, such as (any, foreign), are the Architecture and Multi-Arch stanza values set in the debian/control file.

In many cases, the debmake command makes good guesses for type from binarypackage. If type is not obvious, type is set to bin. For example, libfoo sets type to lib, and font-bar sets type to data, …

If the source tree contents do not match settings for type, debmake warns you.

Here are some typical multiarch package split scenarios for the following upstream source examples:

  • a library source libfoo-1.0.tar.gz

  • a tool source bar-1.0.tar.gz written in a compiled language

  • a tool source baz-1.0.tar.gz written in an interpreted language

binarypackage type Architecture: Multi-Arch: Package content

libfoo1

lib*

any

same

the shared library, co-installable

libfoo1-dbg

dbg*

any

same

the shared library debug symbols, co-installable

libfoo-dev

dev*

any

same

the shared library header files etc., co-installable

libfoo-tools

bin*

any

foreign

the run-time support programs, not co-installable

libfoo-doc

doc*

all

foreign

the shared library documentation files

bar

bin*

any

foreign

the compiled program files, not co-installable

bar-doc

doc*

all

foreign

the documentation files for the program

baz

script

all

foreign

the interpreted program files

For the cases marked with * in the above table, the type values are guessed right from the package names.

The default type is the bin type which means the compiled ELF binary executables. This is why the example in [simple] does not specify -b option.

For programs written in other compiled languages, you may need to add its run-time library package dependency to the resulting binary package by adjusting the Depends: stanza of the debian/control file.

The development package for the shared library should depend on it and should contain a version numberless symlink to it. E.g.: /usr/lib/x86_64-linux-gnu/libfoo.solibfoo.so.1

Note
If any dbg type packages are to be generated, they should be made for all bin and lib type packages.

Useful options

Shortcut options (-a, -i)

The debmake command offers 2 shortcut options.

  • -a : open the upstream tarball

  • -i : execute script to build the binary package

The example in the above [simple] can be done simply as follows.

 $ debmake -a package-1.0.tar.gz -i debuild
Tip
URL such as "http://www.example.org/DL/package-1.0.tar.gz" may be used for the -a option.
Tip
URL such as "http://arm.koji.fedoraproject.org/packages/ibus/1.5.7/3.fc21/src/ibus-1.5.7-3.fc21.src.rpm" may be used for the -a option, too.

Upstream snapshot (-d, -t)

The upstream snapshot from the upstream source tree in VCS can be made with the -d option if the upstream supports the "make dist" equivalence.

 $ cd /path/to/upstream-vcs
 $ debmake -d -i debuild

Alternatively, the same can be made with the -t option if the upstream tarball can be made with the tar command.

 $ cd /path/to/upstream-vcs
 $ debmake -p package -t -i debuild

Unless you provide the upstream version with the -u option or with the debian/changelog file, a snapshot upstream version is generated in the 0~%y%m%d%H%M format, e.g., 0~1403012359, from the UTC date and time.

If the upstream VCS is hosted in the package/ directory instead of the upstream-vcs/ directory, the "-p package" can be skipped.

If the upstream source tree in the VCS contains the debian/* files, the debmake command with either the -d option or the -t option combined with the -i option automates making of the non-native Debian packages from the VCS snapshot while using these debian/* files.

 $ cp -r /path/to/package-0~1403012359/debian/. /path/to/upstream-vcs/debian
 $ dch
   ... update debian/changelog
 $ git add -A .; git commit -m "vcs with debian/*"
 $ debmake -t -p package -i debuild

This Debian non-native binary package building scheme using the "debmake -t -i debuild" command may be considered as the quasi-native Debian package scheme since the packaging situation resembles the Debian native binary package building case using the debuild command without the upstream tarball.

Use of the non-native Debian package helps to ease communication with the downstream distros such as Ubuntu for bug fixes etc.

Python module

You can generate a functioning single binary Debian package with a reasonable package description directly from the Python module package offered as a tarball pythonmodule-1.0.tar.gz. The -b option specifying the package type python and the -s option to copy the package description from the upstream package need to be specified.

 $ debmake -s -b':python' -a pythonmodule-1.0.tar.gz -i debuild

For other interpreted languages with the -b option support, specify the pertinent type for the -b option.

For interpreted languages without the -b option support, specify the script type instead and add the interpreter package as the dependency of the resulting binary package by adjusting the debian/control file.

debmake -cc

The the debmake command with the -cc option can make a summary of the copyright and license for the entire source tree to the standard output.

 $ tar -xvzf package-1.0.tar.gz
 $ cd package-1.0
 $ debmake -cc | less

With -c, this provides shorter report.

debmake -k

When updating a package for the new upstream release, the debmake command can verify the content of the existing debian/copyright file against the copyright and license situation of the entire updated source tree.

 $ cd package-vcs
 $ gbp import-orig --uscan --pristine-tar
 ... update source with the new upstream release
 $ debmake -k | less

The "debmake -k" command parses the debian/copyright file from the top to the bottom and compare the license of all the non-binary files in the current package with the license described in the last matching file pattern entry of the debian/copyright file.

When editing the auto-generated debian/copyright file, please make sure to keep the generic file patterns at the top of the list.

Tip
For all new upstream releases, run the "debmake -k" command to ensure that the debian/copyright file is current.

debmake -j

The generation of the functioning multi binary package always requires extra manual works than that of the functioning single binary package. The test build of the source package is essential part of it.

For example, let’s package the same package-1.0.tar.gz (see [simple]) into a multi binary package. At the line invoking the debmake command, let’s invoke it with the -j option instead for the test building and the report generation.

 $ debmake -j
Note
The -j option for debmake invokes dpkg-depcheck(1) to run debian/rules under strace(1) to obtain library dependencies. Unfortunately, this is very slow. If you know the library package dependencies from other sources such as the SPEC file in the source, you may just run "debmake …" without -j and "debian/rules install" to check the install paths of the generated files.
  • Check the last lines of package.build-dep.log to judge build dependencies for Build-Depends. (You do not need to list packages used by debhelper, perl, or fakeroot explicitly in Build-Depends. This technique is useful for the generation of the single binary package, too.)

  • Check the contents of package.install.log to identify the install paths for files to decide how you split them into multiple packages.

 $ rm -rf package-1.0
 $ tar -xvzf package-1.0.tar.gz
 $ cd package-1.0
 $ debmake -b"package1:type1, ..."
  • Update debian/control and debian/binarypackage.install files using the above information.

  • Update other debian/* files as needed.

 $ debuild
  • Each binarypackage_version-revision_arch.deb has files specified by the debian/binarypackage.install file.

Tip
The binary package name starting with a "-" (hyphen) is treated as the abbreviated name and the real binary package name is generated by attaching it to the source package name.

debmake -x

The amount of template files generated by the debmake command depends on the -x[01234] option.

Note
None of the existing configuration files are modified by the debmake command.

debmake(1) manpage

NAME

debmake - program to make the Debian source package

SYNOPSIS

debmake [-h] [-c | -k] [-n | -a package-version.orig.tar.gz | -d | -t ] [-p package] [-u version] [-r revision] [-z extension] [-b "binarypackage, …]" [-e foo@example.org] [-f "firstname lastname"] [-i "buildtool" | -j] [-l license_file] [-m] [-o file] [-q] [-s] [-v] [-w "addon, …"] [-x [01234]] [-y] [-Q]

DESCRIPTION

debmake helps to build the Debian package from the upstream source. Normally, this is done as follows:

  • The upstream tarball is downloaded as the package-version.tar.gz file.

  • It is untared to create many files under the package-version/ directory.

  • debmake is invoked in the package-version/ directory possibly without any arguments.

  • Files in the package-version/debian/ directory are manually adjusted.

  • dpkg-buildpackage (usually from its wrapper debuild or pdebuild) is invoked in the package-version/ directory to make debian packages.

Make sure to protect the arguments of the -b, -f, -l, and -w options from the shell interference by quoting them properly.

optional arguments:

-h, --help

show this help message and exit.

-c, --copyright

scan source for copyright+license text and exit.

  • -c: sinple output style

  • -cc: normal output style (similar to the debian/copyright file)

  • -ccc: debug output style

-k, --kludge

compare the debian/copyright file with the source and exit.

The debian/copyright file must be organized to list the generic file patterns before the specific exceptions.

  • -k: basic output style

  • -kk: verbose output style

-n, --native

make a native Debian source package without .orig.tar.gz. This makes the "3.0 (native)" format package.

If you are thinking to package a Debian specific source tree with debian/* in it into a native Debian package, please think otherwise. You can use "debmake -d -i debuild" or "debmake -t -i debuild" to make the "3.0 (quilt)" format non-native Debian package. The only difference is that the debian/changelog file must use the non-native version scheme: version-revision. The non-native package is more friendly to the downstream distributions.

-a package-version.tar.gz, --archive package-version.tar.gz

use the upstream source tarball directly. (-p, -u, -z: overridden)

The upstream tarball may be specified as package_version.orig.tar.gz and tar.gz for all cases may be tar.bz2, or tar.xz.

If the specified upstream tarball name contains uppercase letters, the Debian package name is generated by converting them to lowercase letters.

If the specified argument is the URL (http://, https://, or ftp://) to the upstream tarball, the upstream tarball is downloaded from the URL using wget or curl.

-d, --dist

run "make dist" equivalent first to generate upstream tarball and use it.

"debmake -d" is designed to run in the package/ directory hosting the upstream VCS with the build system supporting "make dist" equivalents. (automake/autoconf, Python distutils, …)

-t, --tar

run "tar" to generate upstream tarball and use it

"debmake -t" is designed to run in the package/ directory hosting the upstream VCS. Unless you provide the upstream version with the -u option or with the debian/changelog file, a snapshot upstream version is generated in the 0~%y%m%d%H%M format, e.g., 0~1403012359, from the UTC date and time. The generated tarball excludes the debian/ directory found in the upstream VCS. (It also excludes typical VCS directories: .git/ .hg/ .svn/ .CVS/)

-p package, --package package

set the Debian package name.

-u version, --upstreamversion version

set the upstream package version.

-r revision, --revision revision

set the Debian package revision.

-z extension, --targz extension

set the tarball type, extension=(tar.gz|tar.bz2|tar.xz) (alias: z, b, x)

-b "binarypackage[:type],…", --binaryspec "binarypackage[:type],…"

set binary package specs by the comma separated list of binarypackage:type pairs, e.g., in full form "foo:bin,foo-doc:doc,libfoo1:lib,libfoo1-dbg:dbg,libfoo-dev:dev" or in short form ",-doc,libfoo1,libfoo1-dbg, libfoo-dev".

Here, binarypackage is the binary package name; and optional type is chosen from the following type values:

  • bin: C/C++ compiled ELF binary code package (any, foreign) (default, alias: "", i.e., null-string)

  • data: Data (fonts, graphics, …) package (all, foreign) (alias: da)

  • dbg: Debug symbol package (any, same) (alias: db)

  • dev: Library development package (any, same) (alias: de)

  • doc: Documentation package (all, foreign) (alias: do)

  • lib: Library package (any, same) (alias: l)

  • perl: Perl script package (all, foreign) (alias: pl)

  • python: Python script package (all, foreign) (alias: py)

  • python3: Python3 script package (all, foreign) (alias: py3)

  • ruby: Ruby script package (all, foreign) (alias: rb)

  • script: Shell script package (all, foreign) (alias: sh)

The pair values in the parentheses, such as (any, foreign), are the Architecture and Multi-Arch stanza values set in the debian/control file.

In many cases, the debmake command makes good guesses for type from binarypackage. If type is not obvious, type is set to bin. For example, libfoo sets type to lib, and font-bar sets type to data, …

If the source tree contents do not match settings for type, debmake warns you.

-e foo@example.org, --email foo@example.org

set e-mail address.

The default is taken from the value of the environment variable $DEBEMAIL.

-f "firstname lastname", --fullname "firstname lastname"

set the fullname.

The default is taken from the value of the environment variable $DEBFULLNAME.

-i "buildtool", --invoke "buildtool"

invoke "buildtool" at the end of execution. "buildtool" may be "dpkg-buildpackage", "debuild", "pdebuild", "pdebuild --pbuilder cowbuilder", etc..

The default is not to execute any program.

-j, --judge

run dpkg-depcheck to judge build dependencies and identify file paths. Log files are in the parent directory.

  • package.build-dep.log: Log file for dpkg-depcheck.

  • package.install.log: Log file recording files in the debian/tmp directory.

-l "license_file,…", --license "license_file,…"

add formatted license text to the end of the debian/copyright file holding license scan results

The default is add COPYING and LICENSE and license_file needs to list only the additional file names all separated by ",".

-m, --monoarch

force packages to be non-multiarch.

-o file, --option file

read optional parameters from file. (This is not for everyday use.)

The file is sourced as the Python3 code at the end of para.py. For example, the package description can be specified by the following file.

para['desc'] = 'program short description'
para['desc_long'] = '''\
 program long description which you wish to include.
 .
 Empty line is space + .
 You keep going on ...
'''
-q, --quitearly

quit early before creating files in the debian/ directory.

-s, --spec

use upstream spec (setup.py for Python, etc.) for the package description.

-v, --version

show version information.

-w "addon,…", --with "addon,…"

add extra arguments to the --with option of the dh(1) command as addon in debian/rules.

The addon values are listed all separated by ",", e.g., -w "python2,autoreconf".

For Autotools based packages, setting autoreconf as addon forces to run "autoreconf -i -v -f" for every package building. Otherwise, autotools-dev as addon is used as default.

For Autotools based packages, if they install Python programs, python2 as addon is needed for packages with compat < 9 since this is non-obvious. But for setup.py based packages, python2 as addon is not needed since this is obvious and it is automatically set for the dh(1) command by the debmake command when it is required.

-x n, --extra n

generate extra configuration files as templates.

The number n changes which configuration templates are generated.

  • -x0: bare minimum configuration files. (default if these files exist already)

  • -x1: ,, + desirable configuration files. (default for new packages)

  • -x2: ,, + interesting configuration files. (recommended for experts, multi binary aware)

  • -x3: ,, + unusual configuration template files with the extra .ex suffix to ease their removal. (recommended for new users) To use these as configuration files, rename their file names into ones without the .ex suffix.

  • -x4: ,, + copyright file examples.

-y, --yes

force "yes" for all prompts. (without option: "ask [Y/n]"; doubled option: force "no")

-Q, --quiet

quiet tutorial comment lines marked with ### in template files

EXAMPLES

For a well behaving source, you can build a good-for-local-use installable single Debian binary package easily with one command. Test install of such a package generated in this way offers a good alternative to traditional "make install" to the /usr/local directory since the Debian package can be removed cleanly by the "dpkg -P " command. Here are some examples of how to build such test packages. (These should work in most cases. If the -d does not work, try -t instead.)

For a typical C program source tree packaged with autoconf/automake:

  • debmake -d -i debuild

For a typical python module source tree:

  • debmake -s -d -b":python" -i debuild

For a typical python module in the package-version.tar.gz archive:

  • debmake -s -a package-version.tar.gz -b":python" -i debuild

For a typical perl module in the Package-version.tar.gz archive:

  • debmake -a Package-version.tar.gz -b":perl" -i debuild

HELPER PACKAGES

Packaging may require installation of some additional specialty helper packages.

  • Python3 program may require the dh-python package.

  • Autotools (Autoconf + Automake) build system may require autotools-dev or dh-autoreconf package.

  • Ruby program may require the gem2deb package.

  • Java program may require the javahelper package.

  • Gnome programs may require the gobject-introspection package.

  • etc.

CAVEAT

debmake is meant to provide template files for the package maintainer to work on. Comment lines started by ### are the tutorial text. You must remove or edit such comment lines before uploading to the Debian archive.

There are some limitations for what characters may be used as a part of the Debian package. The most notable limitation is the prohibition of uppercase letters in the package name. Here is the summary in the regular expression.

  • Upstream package name (-p): [-+.a-z0-9]{2,}

  • Binary package name (-b): [-+.a-z0-9]{2,}

  • Upstream version (-u): [0-9][-+.:~a-z0-9A-Z]*

  • Debian revision (-r): [0-9][+.~a-z0-9A-Z]*

See the exact definition in Chapter 5 - Control files and their fields of the “Debian Policy Manual”.

DEBUG

The character set in the environment variable $DEBUG determines the logging output level.

  • p: list all global parameters

  • d: list parsed parameters for all binary packages

  • f: input filename for the copyright scan

  • y: year/name split of copyright line

  • s: line scanner for format_state

  • b: content_state scan loop: begin-loop

  • m: content_state scan loop: after regex match

  • e: content_state scan loop: end-loop

  • c: print copyright section text

  • l: print license section text

  • a: print author/translator section text

  • k: sort key for debian/copyright stanza

  • n: scan result of debian/copyright (debmake -k)

Use this as:

 $ DEBUG=pdfbmeclak debmake ...

AUTHOR

Copyright © 2014 Osamu Aoki <osamu@debian.org>

LICENSE

MIT License

SEE ALSO

The debamake package provides following HTML documents:

Also, please read the original Debian New Maintainers' Guide provided by the the maint-guide package.

See also dpkg-source(1), deb-control(5), debhelper(7), dh(1), dpkg-buildpackage(1), debuild(1), quilt(1), dpkg-depcheck(1), pdebuild(1), pbuilder(8), cowbuilder(8), gbp-buildpackage(1), gbp-pq(1), and git-pbuilder(1) manpages.