debmake-doc.en
debmake-doc.en
Osamu Aoki
October 1, 2024
Guide for Debian Maintainers
by Osamu Aoki
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the ”Software”), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED ”AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM-
PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This guide was made using the following previous documents as its reference:
• “Making a Debian Package (AKA the Debmake Manual)”, copyright © 1997 Jaldhar Vyas.
• “The New-Maintainer’s Debian Packaging Howto”, copyright © 1997 Will Lowe.
• “Debian New Maintainers’ Guide”, copyright © 1998-2002 Josip Rodin, 2005-2017 Osamu Aoki, 2010
Craig Small, and 2010 Raphaël Hertzog.
i
Contents
1 Preface 1
2 Overview 3
3 Prerequisites 5
3.1 People around Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 How to contribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Social dynamics of Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4 Technical reminders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.5 Debian documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.6 Help resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.7 Archive situation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.8 Contribution approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.9 Novice contributor and maintainer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 Tool Setups 12
4.1 Email setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 mc setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 git setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.4 quilt setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.5 devscripts setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.6 sbuild setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.7 Persistent chroot setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.8 gbp setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.9 HTTP proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.10 Private Debian repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.11 Virtual machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.12 Local network with virtual machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 Simple packaging 18
5.1 Packaging tarball . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2 Big picture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3 What is debmake? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.4 What is debuild? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.5 Step 1: Get the upstream source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.6 Step 2: Generate template files with debmake . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.7 Step 3: Modification to the template files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.8 Step 4: Building package with debuild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.9 Step 3 (alternatives): Modification to the upstream source . . . . . . . . . . . . . . . . . . . . . . 30
5.10 Patch by “diff -u” approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.11 Patch by dquilt approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.12 Patch by “dpkg-source --auto-commit” approach . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ii
CONTENTS
8 More on packaging 53
8.1 Package customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
8.2 Customized debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
8.3 Variables for debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
8.4 New upstream release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
8.5 Manage patch queue with dquilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8.6 Build commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8.7 Note on sbuild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8.8 Special build cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.9 Upload orig.tar.gz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.10 Skipped uploads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.11 Bug reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
9 Advanced packaging 58
9.1 Historical perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.2 Current trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.3 Note on build system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.4 Continuous integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.5 Bootstrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.6 Compiler hardening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
9.7 Reproducible build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
9.8 Substvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
9.9 Library package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
9.10 Multiarch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
9.11 Split of a Debian binary package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
9.12 Package split scenario and examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
9.13 Multiarch library path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
9.14 Multiarch header file path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
9.15 Multiarch *.pc file path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
9.16 Library symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
9.17 Library package name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9.18 Library transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.19 binNMU safe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.20 Debugging information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.21 -dbgsym package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9.22 debconf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
iii
CONTENTS
11 Tips 75
11.1 Build under UTF-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
11.2 UTF-8 conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
11.3 Hints for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
12 Tool usages 77
12.1 debdiff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
12.2 dget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
12.3 mk-origtargz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.4 origtargz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.5 git deborig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.6 dpkg-source -b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.7 dpkg-source -x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.8 debc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.9 piuparts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
12.10bts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13 More Examples 80
13.1 Cherry-pick templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.2 No Makefile (shell, CLI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.3 Makefile (shell, CLI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.4 pyproject.toml (Python3, CLI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.5 Makefile (shell, GUI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.6 pyproject.toml (Python3, GUI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
13.7 Makefile (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
13.8 Makefile.in + configure (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
13.9 Autotools (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
13.10CMake (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.11Autotools (multi-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.12CMake (multi-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
13.13Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
13.14Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
iv
CONTENTS
v
Abstract
This “Guide for Debian Maintainers” (2024-10-01) tutorial guide describes the building of the Debian package
to ordinary Debian users and prospective developers using the debmake command.
This guide focuses on the modern packaging style and comes with many simple examples.
• POSIX shell script packaging
• Python3 script packaging
• C with Makefile/Autotools/CMake
• multiple binary packages with shared library etc.
This “Guide for Debian Maintainers” can be considered as the successor to the “Debian New Maintainers’
Guide”.
Chapter 1
Preface
If you are a somewhat experienced Debian user 1, you may have encountered following situations:
• You wish to install a certain software package not yet found in the Debian archive.
• You wish to update a Debian package with the newer upstream release.
• You wish to fix bugs of a Debian package with some patches.
If you wanted to create a Debian package to fulfill these wishes and to share your work with the community,
you are the target audience of this guide as a prospective Debian maintainer. 2 Welcome to the Debian community.
Debian has many social and technical rules and conventions to follow since it is a large volunteer organization
with history. Debian also has developed a huge array of packaging tools and archive maintenance tools to build
consistent sets of binary packages addressing many technical objectives:
• packages build across many architectures (“Section 8.3”)
These make it somewhat overwhelming for many new prospective Debian maintainers to get involved with
Debian. This guide tries to provide entry points for them to get started. It describes the following:
• What you should know before getting involved with Debian as a prospective maintainer.
• What it looks like to make a simple Debian package.
1
CHAPTER 1. PREFACE
The author felt limitations of updating the original “New Maintainers’ Guide” with the dh-make package and
decided to create an alternative tool and its matching document to address modern requirements such as multi-arch.
The result was the debmake package version: 4.0 in 2013. The current debmake is version: 4.5.0. It comes with
this updated “Guide for Debian Maintainers” in the debmake-doc (version: 1.20-1) package. (In 2016, dh-make
was ported from perl to python with updated features.)
Many chores and tips have been integrated into the debmake command allowing this guide to be terse. This
guide also offers many packaging examples for you to get started.
Caution
It takes many hours to properly create and maintain Debian packages. The De-
bian maintainer must be both technically competent and diligent to take up
this challenge.
Some important topics are explained in detail. Some of them may look irrelevant to you. Please be patient.
Some corner cases are skipped. Some topics are only covered by the external pointers. These are intentional choices
to keep this guide simple and maintainable.
2
Chapter 2
Overview
The Debian packaging of the package-1.0.tar.gz, containing a simple C source following the “GNU Coding Stan-
dards” and “FHS”, 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 mean-
ingful package description but still functions well under the dpkg command to be used for your local deployment.
Caution
The debmake command only provides decent template files. These template
files must be manually adjusted to their perfection to comply with the strict qual-
ity requirements of the Debian archive, if the generated package is intended for
general consumption.
If you are new to Debian packaging, do not worry about the details and just get the big picture instead.
If you have been exposed to Debian packaging, this looks vgry much like the dh_make command. This is
because the debmake command is intended to replace functions offered historically by the dh_make command. 1
The debmake command is designed with the following features:
• modern packaging style
– debian/copyright: “DEP-5” compliant
– debian/control: substvar support, multiarch support, multi binary packages, …
– debian/rules: dh syntax, compiler hardening options, …
• flexibility
– many options (see “Section 15.2”, “Chapter 14”, and “Chapter 15”)
• sane default actions
– execute non-stop with clean results
– generate the multiarch package, unless the -m option is explicitly specified.
– generate the non-native Debian package with the Debian source format “3.0 (quilt)”, unless the -n
option is explicitly specified.
• extra utility
– verification of the debian/copyright file against the current source (see “Section 15.6”)
1The deb-make command was popular before the dh_make command. The current debmake package starts its version from 4.0 to avoid
version overlaps with the obsolete debmake package, which provided the deb-make command.
3
CHAPTER 2. OVERVIEW
The debmake command delegates most of the heavy lifting to its back-end packages: debhelper, dpkg-dev,
devscripts, sbuild, schroot, etc.
Tip
Make sure to protect the arguments of the -b, -f, -l, and -w options from shell
interference by quoting them properly.
Tip
Tip
The detailed log of all the package build examples in this document can be ob-
tained by following the instructions in “Section 13.14”.
Note
The generation of the debian/copyright file, and the outputs from the -c (see
“Section 15.3”) and -k (see “Section 15.6”) options involve heuristic operations
on the copyright and license information. They may produce some erroneous
results.
4
Chapter 3
Prerequisites
Here are the prerequisites which you need to understand before you to get involved with Debian.
• sponsor: a person who helps maintainers to upload packages to the official Debian package archive (after
checking their contents).
• mentor: a person who helps novice maintainers with packaging etc.
• Debian Developer (DD): a member of the Debian project with full upload rights to the official Debian
package archive.
• Debian Maintainer (DM): a person with limited upload rights to the official Debian package archive.
Please note that you can’t become an official Debian Developer (DD) overnight, because it takes more than
technical skill. Please do not be discouraged by this. If it is useful to others, you can still upload your package
either as a maintainer through a sponsor or as a Debian Maintainer.
Please note that you do not need to create any new packages to become an official Debian Developer. Con-
tributing to the existing packages can provide a path to becoming an official Debian Developer too. There are many
packages waiting for good maintainers (see “” ̀Section 3.8” ̀”).
5
CHAPTER 3. PREREQUISITES 3.3. SOCIAL DYNAMICS OF DEBIAN
Note
Debugging of software tends to consume more time than writing the initial working
software.
It is unwise to run your base system under the unstable suite even for the development system.
• Creation of binary deb packages and their verification should use minimal unstable chroot described in
“Section 4.6”.
• Basic interactive package development activities should use unstable chroot described in “Section 4.7”.
1The overwhelming number of Debian maintainers use git over other VCS systems such as hg, bzr, etc.
6
CHAPTER 3. PREREQUISITES 3.5. DEBIAN DOCUMENTATION
Note
All these documents are published to https://www.debian.org using the unstable suite versions of corresponding
Debian packages. If you wish to have local accesses to all these documents from your base system, please consider
to use techniques such as “apt-pinning” and “chroot”.
If this guide contradicts the official Debian documentation, the official Debian documentation is correct. Please
file a bug report on the debmake-doc package using the reportbug command.
Here are alternative tutorial documents, which you may read along with this guide:
– http://packaging.ubuntu.com/html/
• “Debian New Maintainers’ Guide” (predecessor of this tutorial, deprecated)
– https://www.debian.org/doc/devel-manuals#maint-guide
– https://packages.qa.debian.org/m/maint-guide.html
Tip
When reading these, you may consider using the debmake command in place
of the dh_make command.
7
CHAPTER 3. PREREQUISITES 3.6. HELP RESOURCES
Caution
Debian development is a moving target. Some information found on the web may
be outdated, incorrect, and non-applicable. Please use them carefully.
Thus, contributions to packages already in the archive are far more appreciated (and more likely to receive
sponsorship for uploading) by other maintainers.
8
CHAPTER 3. PREREQUISITES 3.8. CONTRIBUTION APPROACHES
Tip
The wnpp-alert command from the devscripts package can check for installed
packages up for adoption or orphaned.
Tip
Here:
• For exist_in_debian(), and is_team_maintained(); check:
– the aptitude command
– “Debian packages” web page
9
CHAPTER 3. PREREQUISITES 3.9. NOVICE CONTRIBUTOR AND MAINTAINER
You either need to file an ITP or adopt a package to start working on it. See the “Debian Developer’s Refer-
ence”:
• “5.1. New packages”.
• “5.9. Moving, removing, renaming, orphaning, adopting, and reintroducing packages”.
• Documentation
– Basics of text markups (XML, ReST, Wiki, …).
The novice contributor and maintainer may wonder where to start your contribution to Debian. Here are my
suggestions depending on your skills:
10
CHAPTER 3. PREREQUISITES 3.9. NOVICE CONTRIBUTOR AND MAINTAINER
– Send patches to the packages with the required and important priorities.
• Non-English skills:
– Send patches to the PO file of the Debian Installer.
– Send patches to the PO file of the packages with the required and important priorities.
• Documentation skills:
– Update contents on “Debian Wiki”.
– Send patches to the existing “Debian Documentation”.
These activities should give you good exposure to the other Debian people to establish your credibility.
The novice maintainer should avoid packaging programs with the high security exposure:
When you gain more experience in packaging, you’ll be able to package such programs.
11
Chapter 4
Tool Setups
Caution
Tool setups presented here are only meant as an example and may not be up-to-
date with the latest packages on the system. Debian development is a moving
target. Please make sure to read the pertinent documentation and update the
configuration as needed.
Note
The above is for the author of this manual. The configuration and operation ex-
amples presented in this manual use these email address and name settings.
You must use your email address and name for your system.
4.2 mc setup
The mc command offers very easy ways to manage files. It can open the binary deb file to check its content by
pressing the Enter key over the binary deb file. It uses the dpkg-deb command as its back-end. Let’s set it up to
support easy chdir as follows.
1This assumes you are using Bash as your login shell. If you use some other login shell such as Z shell, use their corresponding configuration
files instead of ~/.bashrc.
12
CHAPTER 4. TOOL SETUPS 4.3. GIT SETUP
If you are too accustomed to the CVS or Subversion commands, you may wish to set several command aliases
as follows.
$ git config --global alias.ci "commit -a"
$ git config --global alias.co checkout
Tip
It is essential to use some GUI git tools like gitk or gitg to work effectively with
the history of the git repository.
13
CHAPTER 4. TOOL SETUPS 4.5. DEVSCRIPTS SETUP
See quilt(1) and “How To Survive With Many Patches or Introduction to Quilt (quilt.html)” on how to use the
quilt command.
See “Section 5.9” for example usages.
Let’s update your group membership to include sbuild and verify it:
$ newgrp -
$ id
uid=1000(<yourname>) gid=1000(<yourname>) groups=...,132(sbuild)
Here, “reboot of system” or “kill -TERM -1” can be used instead to update your group membership 3 .
Let’s create the configuration file ~/.sbuildrc in line with recent Debian practice of “source-only-upload” as:
cat >~/.sbuildrc << 'EOF'
##############################################################################
# PACKAGE BUILD RELATED (source-only-upload as default)
##############################################################################
# -d
2Be careful since some older HOWTOs may use different chroot setups.
3Simply “logout and login under some modern GUI Desktop environment” may not update your group membership.
14
CHAPTER 4. TOOL SETUPS 4.6. SBUILD SETUP
$distribution = 'unstable';
# -A
$build_arch_all = 1;
# -s
$build_source = 1;
# --source-only-changes
$source_only_changes = 1;
# -v
$verbose = 1;
##############################################################################
# POST-BUILD RELATED (turn off functionality by setting variables to 0)
##############################################################################
$run_lintian = 1;
$lintian_opts = ['-i', '-I'];
$run_piuparts = 1;
$piuparts_opts = ['--schroot', 'unstable-amd64-sbuild'];
$run_autopkgtest = 1;
$autopkgtest_root_args = '';
$autopkgtest_opts = [ '--', 'schroot', '%r-%a-sbuild' ];
##############################################################################
# PERL MAGIC
##############################################################################
1;
EOF
Note
There are some exceptional cases such as NEW uploads, uploads with NEW
binary packages, and security uploads where you can’t do source-only-upload
but are required to upload with binary packages. The above configuration needs
to be adjusted for those exceptional cases.
Warning
The optional customization may cause negative effects. In case of doubts, dis-
able them.
Note
The parallel make may fail for some existing packages and may make the build
log difficult to read.
15
CHAPTER 4. TOOL SETUPS 4.7. PERSISTENT CHROOT SETUP
Tip
Note
For building new experimental packages or for debugging buggy packages, let’s setup dedicated persistent
chroot “source:unstable-amd64-desktop” by:
$ sudo cp -a /srv/chroot/unstable-amd64-sbuild-$suffix /srv/chroot/unstable-amd64 ←-
-desktop
$ sudo tee /etc/schroot/chroot.d/unstable-amd64-desktop << EOF
[unstable-desktop]
description=Debian sid/amd64 persistent chroot
groups=root,sbuild
root-groups=root,sbuild
profile=desktop
type=directory
directory=/srv/chroot/unstable-amd64-desktop
union-type=overlay
EOF
Here, desktop profile is used instead of sbuild profile. Please make sure to adjust /etc/schroot/desktop/fstab
to make package source accessible from inside of the chroot.
You can log into this chroot “source:unstable-amd64-desktop” by:
$ sudo schroot -c source:unstable-amd64-desktop
[DEFAULT]
# the default build command:
builder = sbuild
# use pristine-tar:
pristine-tar = True
# Use color when on a terminal, alternatives: on/true, off/false or auto
color = auto
16
CHAPTER 4. TOOL SETUPS 4.10. PRIVATE DEBIAN REPOSITORY
17
Chapter 5
Simple packaging
There is an old Latin saying: “Longum iter est per praecepta, breve et efficax per exempla” (“It’s a long way
by the rules, but short and efficient with examples”).
Debian packaging requires changing this “make install” process to install files to the target system image
location instead of the normal location under /usr/local.
Note
18
CHAPTER 5. SIMPLE PACKAGING 5.3. WHAT IS DEBMAKE?
Tip
Tip
If the upstream tarball in the .tar.xz format is available, use it instead of the one
in the .tar.gz and .tar.bz2 formats. The xz compression format offers the better
compression than the gzip and bzip2 compressions.
Note
Actual packaging activities are often performed manually without using debmake
while referencing only existing similar packages and “Debian Policy Manual”.
The debmake command is the helper script for the Debian packaging. (“Chapter 14”)
19
CHAPTER 5. SIMPLE PACKAGING 5.4. WHAT IS DEBUILD?
* If you followed “Section 4.5” to set the -us and -uc options, this step is skipped and you must run
the debsign command manually.
• The debuild command is a wrapper script of the dpkg-buildpackage command to build the Debian binary
package under the proper environment variables.
• The sbuild command is a wrapper script to build the Debian binary package under the proper chroot envi-
ronment with the proper environment variables.
Note
3 directories, 4 files
20
CHAPTER 5. SIMPLE PACKAGING 5.6. STEP 2: GENERATE TEMPLATE FILES …
$ cat debhello-0.0/src/hello.c
#include <stdio.h>
int
main()
{
printf("Hello, world!\n");
return 0;
}
Here, the Makefile supports “GNU Coding Standards” and “FHS”. Notably:
• build binaries honoring $(CPPFLAGS), $(CFLAGS), $(LDFLAGS), etc.
• install files with $(DESTDIR) defined to the target system image
• install files with $(prefix) defined, which can be overridden to be /usr
Makefile
$ cat debhello-0.0/Makefile
prefix = /usr/local
all: src/hello
src/hello: src/hello.c
@echo "CFLAGS=$(CFLAGS)" | \
fold -s -w 70 | \
sed -e 's/^/# /'
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDCFLAGS) -o $@ $^
install: src/hello
install -D src/hello \
$(DESTDIR)$(prefix)/bin/hello
clean:
-rm -f src/hello
distclean: clean
uninstall:
-rm -f $(DESTDIR)$(prefix)/bin/hello
Note
The echo of the $(CFLAGS) variable is used to verify the proper setting of the
build flag in the following example.
21
CHAPTER 5. SIMPLE PACKAGING 5.6. STEP 2: GENERATE TEMPLATE FILES …
The debmake command generates all these template files based on command line options. Since no options
are specified, the debmake command chooses reasonable default values for you:
• The source package name: debhello
• The upstream version: 0.0
22
CHAPTER 5. SIMPLE PACKAGING 5.6. STEP 2: GENERATE TEMPLATE FILES …
Note
Here, the debmake command is invoked with the -x1 option to keep this tutorial
simple. Use of default -x3 option is highly recommended.
8 directories, 24 files
The debian/rules file is the build script provided by the package maintainer. Here is its template file generated
by the debmake command.
debian/rules (template file):
$ cd /path/to/debhello-0.0
$ cat debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
23
CHAPTER 5. SIMPLE PACKAGING 5.6. STEP 2: GENERATE TEMPLATE FILES …
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1
%:
dh $@
#override_dh_auto_install:
# dh_auto_install -- prefix=/usr
#override_dh_install:
# dh_install --list-missing -X.pyc -X.pyo
This is essentially the standard debian/rules file with the dh command. (There are some commented out
contents for you to customize it.)
The debian/control file provides the main meta data for the Debian package. Here is its template file generated
by the debmake command.
debian/control (template file):
$ cat debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Osamu Aoki" <[email protected]>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.2
Homepage: <insert the upstream URL, if relevant>
Rules-Requires-Root: no
#Vcs-Git: https://salsa.debian.org/debian/debhello.git
#Vcs-Browser: https://salsa.debian.org/debian/debhello
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: auto-generated package by debmake
This Debian binary package was auto-generated by the
debmake(1) command provided by the debmake package.
Warning
Since this is the ELF binary executable package, the debmake command sets “Architecture: any” and “Multi-
Arch: foreign”. Also, it sets required substvar parameters as “Depends: ${shlibs:Depends}, ${misc:Depends}”.
These are explained in “Chapter 6”.
Note
Please note this debian/control file uses the RFC-822 style as documented in
“5.2 Source package control files — debian/control” of the “Debian Policy Man-
ual”. The use of the empty line and the leading space are significant.
The debian/copyright file provides the copyright summary data of the Debian package. Here is its template
file generated by the debmake command.
debian/copyright (template file):
24
CHAPTER 5. SIMPLE PACKAGING 5.7. STEP 3: MODIFICATION TO THE …
$ cat debian/copyright
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: debhello
Upstream-Contact: <preferred name and address to reach the upstream project>
Source: <url://example.com>
#
# Please double check copyright with the licensecheck(1) command.
Files: Makefile
README.md
src/hello.c
Copyright: __NO_COPYRIGHT_NOR_LICENSE__
License: __NO_COPYRIGHT_NOR_LICENSE__
#----------------------------------------------------------------------------...
# Files marked as NO_LICENSE_TEXT_FOUND may be covered by the following
# license/copyright files.
%:
dh $@
override_dh_auto_install:
dh_auto_install -- prefix=/usr
Exporting the DH_VERBOSE environment variable in the debian/rules file as above forces the debhelper
tool to make a fine grained build report.
Exporting DEB_BUILD_MAINT_OPTION as above sets the hardening options as described in the “FEA-
TURE AREAS/ENVIRONMENT” in dpkg-buildflags(1). 1
Exporting DEB_CFLAGS_MAINT_APPEND as above forces the C compiler to emit all the warnings.
Exporting DEB_LDFLAGS_MAINT_APPEND as above forces the linker to link only when the library is
actually needed. 2
The dh_auto_install command for the Makefile based build system essentially runs “$(MAKE) install DEST-
DIR=debian/debhello”. The creation of this override_dh_auto_install target changes its behavior to “$(MAKE)
install DESTDIR=debian/debhello prefix=/usr”.
Here are the maintainer versions of the debian/control and debian/copyright files.
debian/control (maintainer version):
1This is a cliché to force a read-only relocation link for the hardening and to prevent the lintian warning “W: debhello: hardening-no-relro
usr/bin/hello”. This is not really needed for this example but should be harmless. The lintian tool seems to produce a false positive warning
for this case which has no linked library.
2This is a cliché to prevent overlinking for the complex library dependency case such as Gnome programs. This is not really needed for
this simple example but should be harmless.
25
CHAPTER 5. SIMPLE PACKAGING 5.7. STEP 3: MODIFICATION TO THE …
$ vim debian/control
... hack, hack, hack, ...
$ cat debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.2
Homepage: https://salsa.debian.org/debian/debmake-doc
Rules-Requires-Root: no
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: Simple packaging example for debmake
This Debian binary package is an example package.
(This is an example only)
Files: *
Copyright: 2015-2021 Osamu Aoki <[email protected]>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Let’s remove unused template files and edit remaining template files:
• debian/README.source
• debian/source/local-option.ex
• debian/source/local-patch-header.ex
• debian/patches/series (No upstream patch)
• clean
• dirs
• install
26
CHAPTER 5. SIMPLE PACKAGING 5.8. STEP 4: BUILDING PACKAGE WITH DEBUILD
• links
Template files under debian/. (v=0.0):
$ rm -f debian/clean debian/dirs debian/install debian/links
$ rm -f debian/README.source debian/source/*.ex
$ rm -rf debian/patches
$ tree -F debian
debian/
+-- README.Debian
+-- changelog
+-- control
+-- copyright
+-- gbp.conf
+-- rules*
+-- salsa-ci.yml
+-- source/
| +-- format
+-- tests/
| +-- control
+-- upstream/
| +-- metadata
+-- watch
4 directories, 11 files
Tip
Configuration files used by the dh_* commands from the debhelper package
usually treat # as the start of a comment line.
27
CHAPTER 5. SIMPLE PACKAGING 5.8. STEP 4: BUILDING PACKAGE WITH DEBUILD
# CFLAGS=-g -O2
...
Finished running lintian.
You can verify that CFLAGS is updated properly with -Wall and -pedantic by the DEB_CFLAGS_MAINT_APPEND
variable.
The manpage should be added to the package as reported by the lintian package, as shown in later examples
(see “Chapter 13”). Let’s move on for now.
Let’s inspect the result.
The generated files of debhello version 0.0 by the debuild command:
$ cd /path/to
$ tree -FL 1
./
+-- debhello-0.0/
+-- debhello-0.0.tar.gz
+-- debhello-dbgsym_0.0-1_amd64.deb
+-- debhello_0.0-1.debian.tar.xz
+-- debhello_0.0-1.dsc
+-- debhello_0.0-1_amd64.build
+-- debhello_0.0-1_amd64.buildinfo
+-- debhello_0.0-1_amd64.changes
+-- debhello_0.0-1_amd64.deb
+-- debhello_0.0.orig.tar.gz -> debhello-0.0.tar.gz
2 directories, 9 files
• The debhello_0.0-1_amd64.changes is the meta data file for the Debian binary package.
The debhello_0.0-1.debian.tar.xz contains the Debian changes to the upstream source as follows.
The compressed archive contents of debhello_0.0-1.debian.tar.xz:
$ tar -tzf debhello-0.0.tar.gz
debhello-0.0/
debhello-0.0/src/
debhello-0.0/src/hello.c
debhello-0.0/Makefile
debhello-0.0/README.md
$ tar --xz -tf debhello_0.0-1.debian.tar.xz
debian/
debian/README.Debian
debian/changelog
debian/control
debian/copyright
debian/gbp.conf
debian/rules
debian/salsa-ci.yml
debian/source/
debian/source/format
debian/tests/
28
CHAPTER 5. SIMPLE PACKAGING 5.8. STEP 4: BUILDING PACKAGE WITH DEBUILD
debian/tests/control
debian/upstream/
debian/upstream/metadata
debian/watch
The debhello_0.0-1_amd64.deb contains the binary files to be installed to the target system.
The debhello-debsym_0.0-1_amd64.deb contains the debug symbol files to be installed to the target system.
The binary package contents of all binary packages:
$ dpkg -c debhello-dbgsym_0.0-1_amd64.deb
drwxr-xr-x root/root ... ./
drwxr-xr-x root/root ... ./usr/
drwxr-xr-x root/root ... ./usr/lib/
drwxr-xr-x root/root ... ./usr/lib/debug/
drwxr-xr-x root/root ... ./usr/lib/debug/.build-id/
drwxr-xr-x root/root ... ./usr/lib/debug/.build-id/be/
-rw-r--r-- root/root ... ./usr/lib/debug/.build-id/be/f1e0185834f3c3e2614cf8...
drwxr-xr-x root/root ... ./usr/share/
drwxr-xr-x root/root ... ./usr/share/doc/
lrwxrwxrwx root/root ... ./usr/share/doc/debhello-dbgsym -> debhello
$ dpkg -c debhello_0.0-1_amd64.deb
drwxr-xr-x root/root ... ./
drwxr-xr-x root/root ... ./usr/
drwxr-xr-x root/root ... ./usr/bin/
-rwxr-xr-x root/root ... ./usr/bin/hello
drwxr-xr-x root/root ... ./usr/share/
drwxr-xr-x root/root ... ./usr/share/doc/
drwxr-xr-x root/root ... ./usr/share/doc/debhello/
-rw-r--r-- root/root ... ./usr/share/doc/debhello/README.Debian
-rw-r--r-- root/root ... ./usr/share/doc/debhello/changelog.Debian.gz
-rw-r--r-- root/root ... ./usr/share/doc/debhello/copyright
Caution
Many more details need to be addressed before uploading the package to the
Debian archive.
Note
If manual adjustments of auto-generated configuration files by the debmake com-
mand are skipped, the generated binary package may lack meaningful package
description and some of the policy requirements may be missed. This sloppy
package functions well under the dpkg command, and may be good enough for
your local deployment.
29
CHAPTER 5. SIMPLE PACKAGING 5.9. STEP 3 (ALTERNATIVES): MODIFICATION …
Note
The above “Section 5.7” using the debian/rules file is the better approach for
packaging for this example. But let’s continue on with this alternative approaches
as a leaning experience.
In the following, let’s consider 3 simple variants of this alternative approach to generate debian/patches/*
files representing modifications to the upstream source in the Debian source format “3.0 (quilt)”. These substitute
“Section 5.7” in the above step-by-step example:
• “Section 5.10”
• “Section 5.11”
• “Section 5.12”
Please note the debian/rules file used for these examples doesn’t have the override_dh_auto_install target as
follows:
debian/rules (alternative maintainer version):
$ cd /path/to/debhello-0.0
$ vim debian/rules
... hack, hack, hack, ...
$ cat debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@
all: src/hello
$ rm -rf debhello-0.0
$ mv -f debhello-0.0.orig debhello-0.0
30
CHAPTER 5. SIMPLE PACKAGING 5.11. PATCH BY DQUILT APPROACH
Please note that the upstream source tree is restored to the original state after generating a patch file 000-prefix-
usr.patch.
This 000-prefix-usr.patch is edited to be DEP-3 conforming and moved to the right location as below.
000-prefix-usr.patch (DEP-3):
$ echo '000-prefix-usr.patch' >debian/patches/series
$ vim ../000-prefix-usr.patch
... hack, hack, hack, ...
$ mv -f ../000-prefix-usr.patch debian/patches/000-prefix-usr.patch
$ cat debian/patches/000-prefix-usr.patch
From: Osamu Aoki <[email protected]>
Description: set prefix=/usr patch
diff -Nru debhello-0.0.orig/Makefile debhello-0.0/Makefile
--- debhello-0.0.orig/Makefile
+++ debhello-0.0/Makefile
@@ -1,4 +1,4 @@
-prefix = /usr/local
+prefix = /usr
all: src/hello
Note
When generating the Debian source package by dpkg-source via dpkg-
buildpackage in the following step of “Section 5.8”, the dpkg-source com-
mand assumes that no patch was applied to the upstream source, since the
.pc/applied-patches is missing.
31
CHAPTER 5. SIMPLE PACKAGING 5.11. PATCH BY DQUILT APPROACH
| | +-- series
| +-- README.Debian
| +-- README.source
| +-- rules
| +-- salsa-ci.yml
| +-- source
| | +-- format
| | +-- local-options.ex
| | +-- local-patch-header.ex
| +-- tests
| | +-- control
| +-- upstream
| | +-- metadata
| +-- watch
+-- Makefile
+-- .pc
| +-- 000-prefix-usr.patch
| | +-- Makefile
| | +-- .timestamp
| +-- applied-patches
| +-- .quilt_patches
| +-- .quilt_series
| +-- .version
+-- README.md
+-- src
+-- hello.c
9 directories, 29 files
$ cat debian/patches/series
000-prefix-usr.patch
$ cat debian/patches/000-prefix-usr.patch
Description: set prefix=/usr patch
Author: Osamu Aoki <[email protected]>
Index: debhello-0.0/Makefile
===================================================================
--- debhello-0.0.orig/Makefile
+++ debhello-0.0/Makefile
@@ -1,4 +1,4 @@
-prefix = /usr/local
+prefix = /usr
all: src/hello
Here, Makefile in the upstream source tree doesn’t need to be restored to the original state for the packaging.
Note
When generating the Debian source package by dpkg-source via dpkg-
buildpackage in the following step of “Section 5.8”, the dpkg-source com-
mand assumes that patches were applied to the upstream source, since the
.pc/applied-patches exists.
The upstream source tree can be restored to the original state for the packaging.
The upstream source tree (restored):
$ dquilt pop -a
Removing patch debian/patches/000-prefix-usr.patch
Restoring Makefile
No patches applied
$ head -1 Makefile
prefix = /usr/local
$ tree -a .pc
32
CHAPTER 5. SIMPLE PACKAGING 5.12. PATCH BY “DPKG-SOURCE …
.pc
+-- .quilt_patches
+-- .quilt_series
+-- .version
1 directory, 3 files
33
CHAPTER 5. SIMPLE PACKAGING 5.12. PATCH BY “DPKG-SOURCE …
+-- source
| +-- format
| +-- local-options
| +-- local-patch-header
+-- tests
| +-- control
+-- upstream
| +-- metadata
+-- watch
4 directories, 13 files
Note
When generating the Debian source package by dpkg-source via dpkg-
buildpackage in the following step of “Section 5.8”, the dpkg-source command
uses options specified in debian/source/local-options to auto-commit modifica-
tion applied to the upstream source as patches/debian-changes.
Let’s inspect the Debian source package generated after the following “Section 5.8” step and extracting files
from debhello-0.0.debian.tar.xz.
Inspect debhello-0.0.debian.tar.xz after debuild
$ tar --xz -xvf debhello_0.0-1.debian.tar.xz
debian/
debian/README.Debian
debian/changelog
debian/control
debian/copyright
debian/gbp.conf
debian/patches/
debian/patches/debian-changes
debian/patches/series
debian/rules
debian/salsa-ci.yml
debian/source/
debian/source/format
debian/tests/
debian/tests/control
debian/upstream/
debian/upstream/metadata
debian/watch
--- debhello-0.0.orig/Makefile
+++ debhello-0.0/Makefile
@@ -1,4 +1,4 @@
-prefix = /usr/local
+prefix = /usr
all: src/hello
34
CHAPTER 5. SIMPLE PACKAGING 5.12. PATCH BY “DPKG-SOURCE …
The Debian source package debhello-0.0.debian.tar.xz is confirmed to be generated properly with debian/-
patches/* files for the Debian modification.
35
Chapter 6
Here, a broad overview is presented without using VCS operations for the basic rules of Debian packaging focusing
on the non-native Debian package in the “3.0 (quilt)” format.
Note
Some details are intentionally skipped for clarity. Please read the manpages
of the dpkg-source(1), dpkg-buildpackage(1), dpkg(1), dpkg-deb(1), deb(5),
etc.
The Debian source package is a set of input files used to build the Debian binary package and is not a single
file.
The Debian binary package is a special archive file which holds a set of installable binary data with its associated
information.
A single Debian source package may generate multiple Debian binary packages defined in the debian/control
file.
The non-native Debian package in the Debian source format “3.0 (quilt)” is the most normal Debian source
package format.
Note
There are many wrapper scripts. Use them to streamline your workflow but make
sure to understand the basics of their internals.
36
CHAPTER 6. BASICS FOR PACKAGING 6.1. PACKAGING WORKFLOW
debian/rules The executable script for building the Debian package (see “Section 6.5”)
debian/control The package configuration file containing the source package name, the source build
dependencies, the binary package name, the binary dependencies, etc. (see “Section 6.6”)
debian/changelog The Debian package history file defining the upstream package version and the
Debian revision in its first line (see “Section 6.7”)
debian/copyright The copyright and license summary (see “Section 6.8”)
• Optional specification files under the debian/* (see “Section 6.14”):
• The debmake command invoked in the package-version/ directory may be used to provide the initial
template of these configuration files.
– Required specification files are generated even with the -x0 option.
– The debmake command does not overwrite any existing configuration files.
• These files must be manually edited to their perfection according to the “Debian Policy Manual” and
“Debian Developer’s Reference”.
5. The dpkg-buildpackage command (usually from its wrapper debuild or sbuild) is invoked in the package-
version/ directory to make the Debian source and binary packages by invoking the debian/rules script.
7. Test the goodness of the generated Debian binary package manually by installing it and running its programs.
8. After confirming the goodness, prepare files for the normal source-only upload to the Debian archive.
9. Sign the Debian package file with the debsign command using your private GPG key.
• Use “debsign package_version-revision_source.changes” (normal source-only upload situation)
• Use “debsign package_version-revision_arch.changes” (exceptional binary upload situation such as
NEW uploads, and security uploads) files for the binary Debian package upload.
10. Upload the set of the Debian package files with the dput command to the Debian archive.
• Use “dput package_version-revision_source.changes” (source-only upload)
• Use “dput package_version-revision_arch.changes” (binary upload)
1This is the default up to debhelper v13. At debhelper v14, it warns the default change. After debhelper v15, it will change the default
to DESTDIR=debian/tmp/ .
37
CHAPTER 6. BASICS FOR PACKAGING 6.2. DEBHELPER PACKAGE
Test building and confirming of the binary package goodness as above is the moral obligation as a diligent
Debian developer but there is no physical barrier for people to skip such operations at this moment for the source-
only upload.
Here, please replace each part of the filename as:
• the package part with the Debian source package name
Tip
Many patch management and VCS usage strategies for the Debian packaging
are practiced. You don’t need to use all of them.
Tip
• configuring their behavior with declarative configuration files in the debian/ directory.
You should almost always use debhelper as your package’s build dependency. This document also assumes that
you are using a fairly contemporary version of debhelper to handle packaging works in the following contents.
Note
For debhelper “compat >= 9”, the dh command exports compiler flags (CFLAGS,
CXXFLAGS, FFLAGS, CPPFLAGS and LDFLAGS) with values as returned
by dpkg-buildflags if they are not set previously. (The dh command calls
set_buildflags defined in the Debian::Debhelper::Dh_Lib module.)
38
CHAPTER 6. BASICS FOR PACKAGING 6.3. PACKAGE NAME AND VERSION
Note
debhelper(1) changes its behavior with time. Please make sure to read
debhelper-compat-upgrade-checklist(7) to understand the situation.
One tricky case occurs when the upstream releases hello-0.9.12-ReleaseCandidate-99.tar.gz as the pre-release
of hello-0.9.12.tar.gz. You can ensure the Debian package upgrade to work properly by renaming the upstream
source to hello-0.9.12~rc99.tar.gz.
2For more than 90% of packages, the package name is equal or less than 24 characters; the upstream version is equal or less than 10
characters and the Debian revision is equal or less than 3 characters.
39
CHAPTER 6. BASICS FOR PACKAGING 6.4. NATIVE DEBIAN PACKAGE
Caution
A native Debian package is often accidentally built when its upstream tarball is not
accessible from the dpkg-buildpackage command with its correct name pack-
age_version.orig.tar.gz . This is a typical newbie mistake caused by making a
symlink name with “-” instead of the correct one with “_”.
A native Debian package has no separation between the upstream code and the Debian changes and consists
only of the following:
• package_version.tar.gz (copy or symlink of package-version.tar.gz with debian/* files.)
• package_version.dsc
If you need to create a native Debian package, create it in the Debian source format “3.0 (native)” using dpkg-
source(1).
Tip
There is no need to create the tarball in advance if the native Debian package
format is used. The debian/source/format file should have “3.0 (native)” in it as
described in dpkg-source(1) and The debian/source/format file should have
the version without the Debian revision (1.0 instead of 1.0-1). Then, the tarball
containing is generated when “dpkg-source -b” is invoked in the source tree.
%:
dh $@
The dh command functions as the sequencer to call all required “dh target” commands at the right moment. ⁴
• dh clean : clean files in the source tree.
• dh build : build the source tree
• dh build-arch : build the source tree for architecture dependent packages
• dh build-indep : build the source tree for architecture independent packages
3The debmake command generates a bit more complicated debian/rules file. But this is the core part.
⁴This simplicity is available since version 7 of the debhelper package. This guide assumes the use of debhelper version 13 or newer.
40
CHAPTER 6. BASICS FOR PACKAGING 6.6. DEBIAN/CONTROL FILE
• dh install-arch : install the binary files to $(DESTDIR) for architecture dependent packages
• dh install-indep : install the binary files to $(DESTDIR) for architecture independent packages
• dh binary : generate the deb file
Tip
Note
Tip
If an existing package has lower than debhelper compatibility level 13, probably
it’s time to update its packaging.
⁵This is the default up to debhelper v13. At debhelper v14, it warns the default change. After debhelper v15, it will change the default
to DESTDIR=debian/tmp/ .
41
CHAPTER 6. BASICS FOR PACKAGING 6.7. DEBIAN/CHANGELOG FILE
– If Debian maintainer modification fixes reported bugs, add “Closes: #<bug_number>” to close those
bugs.
• Even if you are uploading your package by yourself, you must document all non-trivial user-visible changes
such as:
– the security related bug fixes.
– the user interface changes.
• If you are asking your sponsor to upload it, you should document changes more comprehensively, including
all packaging related ones, to help reviewing your package.
– The sponsor shouldn’t be forced to second guess your thought behind your package.
– The sponsor’s time is more valuable than yours.
After finishing your packaging and verifying its quality, please execute the “dch -r” command and save the
finalized debian/changelog file with the suite normally set to unstable. ⁶ If you are packaging for backports,
security updates, LTS, etc., please use the appropriate distribution names instead.
The debmake command creates the initial template file with the upstream package version and the Debian
revision. The distribution is set to UNRELEASED to prevent accidental upload to the Debian archive.
Tip
The date string used in the debian/changelog file can be manually generated
by the “LC_ALL=C date -R” command.
Tip
42
CHAPTER 6. BASICS FOR PACKAGING 6.9. DEBIAN/PATCHES/* FILES
• “License information”
The debmake command creates the initial debian/copyright template file.
• Please double check copyright with the licensecheck(1) command.
Caution
The debian/copyright file should be sorted to keep the generic file patterns at
the top of the list. See “Section 15.6”.
Note
If you find issues with this license checker, please file a bug report to the debmake
package with the problematic part of text containing the copyright and license.
Note
Note
If you want to use VCS tools such as git, gbp and dgit to create and manage
these patches after learning basics here, please refer to later in “Chapter 10”.
43
CHAPTER 6. BASICS FOR PACKAGING 6.10. DEBIAN/SOURCE/INCLUDE-BINARIES …
The uscan command may verify the authenticity of the upstream tarball with optional configuration (see “Sec-
tion 6.12”).
See uscan(1), “Section 8.4”, “Section 7.1”, and “Section 10.10” for more.
If you know the public GPG key of the upstream maintainer from the mailing list, use it as the debian/upstream/signing-
key.asc file. Otherwise, use the hkp keyserver and check it via your web of trust.
Download public GPG key for the upstream
$ gpg --keyserver hkp://keys.gnupg.net --recv-key 80EE4A00
gpg: requesting key 80EE4A00 from hkp server keys.gnupg.net
gpg: key 80EE4A00: public key "Reuben Thomas <[email protected]>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1
$ gpg --verify hello-2.9.tar.gz.sig
gpg: Signature made Thu 10 Oct 2013 08:49:23 AM JST using DSA key ID 80EE4A00
gpg: Good signature from "Reuben Thomas <[email protected]>"
...
Primary key fingerprint: 9297 8852 A62F A5E2 85B2 A174 6808 9F73 80EE 4A00
Tip
If your network environment blocks access to the HKP port 11371, use
“hkp://keyserver.ubuntu.com:80” instead.
44
CHAPTER 6. BASICS FOR PACKAGING 6.13. DEBIAN/SALSA-CI.YML FILE
After confirming the key ID 80EE4A00 is a trustworthy one, download its public key into the debian/upstream/signing-
key.asc file.
Set public GPG key to debian/upstream/signing-key.asc
$ gpg --armor --export 80EE4A00 >debian/upstream/signing-key.asc
With the above debian/upstream/signing-key.asc file and the following debian/watch file, the uscan com-
mand can verify the authenticity of the upstream tarball after its download. E.g.:
Improved debian/watch file with GPG support:
version=4
opts="pgpsigurlmangle=s/$/.sig/" \
https://ftp.gnu.org/gnu/hello/ @PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@
Tip
Even an upstream source without its build system can be packaged just by using
these files. See “Section 13.2” as an example.
The alphabetical list of notable optional debian/binarypackage.* configuration files listed below provides very
powerful means to set the installation path of files. Please note:
• The ”-x[01234] ” superscript notation that appears in the following list indicates the minimum value for the
debmake -x option that generates the associated template file. See “Section 15.9” or debmake(1) for details.
• For a single binary package, the “binarypackage.” part of the filename in the list may be removed.
• For a multi binary package, a configuration file missing the “binarypackage” part of the filename is applied
to the first binary package listed in the debian/control.
• When there are many binary packages, their configurations can be specified independently by prefixing their
name to their configuration filenames such as “package-1.install”, “package-2.install”, etc.
• Some template configuration files may not be created by the debmake command. In such cases, you need
to create them with an editor.
• Some configuration template files generated by the debmake command with an extra .ex suffix need to be
activated by removing that suffix.
• Unused configuration template files generated by the debmake command should be removed.
• Copy configuration template files as needed to the filenames matching their pertinent binary package names.
45
CHAPTER 6. BASICS FOR PACKAGING 6.14. OTHER DEBIAN/* FILES
46
CHAPTER 6. BASICS FOR PACKAGING 6.14. OTHER DEBIAN/* FILES
47
CHAPTER 6. BASICS FOR PACKAGING 6.14. OTHER DEBIAN/* FILES
See dh_installdeb(1) and “Chapter 6 - Package maintainer scripts and installation procedure” in the
“Debian Policy Manual”.
See also debconf-devel(7) and “3.9.1 Prompting in maintainer scripts” in the “Debian Policy Manual”.
README.Debian -x1 Installed into the first binary package listed in the debian/control file as usr/share/-
doc/binarypackage/README.Debian.
This file provides the information specific to the Debian package.
See dh_installdocs(1).
README.source -x1 Installed into the first binary package listed in the debian/control file as usr/share/-
doc/binarypackage/README.source.
If running “dpkg-source -x” on a source package doesn’t produce the source of the package, ready for
editing, and allow one to make changes and run dpkg-buildpackage to produce a modified package
without taking any additional steps, creating this file is recommended.
See “Debian policy manual section 4.14”.
binarypackage.service -x3 If this exists, it is installed into lib/systemd/system/binarypackage.service in bi-
narypackage.
See dh_systemd_enable(1), dh_systemd_start(1), and dh_installinit(1).
source/format -x1 The Debian package format.
– Use “3.0 (quilt)” to make this non-native package (recommended)
– Use “3.0 (native)” to make this native package
See “SOURCE PACKAGE FORMATS” in dpkg-source(1).
source/lintian-overrides -x3 These file is not installed, but are scanned by the lintian command to provide
overrides for the source package.
See dh_lintian(1) and lintian(1).
source/local-options -x1 The dpkg-source command uses this content as its options. Notable options are:
– unapply-patches
– abort-on-upstream-changes
– auto-commit
– single-debian-patch
This is not included in the generated source package and is meant to be committed to the VCS of the
maintainer.
See “FILE FORMATS” in dpkg-source(1).
source/local-patch-header -x1 Free form text that is put on top of the automatic patch generated.
This is not included in the generated source package and is meant to be committed to the VCS of the
maintainer.
See “FILE FORMATS” in dpkg-source(1).
source/options -x3 Use source/local-options instead to avoid issues with NMUs. See “FILE FORMATS”
in dpkg-source(1).
source/patch-header -x4 Use source/local-patch-header instead to avoid issues with NMUs. See “FILE
FORMATS” in dpkg-source(1).
binarypackage.symbols -x1 The symbols files, if present, are passed to the dpkg-gensymbols command to
be processed and installed.
See dh_makeshlibs(1) and “Section 9.16”..
binarypackage.templates -x3 This is the debconf templates file used for asking any questions necessary to
configure the package. See “Section 9.22”.
tests/control -x1 This is the RFC822-style test meta data file defined in DEP-8. See autopkgtest(1) and
“Section 9.4”.
TODO -x3 Installed into the first binary package listed in the debian/control file as usr/share/doc/binarypackage/TODO.D
See dh_installdocs(1).
binarypackage.tmpfile -x3 If this exists, it is installed into usr/lib/tmpfiles.d/binarypackage.conf in bina-
rypackage.
See dh_systemd_enable(1), dh_systemd_start(1), and dh_installinit(1).
48
CHAPTER 6. BASICS FOR PACKAGING 6.14. OTHER DEBIAN/* FILES
binarypackage.upstart -x4 If this exists, it is installed into etc/init/package.conf in the package build direc-
tory. (deprecated)
See dh_installinit(1).
upstream/metadata -x1 Per-package machine-readable metadata about upstream (DEP-12). See “Upstream
MEtadata GAthered with YAml (UMEGAYA)”.
49
Chapter 7
There are a few cases which require to sanitize the source to prevent contaminating the generated Debian source
package.
• Non DFSG contents in the upstream source.
– Debian takes software freedom seriously and follows the DFSG.
• Extraneous auto-generated contents in the upstream source.
– Debian package should rebuild them under the latest system.
• Extraneous VCS contents in the upstream source.
– The -i and -I options set in “Section 4.5” for the dpkg-source(1) command should avoid these.
* The -i option is aimed at the non-native Debian package.
* The -I is aimed at the native Debian package.
There are several methods to avoid inclusion of undesirable contents.
Note
The “debian/rules clean” target is called before the “dpkg-source --build” com-
mand by the dpkg-buildpackage command and the “dpkg-source --build” com-
mand ignores removed files.
50
CHAPTER 7. SANITIZATION OF THE SOURCE 7.3. FIX WITH EXTEND-DIFF-IGNORE
Note
This approach always works, even when you can’t remove the file. So it saves
you having to make a backup of the unmodified file just to be able to restore it
before the next build.
Tip
If the debian/source/local-options file is used instead, you can hide this setting
from the generated source package. This may be useful when the local non-
standard VCS files interfere with your packaging.
Note
If, for example, the source package of a native package needs files with the file
extension .o as a part of the test data, the setting in “Section 4.5” is too ag-
gressive. You can work around this problem by dropping the -I option for DE-
BUILD_DPKG_BUILDPACKAGE_OPTS in “Section 4.5” while adding the “tar-
ignore=…” lines in the debian/source/local-options file for each package.
This works because the dpkg-source command ignores the contents of the typical VCS files in the source tree
with the DEBUILD_DPKG_BUILDPACKAGE_OPTS setting in ̀”Section 4.5 ̀”.
51
CHAPTER 7. SANITIZATION OF THE SOURCE 7.5. FIX WITH “GIT CLEAN -DFX”
Tip
If the source tree is not managed by a VCS, you should run “git init; git add -A
.; git commit” before the first build.
52
Chapter 8
More on packaging
• The Debian package installation path etc. can be customized through the addition of configuration files such
as package.install and package.docs in the debian/ directory for the dh_* commands from the debhelper
package (see “Section 6.14”).
When these are not sufficient to make a good Debian package, -p1 patches of debian/patches/* files are de-
ployed to modify the upstream source. These are applied in the sequence defined in the debian/patches/series file
before building the package as presented in “Section 5.9”.
You should address the root cause of the Debian packaging problem by the least invasive way. The generated
package shall be more robust for future upgrades in this way.
Note
Send the patch addressing the root cause to the upstream maintainer if it is useful
to the upstream.
• Makefile,
• “python -m build”, or
• Build.PL.
If this is the case, you should add the override_dh_auto_build target with “dh_auto_build -- arguments”. This
ensures passing arguments to the build system after the default parameters that dh_auto_build usually passes.
53
CHAPTER 8. MORE ON PACKAGING 8.3. VARIABLES FOR DEBIAN/RULES
Tip
Please try not to execute the bare build system commands directly if they are
supported by the dh_auto_build command.
See:
• “Section 5.7” for the basic example.
• “Section 9.3” to be reminded of the challenge involving the underlying build system.
• “Section 9.10” for multiarch customization.
• “Section 9.6” for hardening customization.
• The debian/watch file in the old source tree must be a valid one.
• This make symlink ../foo_newvwesion.orig.tar.gz pointing to ../foo-newvwesion.tar.gz.
• Files are extracted from ../foo-newvwesion.tar.gz to ../foo-newversion/
• Files are copied from ../foo-oldversion/debian/ to ../foo-newvesion/debian/ .
After the above, you should refresh debian/patches/* files (see “Section 8.5”) and update debian/changelog
with the dch(1) command.
When “debian uupdate” is specified at the end of line in the debian/watch file, uscan automatically executes
uupdate(1) after downloading the tarball.
54
CHAPTER 8. MORE ON PACKAGING 8.5. MANAGE PATCH QUEUE WITH DQUILT
– If conflicts are encountered with “dquilt push” in the above, resolve them and run “dquilt refresh”
manually for each of them.
In schroot(1) terminology, this builds a Debian package in a clean ephemeral chroot “chroot:unstable-amd64-
sbuild” started as a copy of the clean minimal persistent chroot “source:unstable-amd64-sbuild”.
This build environment was set up as described in “Section 4.6” with “sbuild-debian-developer-setup -s un-
stable” which essentially did the following:
$ sudo mkdir -p /srv/chroot/dist-amd64-sbuild
$ sudo sbuild-createchroot unstable /srv/chroot/unstable-amd64-sbuild http://deb ←-
.debian.org/debian
$ sudo usermod -a -G sbuild <your_user_name>
$ sudo newgrp -
55
CHAPTER 8. MORE ON PACKAGING 8.8. SPECIAL BUILD CASES
Here:
• The profile defined in the /etc/schroot/sbuild/ directory is used to setup the chroot environment.
• /srv/chroot/unstable-amd64-sbuild directory holds the chroot filesystem.
• /etc/sbuild/unstable-amd64-sbuild is symlinked to /srv/chroot/unstable-amd64-sbuild .
You can update this source chroot “source:unstable-amd64-sbuild” by:
$ sudo sbuild-update -udcar unstable
Tip
• debuild -sa
• sbuild
• For “gbp buildpackage”, edit the ~/.gbp.conf file.
56
CHAPTER 8. MORE ON PACKAGING 8.10. SKIPPED UPLOADS
Tip
On the other hand, the -sd option will force the exclusion of the original orig.tar.gz
source.
Tip
• debuild -v1.2
• sbuild --debbuildopts -v1.2
• For gbp buildpackage, edit the ~/.gbp.conf file.
– This file contains some directions such as redirecting the bug report to another package.
• debian/binarypackage.bug-presubj → usr/share/bug/binarypackage/presubj
– This file is displayed to the user by the reportbug command.
• debian/binarypackage.bug-script → usr/share/bug/binarypackage or usr/share/bug/binarypackage/script
– The reportbug command runs this script to generate a template file for the bug report.
See dh_bugfiles(1) and “reportbug’s Features for Developers (README.developers)”
Tip
If you always remind the bug reporter of something or ask them about their situ-
ation, use these files to automate it.
57
Chapter 9
Advanced packaging
58
CHAPTER 9. ADVANCED PACKAGING 9.3. NOTE ON BUILD SYSTEM
9.5 Bootstrapping
Debian cares about supporting new ports or flavours. The new ports or flavours require bootstrapping operation
for the cross-build of the initial minimal native-building system. In order to avoid build-dependency loops dur-
ing bootstrapping, the build-dependency needs to be reduced using the DEB_BUILD_PROFILES environment
variable.
See Debian wiki: “BuildProfileSpec”.
Tip
If a core package foo build depends on a package bar with deep build depen-
dency chains but bar is only used in the test target in foo, you can safely mark
the bar with <!nocheck> in the Build-depends of foo to avoid build loops.
59
CHAPTER 9. ADVANCED PACKAGING 9.6. COMPILER HARDENING
9.8 Substvar
The debian/control file also defines the package dependency in which the “variable substitutions mechanism”
(substvar) may be used to free package maintainers from chores of tracking most of the simple package dependency
cases. See deb-substvars(5).
The debmake command supports the following substvars:
• ${misc:Depends} for all binary packages
• ${misc:Pre-Depends} for all multiarch packages
• ${shlibs:Depends} for all binary executable and library packages
• ${python:Depends} for all Python packages
• ${python3:Depends} for all Python3 packages
• ${perl:Depends} for all Perl packages
• ${ruby:Depends} for all Ruby packages
For the shared library, required libraries found simply by “objdump -p /path/to/program | grep NEEDED” are
covered by the shlib substvar.
For Python and other interpreters, required modules found simply looking for lines with “import”, “use”,
“require”, etc., are covered by the corresponding substvars.
For other programs which do not deploy their own substvars, the misc substvar covers their dependency.
For POSIX shell programs, there is no easy way to identify the dependency and no substvar covers their de-
pendency.
For libraries and modules required via the dynamic loading mechanism including the “GObject introspection”
mechanism, there is no easy way to identify the dependency and no substvar covers their dependency.
60
CHAPTER 9. ADVANCED PACKAGING 9.9. LIBRARY PACKAGE
9.10 Multiarch
Multiarch support for cross-architecture installation of binary packages (particularly i386 and amd64, but also other
combinations) in the dpkg and apt packages introduced in Debian wheezy (7.0, May 2013), demands that we pay
extra attention to packaging.
You should read the following references in detail.
• Ubuntu wiki (upstream)
– “MultiarchSpec”
• Debian wiki (Debian situation)
– “Debian multiarch support”
– “Multiarch/Implementation”
The multiarch is enabled by using the <triplet> value such as i386-linux-gnu and x86_64-linux-gnu in the
install path of shared libraries as /usr/lib/<triplet>/, etc..
• The <triplet> value required internally by debhelper scripts is implicitly set in themselves. The maintainer
doesn’t need to worry.
• The <triplet> value used in override_dh_* target scripts must be explicitly set in the debian/rules file by the
maintainer. The <triplet> value is stored in the $(DEB_HOST_MULTIARCH) variable in the following
debian/rules snippet example:
DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
...
override_dh_install:
mkdir -p package1/lib/$(DEB_HOST_MULTIARCH)
cp -dR tmp/lib/. package1/lib/$(DEB_HOST_MULTIARCH)
1This document was written before the introduction of the symbols file.
2The strong preference is to use the SONAME versioned -dev package names over the single -dev package name in “Chapter 6. Develop-
ment (-DEV) packages”, which does not seem to be shared by the former ftp-master (Steve Langasek). This document was written before the
introduction of the multiarch system and the symbols file.
61
CHAPTER 9. ADVANCED PACKAGING 9.11. SPLIT OF A DEBIAN BINARY PACKAGE
See:
• “Section 8.3”
• “Section 15.2”
• “Section 9.12”
• “dpkg-architecture(1) manpage”
• List all file paths (relative to debian/tmp) in the corresponding debian/binarypackage.install files.
Please check examples in this guide:
• “Section 13.11” (Autotools based)
62
CHAPTER 9. ADVANCED PACKAGING 9.14. MULTIARCH HEADER FILE PATH
The use of the /usr/lib/<triplet>/packagename/ path for the library files allows the upstream maintainer to use
the same install script for the multiatch system with /usr/lib/<triplet> and the biarch system with /usr/lib<qual>/.
3
The use of the file path containing packagename enables having more than 2 development libraries simultane-
ously installed on a system.
63
CHAPTER 9. ADVANCED PACKAGING 9.16. LIBRARY SYMBOLS
• Extract the old DEBIAN/symbols file of the immediate previous binary package with the “dpkg-deb -e”
command.
– Alternatively, the mc command may be used to extract the DEBIAN/symbols file.
• Copy it to the debian/binarypackage.symbols file.
* Extract the updated DEBIAN/symbols file with the “dpkg-deb -e” command.
* Trim the Debian revision such as -1 in it.
* Copy it to the debian/binarypackage.symbols file.
* Re-build the binary package.
– If the dpkg-gensymbols command does not warn about new symbols:
• “deb-symbols(5) manapage”
You should also check:
• Debian wiki: “UsingSymbolsFiles”
Tip
For C++ libraries and other cases where the tracking of symbols is problematic,
follow “8.6.4 The shlibs system” of the “Debian Policy Manual”, instead. Please
make sure to erase the empty debian/binarypackage.symbols file generated by
the debmake command. For this case, the DEBIAN/shlibs file is used.
64
CHAPTER 9. ADVANCED PACKAGING 9.17. LIBRARY PACKAGE NAME
Warning
If the binary library package isn’t renamed, many dependent packages in the
unstable suite become broken just after the library upload even if a binNMU
upload is requested. The binNMU may not happen immediately after the upload
due to several reasons.
The -dev package must follow one of the following naming rules:
* The associated library package needs to be renamed from libfoo7 to libfoo8 to prevent dependency
breakage in the unstable suite during the library transition.
– This approach should be used if the simple binNMU resolves the library dependency quickly for all
affected packages. (ABI change by dropping the deprecated API while keeping the active API un-
changed.)
– This approach may still be a good idea if manual code updates, etc. can be coordinated and manageable
within limited packages. (API change)
• Use the versioned -dev package names: libfoo7-dev and libfoo8-dev
– This is typical for many major library packages.
– Two versions of the library source packages are allowed simultaneously in the archive.
Tip
If the data encoding scheme changes (e.g., latin1 to utf-8), the same care as the
API change needs to be taken.
65
CHAPTER 9. ADVANCED PACKAGING 9.18. LIBRARY TRANSITION
Caution
• “6.7.9. Best practices for debug packages” of the “Debian Developer’s Reference”.
• “18.2 Debugging Information in Separate Files” of the “Debugging with gdb”
• “dh_strip(1) manapage”
• “strip(1) manapage”
• “readelf(1) manapage”
• “objcopy(1) manapage”
• Debian wiki: “DebugPackage”
66
CHAPTER 9. ADVANCED PACKAGING 9.21. -DBGSYM PACKAGE
• Set the Build-Depends to debhelper-compat (>=13) while removing Build-Depends to debhelper in de-
bian/control.
9.22 debconf
The debconf package enables us to configure packages during their installation in 2 main ways:
All user interactions for the package installation must be handled by this debconf system using the following
files.
• debian/binarypackage.config
– This is the debconf config script used for asking any questions necessary to configure the package.
• debian/binarypackage.template
– This is the debconf templates file used for asking any questions necessary to configure the package.
These debconf files are called by package configuration scripts in the binary Debian package
• DEBIAN/binarypackage.preinst
• DEBIAN/binarypackage.prerm
• DEBIAN/binarypackage.postinst
• DEBIAN/binarypackage.postrm
See dh_installdebconf(1), debconf(7), debconf-devel(7) and “3.9.1 Prompting in maintainer scripts” in the
“Debian Policy Manual”.
67
Chapter 10
Up to “Chapter 9”, we focused on packaging operations without using Git or any other VCS. These traditional
packaging operations were based on the tarball released by the upstream as mentioned in “Section 9.1”.
Currently, the git(1) command is the de-facto platform for the VCS tool and is the essential part of both upstream
development and Debian packaging activities. (See Debian wiki “Debian git packaging maintainer branch formats
and workflows” for existing VCS workflows.)
Note
Since the non-native Debian source package uses “diff -u” as its backend tech-
nology for the maintainer modification, it can’t represent modification involving
symlink, file permissions, nor binary data (March 2022 discussion on debian-
[email protected]). Please avoid making such maintainer modifications even though
these can be recorded in the Git repository.
Since VCS workflows are complicated topic and there are many practice styles, I only touch on some key points
with minimal information, here.
Salsa is the remote Git repository service with associated tools. It offers the collaboration platform for Debian
packaging activities using a custom GitLab application instance. See:
• “Section 10.1”
• “Section 10.2”
• “Section 10.3”
There are 2 styles of branch names for the Git repository used for the packaging. See “Section 10.4”.
There are 2 main usage styles for the Git repository for the packaging. See:
• “Section 10.5”
• “Section 10.6”
There are 2 notable Debian packaging tools for the Git repository for the packaging.
• gbp(1) and its subcommands:
– This is a tool designed to work with “Section 10.5”.
– See “Section 10.7”.
68
CHAPTER 10. PACKAGING WITH GIT 10.1. SALSA REPOSITORY
# Customizations here
Note
This upstream-branch may need to be created using the tarball released by the
upstream independent of the upstream Git repository since it tends to contain
automatically generated files.
The upstream Git repository content can co-exit in the local Git repository used for the Debian packaging by
adding its copy. E.g.:
$ git remote add upstream-git <url-upstream-git-repo>
$ git fetch upstream-git master:upstream-master
This allows easy cherry-picking from the upstream Git repository for bug fixes.
1Use of git.debian.org or alioth.debian.org are deprecated now.
69
CHAPTER 10. PACKAGING WITH GIT 10.5. PATCH UNAPPLIED GIT REPOSITORY
• This repository style is useful for all variants of traditional workflows and gdb based workflow:
– “Section 5.7” (no patch)
– “Section 5.10”
* debian/patches/* files can also be generated using “git format-patch”, “git diff”, or “gitk” from
git commits in the through-away maintainer modification branch or from the upstream unreleased
commits.
– “Section 5.11” including the last “dquilt pop -a” step
– “Section 10.9”
• Use helper scripts such as dquilt(1) and gbp-pq(1) to manage data in debian/patches/* files.
– Add .pc line to the ~/.gitignore file if dquilt is used.
– Add unapply-patches and abort-on-upstream-changes lines in the debian/source/local-options file.
• Use “dpkg-source -b” to build the Debian source package.
Note
• The source tree matches extracted contents by “dpkg-source -x” of the Debian source package.
– The source tree is buildable and the same as what NMU maintainers see.
– The source is recorded in the Git repository with maintainer changes including the debian/ directory.
– Maintainer changes to the upstream source are also recorded in debian/patches/* files for the Debian
source format “3.0 (quilt)”.
70
CHAPTER 10. PACKAGING WITH GIT 10.7. NOTE ON GBP
– Use this if you don’t intend to record topic patches in the Debain source package.
– Good enough for packages only with trivial modifications to the upstream.
– Only choice for packages with intertwined modification histories to the upstream
– Add auto-commit and single-debian-patch lines in the debian/source/local-options file
– Use “git checkout upstream; git pull” to pull the new upstream commit and use “git checkout master
; git merge <new-version-tag>” to merge it to the master branch.
– Use “dpkg-source -b” to build the Debian source package.
– Use “dgit push-source” or “dgit push” for uploading the Debian package via the dgit server.
– See “Section 5.12” for example.
• dgit-maint-debrebase(7) workflow.
– Use this if you wish to commit maintainer changes to the patch applied Git repository with the same
granularity as patches of “Section 10.9”.
– Good for packages with multiple sequenced modifications to the upstream.
– Use “dgit build-source” to build the Debian source package.
– Use “dgit push-source” or “dgit push” for uploading the Debian package via the dgit server.
– Details of this workflow are beyond the scope of this tutorial document. See “Section 10.12” for more.
• Use “gbp buildpackage” to build the Debian binary package from the git repository.
– The sbuild package can be used as its clean chroot build backend either by configuration or adding
“--git-builder=’sbuild -A -s --source-only-changes -v -d unstable’”
• Use “gbp pull” to update the debian, upstream and pristine-tar branches safely from the remote repository.
• Use “gbp pq” to manage quilt patches without using dquilt command.
• Use “gbp clone REPOSITORY_URL” to clone and set up tracking branches for debian, upstream and
pristine-tar.
Package history management with the git-buildpackage package is becoming the standard practice for many
Debian maintainers. See more at:
• “Building Debian Packages with git-buildpackage”
• “4 tips to maintain a “3.0 (quilt)” Debian source package in a VCS”
• The systemd packaging practice documentation on “Building from source”
• The workflow mentioned in dgit-maint-gbp(7) which enables to use this gbp with dgit
71
CHAPTER 10. PACKAGING WITH GIT 10.8. NOTE ON DGIT
72
CHAPTER 10. PACKAGING WITH GIT 10.11. GBP IMPORT-DSCS --DEBSNAP
73
CHAPTER 10. PACKAGING WITH GIT 10.13. QUASI-NATIVE DEBIAN PACKAGING
Tip
Some people promote this quasi-native packaging scheme even for programs
written only for Debian since it helps to ease communication with the downstream
distros such as Ubuntu for bug fixes etc.
– For Debian source format “3.0 (quilt)”, removal of files under debian/ directory is an optional action.
The rest is the same as the non-native packaging workflow as written in “Section 6.1”.
Although this can be done in many ways (“Section 15.4”), you can use the Git repository and “git deborig” as:
$ cd /path/to/<dirname>
$ dch -r
... set its <version>-<revision>, e.g., 1.0-1
$ git tag -s debian/1.0-1
$ git rm -rf debian
$ git tag -s upstream/1.0
$ git commit -m upstream/1.0
$ git reset --hard HEAD^
$ git deborig
$ sbuild
74
Chapter 11
Tips
Please also read insightful pages linked from “Notes on Debian” by Russ Allbery (long time Debian developer)
which have best practices for advanced packaging topics.
Use w3m(1) to convert from HTML files to UTF-8 plain text files. When you do this, make sure to execute it
under UTF-8 locale.
$ LC_ALL=C.UTF-8 w3m -o display_charset=UTF-8 \
-cols 70 -dump -no-graph -T text/html \
< foo_in.html > foo_out.txt
75
CHAPTER 11. TIPS 11.3. HINTS FOR DEBUGGING
Tip
Tip
The screen and tmux commands used with the ssh command offer secure and
robust remote connection terminals.
Tip
Tip
The rlwrap and rlfe commands add input line editing capability with history sup-
port to any interactive commands. E.g. “rlwrap dash -i’” .
76
Chapter 12
Tool usages
Note
The description in this section is too terse to be useful for most of the prospective
maintainers. This is the intentional choice of the author. You are highly encour-
aged to search and read all the pertinent documents associated with the com-
mands used.
Note
Examples here use the gz-compression. The xz-compression may be used in-
stead.
12.1 debdiff
You can compare file contents in two source Debian packages with the debdiff command.
$ debdiff old-package.dsc new-package.dsc
You can also compare file lists in two sets of binary Debian packages with the debdiff command.
$ debdiff old-package.changes new-package.changes
These are useful to identify what has been changed in the source packages and to check for inadvertent changes
made when updating binary packages, such as unintentionally misplacing or removing files.
Debian now enforces the source-only upload when developing packages. So there may be 2 different *.changes
files:
• package_version-revision_source.changes for the normal source-only upload
• package_version-revision_arch.changes for the binary upload
12.2 dget
You can download the set of files for the Debian source package with the dget command.
$ dget https://www.example.org/path/to/package_version-rev.dsc
77
CHAPTER 12. TOOL USAGES 12.3. MK-ORIGTARGZ
12.3 mk-origtargz
You can make the upstream tarball ../foo-newversion.tar.[xg]z accessible from the Debian source tree as ../foo_newversion.orig.tar
12.4 origtargz
You can fetch the pre-existing orig tarball of a Debian package from various sources, and unpack it with origtargz
command.
This is basically for -2, -3, … revisions.
12.6 dpkg-source -b
The “dpkg-source -b” command packs the upstream source tree into the Debian source package.
It expects a series of patches in the debian/patches/ directory and their application sequence in debian/patch-
es/series.
It is compatible with dquilt (see “Section 4.4”) operations and understands the the patch application status from
the existance of .pc/applied-patches.
The dpkg-buildpackage command invokes “dpkg-source -b”.
12.7 dpkg-source -x
The “dpkg-source -x” command extracts source tree and applies the patches in the debian/patches/ directory using
the sequence specified in debian/patches/series to the upstream source tree. It also adds .pc/applied-patches. (See
“Section 10.6”.)
The “dpkg-source -x --skip-patches” command extracts source tree only. It doesn’t add .pc/applied-patches.
(See “Section 10.5”.)
Both extracted source trees are ready for building Debian binary packages with dpkg-buildpackage, dbuild,
sbuild, etc..
12.8 debc
You should install generated packages with the debc command to test it locally.
$ debc package_version-rev_arch.changes
12.9 piuparts
You should install generated packages with the piuparts command to test it automatically.
$ sudo piuparts package_version-rev_arch.changes
Note
This is a very slow process with remote APT package repository access.
78
CHAPTER 12. TOOL USAGES 12.10. BTS
12.10 bts
After uploading the package, you will receive bug reports. It is an important duty of a package maintainer to manage
these bugs properly as described in “5.8. Handling bugs” of the “Debian Developer’s Reference”.
The bts command is a handy tool to manage bugs on the “Debian Bug Tracking System”.
$ bts severity 123123 wishlist , tags -1 pending
79
Chapter 13
More Examples
There is an old Latin saying: “fabricando fit faber” (“practice makes perfect”).
It is highly recommended to practice and experiment with all the steps of Debian packaging with simple pack-
ages. This chapter provides you with many upstream cases for your practice.
This should also serve as introductory examples for many programing topics.
• Conversion of a program to use gettext for internationalization and localization: POSIX shell and C sources.
• Overview of many build systems: Makefile, Python, Autotools, and CMake.
Please note that Debian takes a few things seriously:
• Free software (a.k.a. Libre software)
Tip
The best source of a packaging example is the current Debian archive itself.
Please use the “Debian Code Search” service to find pertinent examples.
80
CHAPTER 13. MORE EXAMPLES 13.1. CHERRY-PICK TEMPLATES
$ mkdir debhello-0.1
$ tree
.
+-- debhello-0.1
2 directories, 0 files
81
CHAPTER 13. MORE EXAMPLES 13.2. NO MAKEFILE (SHELL, CLI)
| | +-- format
| | +-- lintian-overrides.ex
| | +-- local-options.ex
| | +-- local-patch-header.ex
| | +-- options.ex
| | +-- patch-header.ex
| +-- tests
| | +-- control
| +-- upstream
| | +-- metadata
| +-- watch
+-- debhello-0.1.tar.gz
+-- debhello_0.1.orig.tar.gz -> debhello-0.1.tar.gz
7 directories, 50 files
Now you can copy any of these generated template files in the debhello-0.1/debian/ directory to your package
as needed while renaming them as needed.
Let’s get this source as tar file from a remote site and make it the Debian package.
Download debhello-0.2.tar.gz
$ wget http://www.example.org/download/debhello-0.2.tar.gz
...
$ tar -xzmf debhello-0.2.tar.gz
$ tree
.
+-- debhello-0.2
| +-- README.md
| +-- data
| | +-- hello.desktop
| | +-- hello.png
| +-- man
| | +-- hello.1
| +-- scripts
| +-- hello
+-- debhello-0.2.tar.gz
5 directories, 6 files
82
CHAPTER 13. MORE EXAMPLES 13.2. NO MAKEFILE (SHELL, CLI)
$ cat debhello-0.2/data/hello.desktop
[Desktop Entry]
Name=Hello
Name[fr]=Bonjour
Comment=Greetings
Comment[fr]=Salutations
Type=Application
Keywords=hello
Exec=hello
Terminal=true
Icon=hello.png
Categories=Utility;
83
CHAPTER 13. MORE EXAMPLES 13.2. NO MAKEFILE (SHELL, CLI)
| | | +-- local-options.ex
| | | +-- local-patch-header.ex
| | +-- tests
| | | +-- control
| | +-- upstream
| | | +-- metadata
| | +-- watch
| +-- man
| | +-- hello.1
| +-- scripts
| +-- hello
+-- debhello-0.2.tar.gz
+-- debhello_0.2.orig.tar.gz -> debhello-0.2.tar.gz
10 directories, 26 files
%:
dh $@
This is essentially the standard debian/rules file with the dh command. Since this is the script package, this
template debian/rules file has no build flag related contents.
debian/control (template file, v=0.2):
$ cat debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Osamu Aoki" <[email protected]>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.2
Homepage: <insert the upstream URL, if relevant>
Rules-Requires-Root: no
#Vcs-Git: https://salsa.debian.org/debian/debhello.git
#Vcs-Browser: https://salsa.debian.org/debian/debhello
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}
Description: auto-generated package by debmake
This Debian binary package was auto-generated by the
debmake(1) command provided by the debmake package.
Since this is the shell script package, the debmake command sets “Architecture: all” and “Multi-Arch: for-
eign”. Also, it sets required substvar parameters as “Depends: ${misc:Depends}”. These are explained in “Chap-
ter 6”.
Since this upstream source lacks the upstream Makefile, that functionality needs to be provided by the main-
tainer. This upstream source contains only a script file and data files and no C source files; the build process can
be skipped but the install process needs to be implemented. For this case, this is achieved cleanly by adding the
debian/install and debian/manpages files without complicating the debian/rules file.
Let’s make this Debian package better as the maintainer.
debian/rules (maintainer version, v=0.2):
$ cd /path/to/debhello-0.2
$ vim debian/rules
... hack, hack, hack, ...
$ cat debian/rules
84
CHAPTER 13. MORE EXAMPLES 13.2. NO MAKEFILE (SHELL, CLI)
#!/usr/bin/make -f
export DH_VERBOSE = 1
%:
dh $@
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}
Description: Simple packaging example for debmake
This Debian binary package is an example package.
(This is an example only)
Warning
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=0.2):
$ rm -f debian/clean debian/dirs debian/links
$ rm -f debian/README.source debian/source/*.ex
$ rm -rf debian/patches
$ tree -F debian
debian/
+-- README.Debian
+-- changelog
+-- control
+-- copyright
+-- gbp.conf
85
CHAPTER 13. MORE EXAMPLES 13.2. NO MAKEFILE (SHELL, CLI)
+-- install
+-- manpages
+-- rules*
+-- salsa-ci.yml
+-- source/
| +-- format
+-- tests/
| +-- control
+-- upstream/
| +-- metadata
+-- watch
4 directories, 13 files
You can create a non-native Debian package using the debuild command (or its equivalents) in this source tree.
The command output is very verbose and explains what it does as follows.
$ cd /path/to/debhello-0.2
$ debuild
dpkg-buildpackage -us -uc -ui -i
dpkg-buildpackage: info: source package debhello
dpkg-buildpackage: info: source version 0.2-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Osamu Aoki <[email protected]>
dpkg-source -i --before-build .
dpkg-buildpackage: info: host architecture amd64
debian/rules clean
dh clean
dh_clean
rm -f debian/debhelper-build-stamp
...
debian/rules binary
dh binary
dh_update_autotools_config
dh_autoreconf
create-stamp debian/debhelper-build-stamp
dh_prep
rm -f -- debian/debhello.substvars
rm -fr -- debian/.debhelper/generated/debhello/ debian/debhello/ debi...
dh_auto_install --destdir=debian/debhello/
...
Finished running lintian.
2 directories, 8 files
86
CHAPTER 13. MORE EXAMPLES 13.2. NO MAKEFILE (SHELL, CLI)
• The debhello_0.2-1.dsc file is the meta data file for the Debian source package.
• The debhello_0.2-1_all.deb file is the Debian binary package.
• The debhello_0.2-1_amd64.build file is the build log file.
• The debhello_0.2-1_amd64.buildinfo file is the meta data file generated by dpkg-genbuildinfo(1).
• The debhello_0.2-1_amd64.changes file is the meta data file for the Debian binary package.
The debhello_0.2-1.debian.tar.xz file contains the Debian changes to the upstream source as follows.
The compressed archive contents of debhello_0.2-1.debian.tar.xz:
$ tar -tzf debhello-0.2.tar.gz
debhello-0.2/
debhello-0.2/data/
debhello-0.2/data/hello.desktop
debhello-0.2/data/hello.png
debhello-0.2/man/
debhello-0.2/man/hello.1
debhello-0.2/scripts/
debhello-0.2/scripts/hello
debhello-0.2/README.md
$ tar --xz -tf debhello_0.2-1.debian.tar.xz
debian/
debian/README.Debian
debian/changelog
debian/control
debian/copyright
debian/gbp.conf
debian/install
debian/manpages
debian/rules
debian/salsa-ci.yml
debian/source/
debian/source/format
debian/tests/
debian/tests/control
debian/upstream/
debian/upstream/metadata
debian/watch
87
CHAPTER 13. MORE EXAMPLES 13.3. MAKEFILE (SHELL, CLI)
(No extra dependency packages required since this is a POSIX shell program.)
Note
If you wish to replace upstream provided PNG file data/hello.png with main-
tainer provided one debian/hello.png, editing debian/install isn’t enough. When
you add debian/hello.png, you need to add a line “include-binaries” to debian/-
source/options since PNG is a binary file. See dpkg-source(1).
Debian packaging requires changing this “make install” process to install files to the target system image
location instead of the normal location under /usr/local.
Let’s get the source and make the Debian package.
Download debhello-1.0.tar.gz
$ wget http://www.example.org/download/debhello-1.0.tar.gz
...
$ tar -xzmf debhello-1.0.tar.gz
$ tree
.
+-- debhello-1.0
| +-- Makefile
| +-- README.md
| +-- data
| | +-- hello.desktop
| | +-- hello.png
| +-- man
| | +-- hello.1
| +-- scripts
| +-- hello
+-- debhello-1.0.tar.gz
5 directories, 7 files
Here, the Makefile uses $(DESTDIR) and $(prefix) properly. All other files are the same as in “Section 13.2”
and most of the packaging activities are the same.
Makefile (v=1.0)
$ cat debhello-1.0/Makefile
prefix = /usr/local
all:
: # do nothing
install:
install -D scripts/hello \
$(DESTDIR)$(prefix)/bin/hello
88
CHAPTER 13. MORE EXAMPLES 13.3. MAKEFILE (SHELL, CLI)
clean:
: # do nothing
distclean: clean
uninstall:
-rm -f $(DESTDIR)$(prefix)/bin/hello
-rm -f $(DESTDIR)$(prefix)/share/applications/hello.desktop
-rm -f $(DESTDIR)$(prefix)/share/pixmaps/hello.png
-rm -f $(DESTDIR)$(prefix)/share/man/man1/hello.1
Let’s package this with the debmake command. Here, the -b’:sh’ option is used to specify that the generated
binary package is a shell script.
$ cd /path/to/debhello-1.0
$ debmake -b':sh' -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="1.0", rev="1"
I: *** start packaging in "debhello-1.0". ***
I: provide debhello_1.0.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.0.tar.gz debhello_1.0.orig.tar.gz
I: pwd = "/path/to/debhello-1.0"
I: parse binary package settings: :sh
I: binary package=debhello Type=script / Arch=all M-A=foreign
I: analyze the source tree
I: build_type = make
I: scan source for copyright+license text and file extensions
I: 25 %, ext = md
...
%:
dh $@
#override_dh_auto_install:
# dh_auto_install -- prefix=/usr
#override_dh_install:
# dh_install --list-missing -X.pyc -X.pyo
89
CHAPTER 13. MORE EXAMPLES 13.4. PYPROJECT.TOML (PYTHON3, CLI)
%:
dh $@
override_dh_auto_install:
dh_auto_install -- prefix=/usr
Since this upstream source has the proper upstream Makefile, there is no need to create debian/install and
debian/manpages files.
The debian/control file is exactly the same as the one in “Section 13.2”.
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=1.0):
$ rm -f debian/clean debian/dirs debian/install debian/links
$ rm -f debian/README.source debian/source/*.ex
$ rm -rf debian/patches
$ tree -F debian
debian/
+-- README.Debian
+-- changelog
+-- control
+-- copyright
+-- gbp.conf
+-- rules*
+-- salsa-ci.yml
+-- source/
| +-- format
+-- tests/
| +-- control
+-- upstream/
| +-- metadata
+-- watch
4 directories, 11 files
The rest of the packaging activities are practically the same as the ones in “Section 13.2”.
90
CHAPTER 13. MORE EXAMPLES 13.4. PYPROJECT.TOML (PYTHON3, CLI)
| +-- debhello
| +-- __init__.py
| +-- main.py
+-- debhello-1.1.tar.gz
6 directories, 10 files
[project]
name = "debhello"
version = "1.1.0"
description = "Hello Python (CLI)"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.12"
license = {file = "LICENSE.txt"}
keywords = ["debhello"]
authors = [
{name = "Osamu Aoki", email = "[email protected]" },
]
maintainers = [
{name = "Osamu Aoki", email = "[email protected]" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: System :: Archiving :: Packaging",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
# Others
"Operating System :: POSIX :: Linux",
"Natural Language :: English",
]
[project.urls]
"Homepage" = "https://salsa.debian.org/debian/debmake"
"Bug Reports" = "https://salsa.debian.org/debian/debmake/issues"
"Source" = "https://salsa.debian.org/debian/debmake"
[project.scripts]
hello = "debhello.main:main"
[tool.setuptools]
package-dir = {"" = "src"}
packages = ["debhello"]
include-package-data = true
src/debhello/__init__.py (v=1.1)
$ cat debhello-1.1/src/debhello/__init__.py
"""
debhello program (CLI)
"""
91
CHAPTER 13. MORE EXAMPLES 13.4. PYPROJECT.TOML (PYTHON3, CLI)
$ cat debhello-1.1/src/debhello/main.py
"""
debhello program
"""
import sys
__version__ = '1.1.0'
if __name__ == "__main__":
sys.exit(main())
Let’s package this with the debmake command. Here, the -b’:py3’ option is used to specify the generated
binary package containing Python3 script and module files.
$ cd /path/to/debhello-1.1
$ debmake -b':py3' -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="1.1", rev="1"
I: *** start packaging in "debhello-1.1". ***
I: provide debhello_1.1.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.1.tar.gz debhello_1.1.orig.tar.gz
I: pwd = "/path/to/debhello-1.1"
I: parse binary package settings: :py3
I: binary package=debhello Type=python3 / Arch=all M-A=foreign
I: analyze the source tree
W: setuptools build system.
I: build_type = Python (pyproject.toml: PEP-518, PEP-621, PEP-660)
I: scan source for copyright+license text and file extensions
...
%:
dh $@ --with python3 --buildsystem=pybuild
92
CHAPTER 13. MORE EXAMPLES 13.4. PYPROJECT.TOML (PYTHON3, CLI)
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}, ${python3:Depends}
Description: auto-generated package by debmake
This Debian binary package was auto-generated by the
debmake(1) command provided by the debmake package.
Since this is the Python3 package, the debmake command sets “Architecture: all” and “Multi-Arch: for-
eign”. Also, it sets required substvar parameters as “Depends: ${python3:Depends}, ${misc:Depends}”. These
are explained in “Chapter 6”.
Let’s make this Debian package better as the maintainer.
debian/rules (maintainer version, v=1.1):
$ cd /path/to/debhello-1.1
$ vim debian/rules
... hack, hack, hack, ...
$ cat debian/rules
#!/usr/bin/make -f
export PYBUILD_NAME=debhello
export PYBUILD_VERBOSE=1
export DH_VERBOSE=1
%:
dh $@ --with python3 --buildsystem=pybuild
Package: debhello
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}
Description: Simple packaging example for debmake
This is an example package to demonstrate Debian packaging using
the debmake command.
.
The generated Debian package uses the dh command offered by the
debhelper package and the dpkg source format `3.0 (quilt)'.
93
CHAPTER 13. MORE EXAMPLES 13.4. PYPROJECT.TOML (PYTHON3, CLI)
There are several other template files under the debian/ directory. These also need to be updated.
This debhello command comes with the upstream-provided manpage and desktop file but the upstream pypro-
ject.toml doesn’t install them. So you need to update debian/install and debian/manpages as follows:
debian/install (maintainer version, v=1.1):
$ vim debian/copyright
... hack, hack, hack, ...
$ cat debian/copyright
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: debhello
Upstream-Contact: Osamu Aoki <[email protected]>
Source: https://salsa.debian.org/debian/debmake-doc
Files: *
Copyright: 2015-2024 Osamu Aoki <[email protected]>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The rest of the packaging activities are practically the same as the ones in “Section 13.3”.
Template files under debian/. (v=1.1):
$ rm -f debian/clean debian/dirs debian/links
$ rm -f debian/README.source debian/source/*.ex
$ rm -rf debian/patches
$ tree -F debian
debian/
+-- README.Debian
+-- changelog
+-- control
+-- copyright
+-- gbp.conf
+-- install
+-- manpages
+-- rules*
+-- salsa-ci.yml
+-- source/
| +-- format
+-- tests/
| +-- control
+-- upstream/
| +-- metadata
94
CHAPTER 13. MORE EXAMPLES 13.5. MAKEFILE (SHELL, GUI)
+-- watch
4 directories, 13 files
5 directories, 7 files
Here, the hello has been re-written to use the zenity command to make this a GTK+ GUI program.
hello (v=1.2)
$ cat debhello-1.2/scripts/hello
#!/bin/sh -e
zenity --info --title "hello" --text "Hello from the shell!"
95
CHAPTER 13. MORE EXAMPLES 13.5. MAKEFILE (SHELL, GUI)
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}
Description: auto-generated package by debmake
This Debian binary package was auto-generated by the
debmake(1) command provided by the debmake package.
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: zenity, ${misc:Depends}
96
CHAPTER 13. MORE EXAMPLES 13.6. PYPROJECT.TOML (PYTHON3, GUI)
4 directories, 11 files
The rest of the packaging activities are practically the same as in “Section 13.3”.
Here is the generated dependency list of debhello_1.2-1_all.deb.
The generated dependency list of debhello_1.2-1_all.deb:
$ dpkg -f debhello_1.2-1_all.deb pre-depends \
depends recommends conflicts breaks
Depends: zenity
97
CHAPTER 13. MORE EXAMPLES 13.6. PYPROJECT.TOML (PYTHON3, GUI)
| +-- __init__.py
| +-- main.py
+-- debhello-1.3.tar.gz
6 directories, 10 files
[project]
name = "debhello"
version = "1.3.0"
description = "Hello Python (GUI)"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.12"
license = {file = "LICENSE.txt"}
keywords = ["debhello"]
authors = [
{name = "Osamu Aoki", email = "[email protected]" },
]
maintainers = [
{name = "Osamu Aoki", email = "[email protected]" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: System :: Archiving :: Packaging",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
# Others
"Operating System :: POSIX :: Linux",
"Natural Language :: English",
]
[project.urls]
"Homepage" = "https://salsa.debian.org/debian/debmake"
"Bug Reports" = "https://salsa.debian.org/debian/debmake/issues"
"Source" = "https://salsa.debian.org/debian/debmake"
[project.scripts]
hello = "debhello.main:main"
[tool.setuptools]
package-dir = {"" = "src"}
packages = ["debhello"]
include-package-data = true
src/debhello/__init__.py (v=1.3)
$ cat debhello-1.3/src/debhello/__init__.py
"""
debhello program (GUI)
"""
98
CHAPTER 13. MORE EXAMPLES 13.6. PYPROJECT.TOML (PYTHON3, GUI)
$ cat debhello-1.3/src/debhello/main.py
#!/usr/bin/python3
from gi.repository import Gtk
__version__ = '1.3.0'
class TopWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.title = "Hello World!"
self.counter = 0
self.border_width = 10
self.set_default_size(400, 100)
self.set_position(Gtk.WindowPosition.CENTER)
self.button = Gtk.Button(label="Click me!")
self.button.connect("clicked", self.on_button_clicked)
self.add(self.button)
self.connect("delete-event", self.on_window_destroy)
def main():
window = TopWindow()
window.show_all()
Gtk.main()
if __name__ == '__main__':
main()
Let’s package this with the debmake command. Here, the -b’:py3’ option is used to specify that the generated
binary package contains Python3 script and module files.
$ cd /path/to/debhello-1.3
$ debmake -b':py3' -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="1.3", rev="1"
I: *** start packaging in "debhello-1.3". ***
I: provide debhello_1.3.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.3.tar.gz debhello_1.3.orig.tar.gz
I: pwd = "/path/to/debhello-1.3"
I: parse binary package settings: :py3
I: binary package=debhello Type=python3 / Arch=all M-A=foreign
I: analyze the source tree
W: setuptools build system.
I: build_type = Python (pyproject.toml: PEP-518, PEP-621, PEP-660)
I: scan source for copyright+license text and file extensions
...
99
CHAPTER 13. MORE EXAMPLES 13.7. MAKEFILE (SINGLE-BINARY PACKAGE)
$ cat debian/rules
#!/usr/bin/make -f
export PYBUILD_NAME=debhello
export PYBUILD_VERBOSE=1
export DH_VERBOSE=1
%:
dh $@ --with python3 --buildsystem=pybuild
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: gir1.2-gtk-3.0, python3-gi, ${misc:Depends}, ${python3:Depends}
Description: Simple packaging example for debmake
This Debian binary package is an example package.
(This is an example only)
Debian packaging requires changing this “make install” process to install files into the target system image
location instead of the normal location under /usr/local.
Let’s get the source and make the Debian package.
Download debhello-1.4.tar.gz
$ wget http://www.example.org/download/debhello-1.4.tar.gz
...
100
CHAPTER 13. MORE EXAMPLES 13.7. MAKEFILE (SINGLE-BINARY PACKAGE)
5 directories, 9 files
src/config.h (v=1.4):
$ cat debhello-1.4/Makefile
prefix = /usr/local
all: src/hello
src/hello: src/hello.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm
install: src/hello
install -D src/hello \
$(DESTDIR)$(prefix)/bin/hello
install -m 644 -D data/hello.desktop \
$(DESTDIR)$(prefix)/share/applications/hello.desktop
install -m 644 -D data/hello.png \
$(DESTDIR)$(prefix)/share/pixmaps/hello.png
install -m 644 -D man/hello.1 \
$(DESTDIR)$(prefix)/share/man/man1/hello.1
clean:
-rm -f src/hello
distclean: clean
uninstall:
-rm -f $(DESTDIR)$(prefix)/bin/hello
-rm -f $(DESTDIR)$(prefix)/share/applications/hello.desktop
-rm -f $(DESTDIR)$(prefix)/share/pixmaps/hello.png
-rm -f $(DESTDIR)$(prefix)/share/man/man1/hello.1
101
CHAPTER 13. MORE EXAMPLES 13.7. MAKEFILE (SINGLE-BINARY PACKAGE)
Makefile (v=1.4):
$ cat debhello-1.4/src/config.h
#define PACKAGE_AUTHOR "Osamu Aoki"
Please note that this Makefile has the proper install target for the manpage, the desktop file, and the desktop
icon.
Let’s package this with the debmake command.
$ cd /path/to/debhello-1.4
$ debmake -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="1.4", rev="1"
I: *** start packaging in "debhello-1.4". ***
I: provide debhello_1.4.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.4.tar.gz debhello_1.4.orig.tar.gz
I: pwd = "/path/to/debhello-1.4"
I: parse binary package settings:
I: binary package=debhello Type=bin / Arch=any M-A=foreign
I: analyze the source tree
I: build_type = make
I: scan source for copyright+license text and file extensions
I: 33 %, ext = c
...
4 directories, 12 files
The rest of the packaging activities are practically the same as the one in “Section 5.8”.
Here is the generated dependency list of all binary packages.
The generated dependency list of all binary packages (v=1.4):
102
CHAPTER 13. MORE EXAMPLES 13.8. MAKEFILE.IN + CONFIGURE …
5 directories, 9 files
103
CHAPTER 13. MORE EXAMPLES 13.8. MAKEFILE.IN + CONFIGURE …
#else
printf("I can't do MATH!\n");
#endif
return 0;
}
Makefile.in (v=1.5):
$ cat debhello-1.5/Makefile.in
prefix = @prefix@
all: src/hello
src/hello: src/hello.c
$(CC) @VERBOSE@ \
$(CPPFLAGS) \
$(CFLAGS) \
$(LDFLAGS) \
-o $@ $^ \
@LINKLIB@
install: src/hello
install -D src/hello \
$(DESTDIR)$(prefix)/bin/hello
install -m 644 -D data/hello.desktop \
$(DESTDIR)$(prefix)/share/applications/hello.desktop
install -m 644 -D data/hello.png \
$(DESTDIR)$(prefix)/share/pixmaps/hello.png
install -m 644 -D man/hello.1 \
$(DESTDIR)$(prefix)/share/man/man1/hello.1
clean:
-rm -f src/hello
distclean: clean
uninstall:
-rm -f $(DESTDIR)$(prefix)/bin/hello
-rm -f $(DESTDIR)$(prefix)/share/applications/hello.desktop
-rm -f $(DESTDIR)$(prefix)/share/pixmaps/hello.png
-rm -f $(DESTDIR)$(prefix)/share/man/man1/hello.1
configure (v=1.5):
$ cat debhello-1.5/configure
#!/bin/sh -e
# default values
PREFIX="/usr/local"
VERBOSE=""
WITH_MATH="0"
LINKLIB=""
PACKAGE_AUTHOR="John Doe"
# parse arguments
while [ "${1}" != "" ]; do
VAR="${1%=*}" # Drop suffix =*
VAL="${1#*=}" # Drop prefix *=
case "${VAR}" in
--prefix)
PREFIX="${VAL}"
;;
--verbose|-v)
VERBOSE="-v"
104
CHAPTER 13. MORE EXAMPLES 13.8. MAKEFILE.IN + CONFIGURE …
;;
--with-math)
WITH_MATH="1"
LINKLIB="-lm"
;;
--author)
PACKAGE_AUTHOR="${VAL}"
;;
*)
echo "W: Unknown argument: ${1}"
esac
shift
done
Please note that the configure command replaces strings with @…@ in Makefile.in to produce Makefile and
creates src/config.h.
Let’s package this with the debmake command.
$ cd /path/to/debhello-1.5
$ debmake -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="1.5", rev="1"
I: *** start packaging in "debhello-1.5". ***
I: provide debhello_1.5.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.5.tar.gz debhello_1.5.orig.tar.gz
I: pwd = "/path/to/debhello-1.5"
I: parse binary package settings:
I: binary package=debhello Type=bin / Arch=any M-A=foreign
I: analyze the source tree
I: build_type = configure
I: scan source for copyright+license text and file extensions
I: 17 %, ext = in
...
The result is similar to “Section 5.6” but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=1.5):
$ cd /path/to/debhello-1.5
$ cat debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1
%:
dh $@
105
CHAPTER 13. MORE EXAMPLES 13.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
%:
dh $@
override_dh_auto_configure:
dh_auto_configure -- \
--with-math \
--author="Osamu Aoki"
There are several other template files under the debian/ directory. These also need to be updated.
The rest of the packaging activities are practically the same as the one in “Section 5.8”.
106
CHAPTER 13. MORE EXAMPLES 13.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
| +-- src
| +-- Makefile.am
| +-- hello.c
+-- debhello-1.6.tar.gz
5 directories, 11 files
Makefile.am (v=1.6):
$ cat debhello-1.6/Makefile.am
SUBDIRS = src man
$ cat debhello-1.6/man/Makefile.am
dist_man_MANS = hello.1
$ cat debhello-1.6/src/Makefile.am
bin_PROGRAMS = hello
hello_SOURCES = hello.c
configure.ac (v=1.6):
$ cat debhello-1.6/configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([debhello],[2.1],[[email protected]])
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADERS([config.h])
echo "Standard customization chores"
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
# Add #define PACKAGE_AUTHOR ... in config.h with a comment
AC_DEFINE(PACKAGE_AUTHOR, ["Osamu Aoki"], [Define PACKAGE_AUTHOR])
echo "Add --with-math option functionality to ./configure"
AC_ARG_WITH([math],
[AS_HELP_STRING([--with-math],
[compile with math library @<:@default=yes@:>@])],
[],
[with_math="yes"]
)
echo "==== withval := \"$withval\""
echo "==== with_math := \"$with_math\""
# m4sh if-else construct
AS_IF([test "x$with_math" != "xno"],[
echo "==== Check include: math.h"
AC_CHECK_HEADER(math.h,[],[
AC_MSG_ERROR([Couldn't find math.h.] )
107
CHAPTER 13. MORE EXAMPLES 13.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
])
echo "==== Check library: libm"
AC_SEARCH_LIBS(atan, [m])
#AC_CHECK_LIB(m, atan)
echo "==== Build with LIBS := \"$LIBS\""
AC_DEFINE(WITH_MATH, [1], [Build with the math library])
],[
echo "==== Skip building with math.h."
AH_TEMPLATE(WITH_MATH, [Build without the math library])
])
# Checks for programs.
AC_PROG_CC
AC_CONFIG_FILES([Makefile
man/Makefile
src/Makefile])
AC_OUTPUT
Tip
The result is similar to “Section 13.8” but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=1.6):
$ cd /path/to/debhello-1.6
$ cat debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1
%:
dh $@ --with autoreconf
#override_dh_install:
108
CHAPTER 13. MORE EXAMPLES 13.10. CMAKE (SINGLE-BINARY PACKAGE)
%:
dh $@ --with autoreconf
override_dh_auto_configure:
dh_auto_configure -- \
--with-math
There are several other template files under the debian/ directory. These also need to be updated.
The rest of the packaging activities are practically the same as the one in “Section 5.8”.
109
CHAPTER 13. MORE EXAMPLES 13.10. CMAKE (SINGLE-BINARY PACKAGE)
| +-- hello.c
+-- debhello-1.7.tar.gz
5 directories, 11 files
src/config.h.in (v=1.7):
$ cat debhello-1.7/src/config.h.in
/* name of the package author */
#define PACKAGE_AUTHOR "@PACKAGE_AUTHOR@"
/* math library support */
#cmakedefine WITH_MATH
CMakeLists.txt (v=1.7):
$ cat debhello-1.7/CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(debhello)
set(PACKAGE_AUTHOR "Osamu Aoki")
add_subdirectory(src)
add_subdirectory(man)
$ cat debhello-1.7/man/CMakeLists.txt
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/hello.1
DESTINATION share/man/man1
)
$ cat debhello-1.7/src/CMakeLists.txt
# Always define HAVE_CONFIG_H
add_definitions(-DHAVE_CONFIG_H)
# Interactively define WITH_MATH
option(WITH_MATH "Build with math support" OFF)
#variable_watch(WITH_MATH)
# Generate config.h from config.h.in
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h"
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_executable(hello hello.c)
install(TARGETS hello
RUNTIME DESTINATION bin
)
110
CHAPTER 13. MORE EXAMPLES 13.10. CMAKE (SINGLE-BINARY PACKAGE)
$ cd /path/to/debhello-1.7
$ debmake -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="1.7", rev="1"
I: *** start packaging in "debhello-1.7". ***
I: provide debhello_1.7.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.7.tar.gz debhello_1.7.orig.tar.gz
I: pwd = "/path/to/debhello-1.7"
I: parse binary package settings:
I: binary package=debhello Type=bin / Arch=any M-A=foreign
I: analyze the source tree
I: build_type = Cmake
I: scan source for copyright+license text and file extensions
I: 33 %, ext = text
...
The result is similar to “Section 13.8” but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=1.7):
$ cd /path/to/debhello-1.7
$ cat debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1
%:
dh $@
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_TARGET_MULTIARCH)"
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: auto-generated package by debmake
This Debian binary package was auto-generated by the
debmake(1) command provided by the debmake package.
111
CHAPTER 13. MORE EXAMPLES 13.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
$ vim debian/rules
... hack, hack, hack, ...
$ cat debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@
override_dh_auto_configure:
dh_auto_configure -- -DWITH-MATH=1
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: Simple packaging example for debmake
This Debian binary package is an example package.
(This is an example only)
There are several other template files under the debian/ directory. These also need to be updated.
The rest of the packaging activities are practically the same as the one in “Section 13.8”.
112
CHAPTER 13. MORE EXAMPLES 13.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
.
+-- debhello-2.0
| +-- LICENSE
| +-- Makefile.am
| +-- README.md
| +-- configure.ac
| +-- data
| | +-- hello.desktop
| | +-- hello.png
| +-- lib
| | +-- Makefile.am
| | +-- sharedlib.c
| | +-- sharedlib.h
| +-- man
| | +-- Makefile.am
| | +-- hello.1
| +-- src
| +-- Makefile.am
| +-- hello.c
+-- debhello-2.0.tar.gz
6 directories, 14 files
Makefile.am (v=2.0):
$ cat debhello-2.0/Makefile.am
# recursively process `Makefile.am` in SUBDIRS
SUBDIRS = lib src man
$ cat debhello-2.0/man/Makefile.am
# manpages (distributed in the source package)
dist_man_MANS = hello.1
$ cat debhello-2.0/lib/Makefile.am
# libtool librares to be produced
lib_LTLIBRARIES = libsharedlib.la
113
CHAPTER 13. MORE EXAMPLES 13.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
configure.ac (v=2.0):
$ cat debhello-2.0/configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([debhello],[2.2],[[email protected]])
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADERS([config.h])
echo "Standard customization chores"
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
# choose one
LTDL_INIT([recursive])
#LTDL_INIT([subproject])
#LTDL_INIT([nonrecursive])
Let’s package this with the debmake command into multiple packages:
• debhello: type = bin
• libsharedlib1: type = lib
114
CHAPTER 13. MORE EXAMPLES 13.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
Here, the -b\’,libsharedlib1,libsharedlib-dev’ option is used to specify the generated binary packages.
$ cd /path/to/debhello-2.0
$ debmake -b',libsharedlib1,libsharedlib-dev' -x1
I: set parameters
...
I: sanity check of parameters
I: pkg="debhello", ver="2.0", rev="1"
I: *** start packaging in "debhello-2.0". ***
I: provide debhello_2.0.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-2.0.tar.gz debhello_2.0.orig.tar.gz
I: pwd = "/path/to/debhello-2.0"
I: parse binary package settings: ,libsharedlib1,libsharedlib-dev
I: binary package=debhello Type=bin / Arch=any M-A=foreign
I: binary package=libsharedlib1 Type=lib / Arch=any M-A=same
I: binary package=libsharedlib-dev Type=dev / Arch=any M-A=same
I: analyze the source tree
I: build_type = Autotools with autoreconf
...
The result is similar to “Section 13.8” but with more template files.
Let’s inspect the notable template files generated.
debian/rules (template file, v=2.0):
$ cd /path/to/debhello-2.0
$ cat debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1
%:
dh $@ --with autoreconf
#override_dh_install:
# dh_install --list-missing -X.la -X.pyc -X.pyo
%:
dh $@ --with autoreconf
override_dh_missing:
dh_missing -X.la
115
CHAPTER 13. MORE EXAMPLES 13.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper-compat (= 13), dh-autoreconf
Standards-Version: 4.6.2
Homepage: https://salsa.debian.org/debian/debmake-doc
Rules-Requires-Root: no
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: libsharedlib1 (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Description: Simple packaging example for debmake
This package contains the compiled binary executable.
.
This Debian binary package is an example package.
(This is an example only)
Package: libsharedlib1
Section: libs
Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: Simple packaging example for debmake
This package contains the shared library.
Package: libsharedlib-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libsharedlib1 (= ${binary:Version}), ${misc:Depends}
Description: Simple packaging example for debmake
This package contains the development files.
Files: *
Copyright: 2015-2021 Osamu Aoki <[email protected]>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
116
CHAPTER 13. MORE EXAMPLES 13.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
Since this upstream source creates the proper auto-generated Makefile, there is no need to create debian/install
and debian/manpages files.
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=2.0):
$ rm -f debian/clean debian/dirs debian/install debian/links
$ rm -f debian/README.source debian/source/*.ex
$ rm -rf debian/patches
$ tree -F debian
debian/
+-- README.Debian
+-- changelog
+-- control
+-- copyright
+-- debhello.dirs
+-- debhello.doc-base
+-- debhello.docs
+-- debhello.examples
+-- debhello.info
+-- debhello.install
+-- debhello.links
+-- debhello.manpages
+-- gbp.conf
+-- libsharedlib-dev.install
+-- libsharedlib1.install
+-- libsharedlib1.symbols
+-- rules*
+-- salsa-ci.yml
+-- source/
| +-- format
+-- tests/
| +-- control
+-- upstream/
| +-- metadata
+-- watch
4 directories, 22 files
The rest of the packaging activities are practically the same as the one in “Section 13.8”.
Here are the generated dependency list of all binary packages.
The generated dependency list of all binary packages (v=2.0):
$ dpkg -f debhello-dbgsym_2.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: debhello (= 2.0-1)
$ dpkg -f debhello_2.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libsharedlib1 (= 2.0-1), libc6 (>= 2.34)
$ dpkg -f libsharedlib-dev_2.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libsharedlib1 (= 2.0-1)
$ dpkg -f libsharedlib1-dbgsym_2.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libsharedlib1 (= 2.0-1)
$ dpkg -f libsharedlib1_2.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libc6 (>= 2.2.5)
117
CHAPTER 13. MORE EXAMPLES 13.12. CMAKE (MULTI-BINARY PACKAGE)
6 directories, 14 files
src/config.h.in (v=2.1):
$ cat debhello-2.1/src/config.h.in
/* name of the package author */
#define PACKAGE_AUTHOR "@PACKAGE_AUTHOR@"
118
CHAPTER 13. MORE EXAMPLES 13.12. CMAKE (MULTI-BINARY PACKAGE)
CMakeLists.txt (v=2.1):
$ cat debhello-2.1/CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(debhello)
set(PACKAGE_AUTHOR "Osamu Aoki")
add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(man)
$ cat debhello-2.1/man/CMakeLists.txt
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/hello.1
DESTINATION share/man/man1
)
$ cat debhello-2.1/src/CMakeLists.txt
# Always define HAVE_CONFIG_H
add_definitions(-DHAVE_CONFIG_H)
# Generate config.h from config.h.in
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h"
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_SOURCE_DIR}/lib")
add_executable(hello hello.c)
target_link_libraries(hello sharedlib)
install(TARGETS hello
RUNTIME DESTINATION bin
)
The result is similar to “Section 13.8” but not exactly the same.
119
CHAPTER 13. MORE EXAMPLES 13.12. CMAKE (MULTI-BINARY PACKAGE)
%:
dh $@
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_TARGET_MULTIARCH)"
%:
dh $@
override_dh_auto_configure:
dh_auto_configure -- \
-DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_HOST_MULTIARCH)"
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: libsharedlib1 (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Description: Simple packaging example for debmake
This package contains the compiled binary executable.
.
This Debian binary package is an example package.
(This is an example only)
120
CHAPTER 13. MORE EXAMPLES 13.12. CMAKE (MULTI-BINARY PACKAGE)
Package: libsharedlib1
Section: libs
Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: Simple packaging example for debmake
This package contains the shared library.
Package: libsharedlib-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libsharedlib1 (= ${binary:Version}), ${misc:Depends}
Description: Simple packaging example for debmake
This package contains the development files.
Files: *
Copyright: 2015-2021 Osamu Aoki <[email protected]>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This upstream CMakeList.txt needs to be patched to cope with the multiarch path.
debian/patches/* (maintainer version, v=2.1):
... hack, hack, hack, ...
$ cat debian/libsharedlib1.symbols
libsharedlib.so.1 libsharedlib1 #MINVER#
sharedlib@Base 2.1
Since this upstream source creates the proper auto-generated Makefile, there is no need to create debian/install
and debian/manpages files.
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=2.1):
$ rm -f debian/clean debian/dirs debian/install debian/links
$ rm -f debian/README.source debian/source/*.ex
$ tree -F debian
121
CHAPTER 13. MORE EXAMPLES 13.13. INTERNATIONALIZATION
debian/
+-- README.Debian
+-- changelog
+-- control
+-- copyright
+-- debhello.dirs
+-- debhello.doc-base
+-- debhello.docs
+-- debhello.examples
+-- debhello.info
+-- debhello.install
+-- debhello.links
+-- debhello.manpages
+-- gbp.conf
+-- libsharedlib-dev.install
+-- libsharedlib1.install
+-- libsharedlib1.symbols
+-- patches/
| +-- 000-cmake-multiarch.patch
| +-- series
+-- rules*
+-- salsa-ci.yml
+-- source/
| +-- format
+-- tests/
| +-- control
+-- upstream/
| +-- metadata
+-- watch
5 directories, 24 files
The rest of the packaging activities are practically the same as the one in “Section 13.8”.
Here are the generated dependency list of all binary packages.
The generated dependency list of all binary packages (v=2.1):
$ dpkg -f debhello-dbgsym_2.1-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: debhello (= 2.1-1)
$ dpkg -f debhello_2.1-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libsharedlib1 (= 2.1-1), libc6 (>= 2.34)
$ dpkg -f libsharedlib-dev_2.1-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libsharedlib1 (= 2.1-1)
$ dpkg -f libsharedlib1-dbgsym_2.1-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libsharedlib1 (= 2.1-1)
$ dpkg -f libsharedlib1_2.1-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libc6 (>= 2.2.5)
13.13 Internationalization
Here is an example of updating the simple upstream C source debhello-2.0.tar.gz presented in “Section 13.11” for
internationalization (i18n) and creating the updated upstream C source debhello-2.0.tar.gz.
In the real situation, the package should already be internationalized. So this example is educational for you to
understand how this internationalization is implemented.
122
CHAPTER 13. MORE EXAMPLES 13.13. INTERNATIONALIZATION
Tip
The routine maintainer activity for the i18n is simply to add translation po files
reported to you via the Bug Tracking System (BTS) to the po/ directory and to
update the language list in the po/LINGUAS file.
6 directories, 14 files
Internationalize this source tree with the gettextize command and remove files auto-generated by Autotools.
run gettextize (i18n):
$ cd /path/to/debhello-2.0
$ gettextize
Creating po/ subdirectory
Creating build-aux/ subdirectory
Copying file ABOUT-NLS
Copying file build-aux/config.rpath
Not copying intl/ directory.
Copying file po/Makefile.in.in
Copying file po/Makevars.template
Copying file po/Rules-quot
Copying file po/boldquot.sed
Copying file po/[email protected]
Copying file po/[email protected]
Copying file po/insert-header.sin
Copying file po/quot.sed
Copying file po/remove-potcdate.sin
Creating initial po/POTFILES.in
Creating po/ChangeLog
Creating directory m4
Copying file m4/gettext.m4
Copying file m4/iconv.m4
Copying file m4/lib-ld.m4
Copying file m4/lib-link.m4
Copying file m4/lib-prefix.m4
123
CHAPTER 13. MORE EXAMPLES 13.13. INTERNATIONALIZATION
You will also need config.guess and config.sub, which you can get from the CV...
of the 'config' project at http://savannah.gnu.org/. The commands to fetch th...
are
$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/conf...
$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/conf...
You might also want to copy the convenience header file gettext.h
from the /usr/share/gettext directory into your package.
It is a wrapper around <libintl.h> that implements the configure --disable-nl...
option.
124
CHAPTER 13. MORE EXAMPLES 13.13. INTERNATIONALIZATION
AM_INIT_AUTOMAKE([foreign])
# choose one
LTDL_INIT([recursive])
#LTDL_INIT([subproject])
#LTDL_INIT([nonrecursive])
# This tells whether or not to prepend "GNU " prefix to the package
# name that gets inserted into the header of the $(DOMAIN).pot file.
# Possible values are "yes", "no", or empty. If it is empty, try to
# detect it automatically by scanning the files in $(top_srcdir) for
# "GNU packagename" string.
-PACKAGE_GNU =
+PACKAGE_GNU = no
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
$ rm po/Makevars.template
Let’s update C sources for the i18n version by wrapping strings with _(…).
src/hello.c (i18n):
... hack, hack, hack, ...
$ cat src/hello.c
#include "config.h"
#include <stdio.h>
#include <sharedlib.h>
125
CHAPTER 13. MORE EXAMPLES 13.13. INTERNATIONALIZATION
#include <libintl.h>
#define _(string) gettext (string)
int
main()
{
printf(_("Hello, I am " PACKAGE_AUTHOR "!\n"));
sharedlib();
return 0;
}
lib/sharedlib.c (i18n):
... hack, hack, hack, ...
$ cat lib/sharedlib.c
#include <stdio.h>
#include <libintl.h>
#define _(string) gettext (string)
int
sharedlib()
{
printf(_("This is a shared library!\n"));
return 0;
}
The new gettext (v=0.19) can handle the i18n version of the desktop file directly.
data/hello.desktop.in (i18n):
$ fgrep -v '[ja]=' data/hello.desktop > data/hello.desktop.in
$ rm data/hello.desktop
$ cat data/hello.desktop.in
[Desktop Entry]
Name=Hello
Comment=Greetings
Type=Application
Keywords=hello
Exec=hello
Terminal=true
Icon=hello.png
Categories=Utility;
Here is the updated root Makefile.am with po added to the SUBDIRS environment variable.
Makefile.am (i18n):
$ cat Makefile.am
# recursively process `Makefile.am` in SUBDIRS
SUBDIRS = po lib src man
ACLOCAL_AMFLAGS = -I m4
126
CHAPTER 13. MORE EXAMPLES 13.13. INTERNATIONALIZATION
#: src/hello.c:9
#, c-format
msgid "Hello, I am "
msgstr ""
#: lib/sharedlib.c:7
#, c-format
msgid "This is a shared library!\n"
msgstr ""
#: data/hello.desktop.in:3
msgid "Hello"
msgstr ""
#: data/hello.desktop.in:4
msgid "Greetings"
msgstr ""
#: data/hello.desktop.in:6
msgid "hello"
msgstr ""
127
CHAPTER 13. MORE EXAMPLES 13.14. DETAILS
#: src/hello.c:34
#, c-format
msgid "Hello, my name is %s!\n"
msgstr "Bonjour, je m'appelle %s!\n"
#: lib/sharedlib.c:29
#, c-format
msgid "This is a shared library!\n"
msgstr "Ceci est une bibliothèque partagée!\n"
#: data/hello.desktop.in:3
msgid "Hello"
msgstr ""
#: data/hello.desktop.in:4
msgid "Greetings"
msgstr "Salutations"
#: data/hello.desktop.in:6
msgid "hello"
msgstr ""
#: data/hello.desktop.in:9
msgid "hello.png"
msgstr ""
The packaging activities are practically the same as the one in “Section 13.11”.
You can find more i18n examples by following “Section 13.14”.
13.14 Details
Actual details of the examples presented and their variants can be obtained by the following.
How to get details
$ apt-get source debmake-doc
$ cd debmake-doc*
$ cd examples
$ view examples/README.md
Now, each directory named as examples/debhello-?.?_build-? contains the Debian packaging example.
• emulated console command line activity log: the .log file
• emulated console command line activity log (short): the .slog file
• snapshot source tree image after the debmake command: the debmake directory
• snapshot source tree image after proper packaging: the packge directory
• snapshot source tree image after the debuild command: the test directory
Notable examples are:
128
Chapter 14
debmake(1) manpage
14.1 NAME
debmake - program to make a Debian source package
14.2 SYNOPSIS
debmake [-h] [-c | -k] [-n | -a package-version.orig.tar.gz | -d | -t ] [-p package] [-u version] [-r revision] [-z
extension] [-b ”binarypackage[:type], …]” [-e [email protected]] [-f ”firstname lastname”] [-i ”buildtool” | -j] [-l
license_file] [-m] [-o file] [-q] [-s] [-v] [-w ”addon, …”] [-x [01234]] [-y] [-L] [-P] [-T]
14.3 DESCRIPTION
debmake helps to build a 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 untarred to create many files under the package-version/ directory.
• debmake is invoked in the package-version/ directory, possibly without any arguments.
129
CHAPTER 14. DEBMAKE(1) MANPAGE 14.3. DESCRIPTION
-n, --native make a native Debian source package without .orig.tar.gz. This makes a Debian source format “3.0
(native)” package.
If you are thinking of packaging a Debian-specific source tree with debian/ in it into a native Debian package,
please think otherwise. You can use the “debmake -d -i debuild” or “debmake -t -i debuild” commands
to make a Debian non-native package using the Debian source format “3.0 (quilt)” 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 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 other cases, it 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 the “make dist” command equivalents first to generate the upstream tarball and use it.
The “debmake -d” command is designed to run in the package/ directory hosting the upstream VCS with
the build system supporting the “make dist” command equivalents. (automake/autoconf, …)
-t, --tar run the “tar” command to generate the upstream tarball and use it.
The “debmake -t” command 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 the binary package specs by a comma
separated list of binarypackage:type pairs. Here, binarypackage is the binary package name, and the 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)
• 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)
• python3: Python (version 3) script package (all, foreign) (alias: py3, python, py)
• ruby: Ruby script package (all, foreign) (alias: rb)
• nodejs: Node.js based JavaScript package (all, foreign) (alias: js)
• script: Shell and other interpretted language 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.
Here are examples for typical binary package split scenarios where the upstream Debian source package
name is foo:
• Generating an executable binary package foo:
130
CHAPTER 14. DEBMAKE(1) MANPAGE 14.3. DESCRIPTION
If the source tree contents do not match settings for type, the debmake command warns you.
-e [email protected], --email [email protected] set e-mail address.
The default is taken from the value of the environment variable $DEBEMAIL.
-q, --quitearly quit early before creating files in the debian/ directory.
-s, --spec use upstream spec (pyproject.py for Python, etc.) for the package description.
-v, --version show version information.
131
CHAPTER 14. DEBMAKE(1) MANPAGE 14.4. EXAMPLES
-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 ”python3,autoreconf””.
For Autotools based packages, autoreconf as addon to run “autoreconf -i -v -f” for every package building
is default behavior of the dh(1) command.
For Autotools based packages, if they install Python (version 3) programs, setting python3 as addon to the
debmake command argument is needed since this is non-obvious. But for pyproject.toml based Python
packages, setting python3 as addon to the debmake command argument is not needed since this is obvious
and the debmake command automatically set it to the dh(1) command.
-x n, --extra n generate configuration files as templates. (Please note debian/changelog, debian/control, de-
bian/copyright, and debian/rules are bare minimum configuration files to build a Debian binary package.)
The number n determines which configuration templates are generated.
• -x0: all required configuration template files. (selected option if any of these files already exist)
• -x1: all -x0 files + desirable configuration template files with binary package type supports.
• -x2: all -x1 files + normal configuration template files with maintainer script supports.
• -x3: all -x2 files + optional configuration template files. (default optuin)
• -x4: all -x3 files + deprecated configuration template files.
Some configuration template files are generated with the extra .ex suffix to ease their removal. To activate
these, rename their file names to the ones without the .ex suffix and edit their contents. Existing configuration files
are never overwritten. If you wish to update some of the existing configuration files, please rename them before
running the debmake command and manually merge the generated configuration files with the old renamed ones.
-y, --yes “force yes” for all prompts. (without option: “ask [Y/n]”; doubled option: “force no”)
-L, --local generate configuration files for the local package to fool lintian(1) checks.
-P, --pedantic pedantically check auto-generated files.
-T, --tutorial output tutorial comment lines in template files. default when -x3 or -x4 is set.
14.4 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 the traditional
“make install” command installing into 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 option does not work, try the -t option instead.)
For a typical C program source tree packaged with autoconf/automake:
• debmake -d -i debuild
132
CHAPTER 14. DEBMAKE(1) MANPAGE 14.5. HELPER PACKAGES
14.6 CAVEAT
Although debmake is meant to provide template files for the package maintainer to work on, actual packaging
activities are often performed without using debmake while referencing only existing similar packages and “Debian
Policy Manual”. All template files generated by debmake are required to be modified manually.
There are 2 positive points for debmake:
• debmake helps to write terse packaging tutorial “Guide for Debian Maintainers” (debmake-doc package).
• debmake provides short extracted license texts as debian/copyright in decent accuracy to help license re-
view.
Please double check copyright with the licensecheck(1) command.
There are some limitations for what characters may be used as a part of the Debian package. The most no-
table limitation is the prohibition of uppercase letters in the package name. Here is a summary as a set of regular
expressions:
14.7 DEBUG
Please report bugs to the debmake package using the reportbug command.
The character set in the environment variable $DEBUG determines the logging output level.
• i: main.py logging
• p: para.py logging
133
CHAPTER 14. DEBMAKE(1) MANPAGE 14.8. AUTHOR
14.8 AUTHOR
Copyright © 2014-2024 Osamu Aoki <[email protected]>
14.9 LICENSE
Expat License
134
Chapter 15
debmake options
Tip
Tip
15.2 debmake -b
The debmake command with the -b option provides an intuitive and flexible method to create the initial template
debian/control file defining the split of the Debian binary packages with following stanzas:
• Package:
• Architecture: (e.g. amd64)
135
CHAPTER 15. DEBMAKE OPTIONS 15.3. DEBMAKE -CC
The debmake command also sets an appropriate set of substvars used in each pertinent dependency stanza.
Let’s quote the pertinent part from the debmake manpage here.
-b ”binarypackage[:type],…”, --binaryspec ”binarypackage[:type],…” set the binary package specs by a comma
separated list of binarypackage:type pairs. Here, binarypackage is the binary package name, and the 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)
• 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)
• python3: Python (version 3) script package (all, foreign) (alias: py3, python, py)
• ruby: Ruby script package (all, foreign) (alias: rb)
• nodejs: Node.js based JavaScript package (all, foreign) (alias: js)
• script: Shell and other interpretted language 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.
Here are examples for typical binary package split scenarios where the upstream Debian source package
name is foo:
• Generating an executable binary package foo:
– “-b’foo:bin’”, or its short form ̀-b’-’ ̀”, or no -b option
• Generating an executable (python3) binary package python3-foo:
– “-b’python3-foo:py’”, or its short form “-b’python3-foo’”
• Generating a data package foo:
– “-b’foo:data’”, or its short form “-b’-:data’”
• Generating a executable binary package foo and a documentation one foo-doc:
– “-b’foo:bin,foo-doc:doc’”, or its short form “-b’-:-doc’”
• Generating a executable binary package foo, a library package libfoo1, and a library development pack-
age libfoo-dev:
– “-b’foo:bin,libfoo1:lib,libfoo-dev:dev’” or its short form “-b’-,libfoo1,libfoo-dev’”
If the source tree contents do not match settings for type, the debmake command warns you.
136
CHAPTER 15. DEBMAKE OPTIONS 15.4. SNAPSHOT UPSTREAM TARBALL (-D, -T)
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 the making of a non-native Debian package 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 non-native Debian binary package building scheme without the real upstream tarball is considered as the
quasi-native Debian package. See “Section 10.13”.
15.5 debmake -j
This is an experimental feature.
The generation of a functioning multi-binary package always requires more manual work than that of a func-
tioning single binary package. The test build of the source package is the essential part of it.
For example, let’s package the same package-1.0.tar.gz (see “Chapter 5”) into a multi binary package.
• Invoke the debmake command with the -j option for the test building and the report generation.
$ debmake -j -a package-1.0.tar.gz
• Check the last lines of the package.build-dep.log file 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 tech-
nique is useful for the generation of a single binary package, too.)
• Check the contents of the package.install.log file to identify the install paths for files to decide how you split
them into multiple packages.
• Start packaging with the debmake command.
$ rm -rf package-1.0
$ tar -xvzf package-1.0.tar.gz
$ cd package-1.0
$ debmake -b"package1:type1, ..."
• Build the Debian package with the debuild command or its equivalent.
137
CHAPTER 15. DEBMAKE OPTIONS 15.6. DEBMAKE -K
$ debuild
• All binary package entries specified in the debian/binarypackage.install file are generated as binarypackage_version-
revision_arch.deb.
Note
The -j option for the debmake command invokes dpkg-depcheck(1) to run de-
bian/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 the ”debmake …” com-
mand without the -j option and run the “debian/rules install” command to check
the install paths of the generated files.
15.6 debmake -k
This is an experimental feature.
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 compares 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.
15.7 debmake -P
The debmake command invoked with the -P option pedantically checks auto-generated files for copyright+license
text even if they are with permissive license.
This option affects not only the content of the debian/copyright file generated by normal execution, but also
the output by the execution with the -k, -c, -cc, and -ccc options.
15.8 debmake -T
The debmake command invoked with the -T option additionally prints verbose tutorial comment lines. The lines
marked with ### in the template files are part of the verbose tutorial comment lines.
138
CHAPTER 15. DEBMAKE OPTIONS 15.9. DEBMAKE -X
15.9 debmake -x
The amount of template files generated by the debmake command depends on the -x[01234] option.
• See “Section 13.1” for cherry-picking of the template files.
Note
None of the existing configuration files are modified by the debmake command.
139