Debmake-Doc en
Debmake-Doc en
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 Overview 1
2 Prerequisites 3
2.1 People around Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 How to contribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Social dynamics of Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 Technical reminders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.5 Debian documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.6 Help resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.7 Archive situation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.8 Contribution approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.9 Novice contributor and maintainer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Tool Setups 9
3.1 Email address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 mc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4 quilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5 devscripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6 pbuilder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.7 git-buildpackage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.8 HTTP proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.9 Private Debian repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Simple Example 15
4.1 Big picture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 What is debmake? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.3 What is debuild? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.4 Step 1: Get the upstream source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.5 Step 2: Generate template files with debmake . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.6 Step 3: Modification to the template files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.7 Step 4: Building package with debuild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.8 Step 3 (alternative): Modification to the upstream source . . . . . . . . . . . . . . . . . . . . . . 26
4.8.1 Patch by diff -u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.8.2 Patch by dquilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.8.3 Patch by dpkg-source --commit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5 Basics 31
5.1 Packaging workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.1.1 The debhelper package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.2 Package name and version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3 Native Debian package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4 debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.4.1 dh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.4.2 Simple debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4.3 Customized debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4.4 Variables for debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.4.5 Reproducible build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.5 debian/control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.5.1 Split of a Debian binary package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.5.1.1 debmake -b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.5.1.2 Package split scenario and examples . . . . . . . . . . . . . . . . . . . . . . . 39
5.5.1.3 The library package name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.5.2 Substvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
ii
CONTENTS
6 debmake options 62
6.1 Shortcut options (-a, -i) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.1.1 Python module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.2 Upstream snapshot (-d, -t) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.3 debmake -cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.4 debmake -k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.5 debmake -j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.6 debmake -x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.7 debmake -P . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.8 debmake -T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
7 Tips 66
7.1 debdiff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.2 dget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.3 debc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.4 piuparts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.5 debsign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.6 dput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.7 bts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.8 git-buildpackage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.8.1 gbp import-dscs --debsnap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.9 Upstream git repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.10 chroot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
iii
CONTENTS
8 More Examples 78
8.1 Cherry-pick templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.2 No Makefile (shell, CLI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.3 Makefile (shell, CLI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.4 setup.py (Python3, CLI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
8.5 Makefile (shell, GUI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.6 setup.py (Python3, GUI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.7 Makefile (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.8 Makefile.in + configure (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.9 Autotools (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.10 CMake (single-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
8.11 Autotools (multi-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
8.12 CMake (multi-binary package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
8.13 Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
8.14 Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
iv
Abstract
This “Guide for Debian Maintainers” (2019-03-26) 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”.
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 5.4.4)
of a Debian system from the Debian Reference. It contains some pointers to learn about Unix programming, too.
2 If you are not interested in sharing the Debian package, you can certainly work around your local situation by compiling and installing
vi
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. The result is the
debmake (version: 4.3.1) package and this updated “Guide for Debian Maintainers” in the debmake-doc (version:
1.14-1) package.
Many chores and tips have been integrated into the debmake command making this guide simple. This guide
also offers many packaging examples.
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.
vii
Chapter 1
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.
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 good template files. These template files
must be manually adjusted to their perfection to comply with the strict quality re-
quirements of the Debian archive, if the generated package is intended for gen-
eral 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 very 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:
• flexibility
version overlaps with the obsolete debmake package, which provided the deb-make command.
1
CHAPTER 1. OVERVIEW
• extra utility
– verification of the debian/copyright file against the current source (Section 6.4)
The debmake command delegates most of the heavy lifting to its back-end packages: debhelper, dpkg-dev,
devscripts, pbuilder, 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 8.14.
Note
The generation of the debian/copyright file, and the outputs from the -c (Sec-
tion 6.3) and -k (Section 6.4) options involve heuristic operations on the copyright
and license information. They may produce some erroneous results.
2
Chapter 2
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 2.8).
3
CHAPTER 2. PREREQUISITES 2.3. SOCIAL DYNAMICS OF DEBIAN
• Debian is not your school where you get automatic attention of teachers.
Since we focus only on the technical aspects of the packaging in the rest of this guide, please refer to the
following to understand the social dynamics of Debian:
• Debian: 17 years of Free Software, “do-ocracy”, and democracy (Introductory slides by the ex-DPL)
Note
Debugging of software tends to consume more time than writing the initial working
software.
1 The overwhelming number of Debian maintainers use git over other VCS systems such as hg, bzr, etc.
4
CHAPTER 2. PREREQUISITES 2.5. DEBIAN DOCUMENTATION
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:
• “Debian New Maintainers’ Guide” (older)
– https://www.debian.org/doc/devel-manuals#maint-guide
– https://packages.qa.debian.org/m/maint-guide.html
– https://www.debian.org/doc/devel-manuals#packaging-tutorial
– https://packages.qa.debian.org/p/packaging-tutorial.html
– http://packaging.ubuntu.com/html/
Tip
When reading these tutorials, you should consider using the debmake command
in place of the dh_make command for better template files.
Your desired information can be found effectively by using a well-formed search string such as “keyword
site:lists.debian.org” to limit the search domain of the web search engine.
Making a small test package is a good way to learn details of the packaging. Inspecting existing well maintained
packages is the best way to learn how other people make packages.
If you still have questions about the packaging, you can ask them interactively:
5
CHAPTER 2. PREREQUISITES 2.7. ARCHIVE SITUATION
– debian-devel-{french,italian,portuguese,spanish}@lists.debian.org
– [email protected] (This mailing list is for general (Simplified) Chinese discussion.)
– [email protected]
The more experienced Debian developers will gladly help you, if you ask properly after making your required
efforts.
Caution
Debian development is a moving target. Some information found on the web may
be outdated, incorrect, and non-applicable. Please use it carefully.
• The number of packages already in the Debian archive is several tens of times greater than that of active
maintainers.
• Unfortunately, some packages lack an appropriate level of attention by the maintainer.
Thus, contributions to packages already in the archive are far more appreciated (and more likely to receive
sponsorship for uploading) by other maintainers.
Tip
The wnpp-alert command from the devscripts package can check for installed
packages up for adoption or orphaned.
if exist_in_debian(program):
if is_team_maintained(program):
join_team(program)
if is_orphaned(program) # maintainer: Debian QA Group
adopt_it(program)
elif is_RFA(program) # Request for Adoption
adopt_it(program)
else:
if need_help(program):
contact_maintainer(program)
6
CHAPTER 2. PREREQUISITES 2.8. CONTRIBUTION APPROACHES
triaging_bugs(program)
preparing_QA_or_NMU_uploads(program)
else:
leave_it(program)
else: # new packages
if not is_good_program(program):
give_up_packaging(program)
elif not is_distributable(program):
give_up_packaging(program)
else: # worth packaging
if is_ITPed_by_others(program):
if need_help(program):
contact_ITPer_for_collaboration(program)
else:
leave_it_to_ITPer(program)
else: # really new
if is_applicable_team(program):
join_team(program)
if is_DFSG(program) and is_DFSG(dependency(program)):
file_ITP(program, area="main") # This is Debian
elif is_DFSG(program):
file_ITP(program, area="contrib") # This is not Debian
else: # non-DFSG
file_ITP(program, area="non-free") # This is not Debian
package_it_and_close_ITP(program)
Here:
• For exist_in_debian(), and is_team_maintained(); check:
– the aptitude command
– Debian packages web page
– Teams
• For is_orphaned(), is_RFA(), and is_ITPed_by_others(); check:
– The output of the wnpp-alert command.
– Work-Needing and Prospective Packages
– Debian Bug report logs: Bugs in pseudo-package wnpp in unstable
– Debian Packages that Need Lovin’
– Browse wnpp bugs based on debtags
• For is_good_program(), check:
– The program should be useful.
– The program should not introduce security and maintenance concerns to the Debian system.
– The program should be well documented and its code needs to be understandable (i.e. not obfuscated).
– The program’s authors agree with the packaging and are amicable to Debian. 2
• For is_it_DFSG(), and is_its_dependency_DFSG(); check:
– Debian Free Software Guidelines (DFSG).
• For is_it_distributable(), check:
– The software must have a license and it should allow its distribution.
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.
2 This is not the absolute requirement. The hostile upstream may become a major resource drain for us all. The friendly upstream can be
consulted to solve any problems with the program.
7
CHAPTER 2. PREREQUISITES 2.9. NOVICE CONTRIBUTOR AND MAINTAINER
• Translation
• Documentation
The novice contributor and maintainer may wonder where to start your contribution to Debian. Here are my
suggestions depending on your skills:
• POSIX shell, Perl, and Python skills:
– Send patches to the packages with the required and important priorities.
• Non-English skills:
• Documentation skills:
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:
8
Chapter 3
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.
DEBEMAIL="[email protected]"
DEBFULLNAME="Firstname Lastname"
export DEBEMAIL DEBFULLNAME
3.2 mc
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.
Add to the ~/.bashrc file
# mc related
export HISTCONTROL=ignoreboth
. /usr/lib/mc/mc.sh
1 This assumes you are using Bash as your login shell. If you use some other login shell such as Z shell, use their corresponding configuration
9
CHAPTER 3. TOOL SETUPS 3.3. GIT
3.3 git
Nowadays, the git command is the essential tool to manage the source tree with history.
The global user configuration for the git command such as your name and email address can be set in ~/.gitconfig
as follows.
If you are too accustomed to the CVS or Subversion commands, you may wish to set several command aliases
as follows.
Tip
It is essential to use some GUI git tools like gitk or gitg to work effectively with
the history of the git repository.
3.4 quilt
The quilt command offers a basic method for recording modifications. For the Debian packaging, it should be
customized to record modifications in the debian/patches/ directory instead of its default patches/ directory.
In order to avoid changing the behavior of the quilt command itself, let’s create an alias dquilt for the Debian
packaging by adding the following lines to the ~/.bashrc file. The second line provides the same shell completion
feature of the quilt command to the dquilt command.
Add to the ~/.bashrc file
d=.
while [ ! -d $d/debian -a `readlink -e $d` != / ];
do d=$d/..; done
if [ -d $d/debian ] && [ -z $QUILT_PATCHES ]; then
# if in Debian packaging tree with unset $QUILT_PATCHES
QUILT_PATCHES="debian/patches"
QUILT_PATCH_OPTS="--reject-format=unified"
QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto"
QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:" + \
"diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33"
if ! [ -d $d/debian/patches ]; then mkdir $d/debian/patches; fi
fi
See quilt(1) and How To Survive With Many Patches or Introduction to Quilt on how to use the quilt command.
See Section 4.8 for example usages.
10
CHAPTER 3. TOOL SETUPS 3.5. DEVSCRIPTS
3.5 devscripts
The debsign command, included in the devscripts package, is used to sign the Debian package with your private
GPG key.
The debuild command, included in the devscripts package, builds the binary package and checks it with the
lintian command. It is useful to have verbose outputs from the lintian command.
You can set these up in ~/.devscripts as follows.
3.6 pbuilder
2
The pbuilder package provides a clean room (chroot) build environment.
Let’s customize it with several helper packages.
• The cowbuilder package to boost the chroot creation speed.
• The lintian package to find bugs in the package.
Warning
The optional customization may cause negative effects. In case of doubts, dis-
able them.
AUTO_DEBSIGN="${AUTO_DEBSIGN:-no}"
PDEBUILD_PBUILDER=cowbuilder
HOOKDIR="/var/cache/pbuilder/hooks"
MIRRORSITE="http://deb.debian.org/debian/"
#APTCACHE=/var/cache/pbuilder/aptcache
APTCACHE=/var/cache/apt/archives
#BUILDRESULT=/var/cache/pbuilder/result/
BUILDRESULT=../
EXTRAPACKAGES="ccache lintian libeatmydata1"
11
CHAPTER 3. TOOL SETUPS 3.6. PBUILDER
#BINDMOUNTS="${CCACHE_DIR}"
# parallel make
#DEBBUILDOPTS=-j8
Note
Note
Due to Bug #606542, you may need to manually install packages listed in EX-
TRAPACKAGES into the chroot. See Section 7.10.
Note
Install libeatmydata1 (>=82-2) both inside and outside of the chroot or disable to
use libeatmydata1. This may cause a race condition with some build systems.
Note
The parallel make may fail for some existing packages and may make the build
log difficult to read.
#!/bin/sh
set -e
# increase the ccache caching size
ccache -M 4G
# output the current statistics
ccache -s
/var/cache/pbuilder/hooks/B90lintian
#!/bin/sh
set -e
apt-get -y --allow-downgrades install lintian
echo "+++ lintian output +++"
su -c "lintian -i -I --show-overrides /tmp/buildd/*.changes; :" -l pbuilder
echo "+++ end of lintian output +++"
/var/cache/pbuilder/hooks/C10shell
12
CHAPTER 3. TOOL SETUPS 3.7. GIT-BUILDPACKAGE
#!/bin/sh
set -e
apt-get -y --allow-downgrades install vim bash mc
# invoke shell if build fails
cd /tmp/buildd/*/debian/..
/bin/bash < /dev/tty > /dev/tty 2> /dev/tty
Note
All these scripts need to be set world executable: “-rwxr-xr-x 1 root root”.
Note
3.7 git-buildpackage
You may wish to set several global configurations in ~/.gbp.conf
[DEFAULT]
# the default build command:
builder = git-pbuilder -i -I -us -uc
# use pristine-tar:
pristine-tar = True
# Use color when on a terminal, alternatives: on/true, off/false or auto
color = auto
Tip
13
CHAPTER 3. TOOL SETUPS 3.9. PRIVATE DEBIAN REPOSITORY
14
Chapter 4
Simple Example
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”).
Here is an example of creating a simple Debian package from a simple C source using the Makefile as its build
system.
Let’s assume this upstream tarball to be debhello-0.0.tar.gz.
This type of source is meant to be installed as a non-system file as:
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
• The debuild command builds the binary package from the debianized source tree.
15
CHAPTER 4. SIMPLE EXAMPLE 4.2. 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.
• It generates the upstream tarball and its required symlink if they are missing.
• It doesn’t overwrite the existing configuration files in the debian/ directory.
• It supports the multiarch package.
• It creates good template files such as the debian/copyright file compliant with DEP-5.
These features make Debian packaging with debmake simple and modern.
Note
The debmake command isn’t the only way to make a Debian package. Many
packages are packaged using only a text editor while imitating how other similar
packages are packaged.
– “dpkg-source --before-build” (apply Debian patches, unless they are already applied)
– “fakeroot debian/rules clean”
16
CHAPTER 4. SIMPLE EXAMPLE 4.4. STEP 1: GET THE UPSTREAM SOURCE
• The debuild command is a wrapper script of the dpkg-buildpackage command to build the Debian binary
package under the proper environment variables.
• The pdebuild command is a wrapper script to build the Debian binary package under the proper chroot
environment with the proper environment variables.
• The git-pbuilder command is another wrapper script to build the Debian binary package under the proper
chroot environment with the proper environment variables. This provides an easier command line UI to
switch among different build environments.
Note
$ wget http://www.example.org/download/debhello-0.0.tar.gz
...
$ tar -xzmf debhello-0.0.tar.gz
$ tree
.
├── debhello-0.0
│ ├── LICENSE
│ ├── Makefile
│ └── src
│ └── hello.c
└── debhello-0.0.tar.gz
2 directories, 4 files
$ cat debhello-0.0/src/hello.c
#include <stdio.h>
int
main()
{
printf("Hello, world!\n");
17
CHAPTER 4. SIMPLE EXAMPLE 4.5. STEP 2: GENERATE TEMPLATE FILES …
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
$ 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.
Tip
If the debmake command is invoked with the -T option, more verbose comments
are generated for the template files.
The output from the debmake command is very verbose and explains what it does as follows.
18
CHAPTER 4. SIMPLE EXAMPLE 4.5. STEP 2: GENERATE TEMPLATE FILES …
$ cd debhello-0.0
$ debmake
I: set parameters
I: sanity check of parameters
I: pkg="debhello", ver="0.0", rev="1"
I: *** start packaging in "debhello-0.0". ***
I: provide debhello_0.0.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-0.0.tar.gz debhello_0.0.orig.tar.gz
I: pwd = "/path/to/debhello-0.0"
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: 100 %, ext = c
I: check_all_licenses
I: ..
I: check_all_licenses completed for 2 files.
I: bunch_all_licenses
I: format_all_licenses
I: make debian/* template files
I: single binary package
I: debmake -x "1" ...
I: creating => debian/control
I: creating => debian/copyright
I: substituting => /usr/share/debmake/extra0/rules
I: creating => debian/rules
I: substituting => /usr/share/debmake/extra0/changelog
I: creating => debian/changelog
I: substituting => /usr/share/debmake/extra1/compat
I: creating => debian/compat
I: substituting => /usr/share/debmake/extra1/watch
I: creating => debian/watch
I: substituting => /usr/share/debmake/extra1/README.Debian
I: creating => debian/README.Debian
I: substituting => /usr/share/debmake/extra1source/local-options
I: creating => debian/source/local-options
I: substituting => /usr/share/debmake/extra1source/format
I: creating => debian/source/format
I: substituting => /usr/share/debmake/extra1patches/series
I: creating => debian/patches/series
I: run "debmake -x2" to get more template files
I: $ wrap-and-sort
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
19
CHAPTER 4. SIMPLE EXAMPLE 4.5. STEP 2: GENERATE TEMPLATE FILES …
$ cd ..
$ tree
.
├── debhello-0.0
│ ├── LICENSE
│ ├── Makefile
│ ├── debian
│ │ ├── README.Debian
│ │ ├── changelog
│ │ ├── compat
│ │ ├── control
│ │ ├── copyright
│ │ ├── patches
│ │ │ └── series
│ │ ├── rules
│ │ ├── source
│ │ │ ├── format
│ │ │ └── local-options
│ │ └── watch
│ └── src
│ └── hello.c
├── debhello-0.0.tar.gz
└── debhello_0.0.orig.tar.gz -> debhello-0.0.tar.gz
5 directories, 15 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):
$ cat debhello-0.0/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,--as-needed
%:
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 debhello-0.0/debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Firstname Lastname" <[email protected]>
Build-Depends: debhelper (>=11~)
Standards-Version: 4.1.4
Homepage: <insert the upstream URL, if relevant>
20
CHAPTER 4. SIMPLE EXAMPLE 4.5. STEP 2: GENERATE TEMPLATE FILES …
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 5.
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 Manual”.
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):
$ cat debhello-0.0/debian/copyright
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: debhello
Source: <url://example.com>
#
# Please double check copyright with the licensecheck(1) command.
Files: Makefile
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.
#----------------------------------------------------------------------------...
# License file: LICENSE
License:
.
All files in this archive are licensed under the MIT License as below.
.
Copyright 2015 Osamu Aoki <[email protected]>
.
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:
21
CHAPTER 4. SIMPLE EXAMPLE 4.6. STEP 3: MODIFICATION TO THE …
.
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.
$ vim debhello-0.0/debian/rules
... hack, hack, hack, ...
$ cat debhello-0.0/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_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):
$ vim debhello-0.0/debian/control
... hack, hack, hack, ...
$ cat debhello-0.0/debian/control
Source: debhello
Section: devel
Priority: optional
1 This 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.
2 This is a cliché to prevent overlinking for the complex library dependency case such as Gnome programs. This is not really needed for
22
CHAPTER 4. SIMPLE EXAMPLE 4.6. STEP 3: MODIFICATION TO THE …
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: example package in the debmake-doc package
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)'.
$ vim debhello-0.0/debian/copyright
... hack, hack, hack, ...
$ cat debhello-0.0/debian/copyright
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: debhello
Source: https://salsa.debian.org/debian/debmake-doc
Files: *
Copyright: 2015 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.
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=0.0):
$ tree debhello-0.0/debian
debhello-0.0/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
23
CHAPTER 4. SIMPLE EXAMPLE 4.7. STEP 4: BUILDING PACKAGE WITH DEBUILD
2 directories, 10 files
Tip
Configuration files used by the dh_* commands from the debhelper package
usually treat # as the start of a comment line.
$ cd debhello-0.0
$ debuild
dpkg-buildpackage -us -uc -ui -i
...
fakeroot debian/rules clean
dh clean
...
debian/rules build
dh build
dh_update_autotools_config
dh_autoreconf
dh_auto_configure
dh_auto_build
make -j4 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/path/to/debhello-0.0'
# CFLAGS=-g -O2 -fdebug-prefix-map=/build/debmake-doc-1.14=.
# -fstack-protector-strong -Wformat -Werror=format-security
cc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/debmake-d...
...
fakeroot debian/rules binary
dh binary
...
Now running lintian debhello_0.0-1_amd64.changes ...
...
W: debhello: binary-without-manpage usr/bin/hello
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 8). Let’s move on for now.
Let’s inspect the result.
The generated files of debhello version 0.0 by the debuild command:
$ cd ..
$ 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
24
CHAPTER 4. SIMPLE EXAMPLE 4.7. STEP 4: BUILDING PACKAGE WITH DEBUILD
├── 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
1 directory, 9 files
• The debhello-dbgsym_0.0-1_amd64.deb is the Debian debug symbol binary package. See Section 5.17.1.
• The debhello_0.0-1_amd64.build file is the build log file.
• The debhello_0.0-1_amd64.buildinfo file is the meta data file generated by dpkg-genbuildinfo(1).
• 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:
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/8f/
-rw-r--r-- root/root ... ./usr/lib/debug/.build-id/8f/6eac00576c538d13e7aea9...
drwxr-xr-x root/root ... ./usr/share/
drwxr-xr-x root/root ... ./usr/share/doc/
25
CHAPTER 4. SIMPLE EXAMPLE 4.8. STEP 3 (ALTERNATIVE): MODIFICATION …
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.
– Section 4.8.1
– Section 4.8.2
– Section 4.8.3
• The maintainer modification to the debian/rules file doesn’t have the override_dh_auto_install target as
follows:
26
CHAPTER 4. SIMPLE EXAMPLE 4.8. STEP 3 (ALTERNATIVE): MODIFICATION …
$ cd 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 $@
This alternative approach to Debian packaging using a series of patch files may be less robust for future upstream
changes but more flexible coping with the difficult upstream source. (See Section 7.13.)
Note
For this particular packaging case, the above Section 4.6 using the debian/rules
file is the better approach. But let’s keep on with this approach as a leaning
process.
Tip
For more complicated packaging cases, both Section 4.6 and Section 4.8 ap-
proaches need to be deployed.
$ cp -a debhello-0.0 debhello-0.0.orig
$ vim debhello-0.0/Makefile
... hack, hack, hack, ...
$ diff -Nru debhello-0.0.orig debhello-0.0 >000-prefix-usr.patch
$ cat 000-prefix-usr.patch
diff -Nru debhello-0.0.orig/Makefile debhello-0.0/Makefile
--- debhello-0.0.orig/Makefile 2019-03-26 17:03:03.049996643 +0000
+++ debhello-0.0/Makefile 2019-03-26 17:03:03.121995074 +0000
@@ -1,4 +1,4 @@
-prefix = /usr/local
+prefix = /usr
all: src/hello
$ rm -rf debhello-0.0
$ mv -f debhello-0.0.orig debhello-0.0
Please note that the upstream source tree is restored to the original state and the patch file is available as 000-
prefix-usr.patch.
This 000-prefix-usr.patch is edited to be DEP-3 conformant and moved to the right location as below.
27
CHAPTER 4. SIMPLE EXAMPLE 4.8. STEP 3 (ALTERNATIVE): MODIFICATION …
$ cd debhello-0.0
$ 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
$ cd debhello-0.0
$ dquilt new 000-prefix-usr.patch
Patch debian/patches/000-prefix-usr.patch is now on top
$ dquilt add Makefile
File Makefile added to patch debian/patches/000-prefix-usr.patch
... hack, hack, hack, ...
$ head -1 Makefile
prefix = /usr
$ dquilt refresh
Refreshed patch debian/patches/000-prefix-usr.patch
$ dquilt header -e --dep3
... edit the DEP-3 patch header with editor
$ tree -a
.
├── .pc
│ ├── .quilt_patches
│ ├── .quilt_series
│ ├── .version
│ ├── 000-prefix-usr.patch
│ │ ├── .timestamp
│ │ └── Makefile
│ └── applied-patches
├── LICENSE
├── Makefile
├── debian
│ ├── README.Debian
│ ├── changelog
│ ├── compat
│ ├── control
│ ├── copyright
│ ├── patches
│ │ ├── 000-prefix-usr.patch
│ │ └── series
│ ├── rules
│ ├── source
│ │ ├── format
│ │ └── local-options
│ └── watch
28
CHAPTER 4. SIMPLE EXAMPLE 4.8. STEP 3 (ALTERNATIVE): MODIFICATION …
└── src
└── hello.c
6 directories, 20 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. The dpkg-source
command invoked by the Debian packaging procedure in Section 4.7, understands the patch application state
recorded by the dquilt program in the .pc/ directory. As long as all the changes are committed by the dquilt
command, the Debian source package can be built from the modified source tree.
Note
If the .pc/ directory is missing, the dpkg-source command assumes that no patch
was applied. That’s why the more primitive patch generation methods like in
Section 4.8.1 without generating the .pc/ directory require the upstream source
tree to be restored.
$ cd debhello-0.0
$ vim Makefile
... hack, hack, hack, ...
$ head -n1 Makefile
prefix = /usr
$ 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
29
CHAPTER 4. SIMPLE EXAMPLE 4.8. STEP 3 (ALTERNATIVE): MODIFICATION …
@@ -1,4 +1,4 @@
-prefix = /usr/local
+prefix = /usr
all: src/hello
$ tree -a
.
├── .pc
│ ├── .quilt_patches
│ ├── .quilt_series
│ ├── .version
│ ├── 000-prefix-usr.patch
│ │ ├── .timestamp
│ │ └── Makefile
│ └── applied-patches
├── LICENSE
├── Makefile
├── debian
│ ├── README.Debian
│ ├── changelog
│ ├── compat
│ ├── control
│ ├── copyright
│ ├── patches
│ │ ├── 000-prefix-usr.patch
│ │ └── series
│ ├── rules
│ ├── source
│ │ ├── format
│ │ └── local-options
│ └── watch
└── src
└── hello.c
6 directories, 20 files
Here, the dpkg-source command performs exactly the same as what the sequences of the dquilt command did
in Section 4.8.2.
30
Chapter 5
Basics
A broad overview is presented here 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 “3.0 (quilt)” format 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.
3. The upstream tarball is copied (or symlinked) to the particular filename packagename_version.orig.tar.gz.
• the character separating package and version is changed from - (hyphen) to _ (underscore)
• .orig is added in the file extension.
4. The Debian package specification files are added to the upstream source under the package-version/debian/
directory.
31
CHAPTER 5. BASICS 5.1. PACKAGING WORKFLOW
debian/rules The executable script for building the Debian package (see Section 5.4)
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 5.5)
debian/changelog The Debian package history file defining the upstream package version and the
Debian revision in its first line (see Section 5.6)
debian/copyright The copyright and license summary (see Section 5.7)
• Optional specification files under the debian/* (see Section 5.11):
• The debmake command invoked in the package-version/ directory provides the initial set of these
template 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 pdebuild) is invoked in the package-
version/ directory to make the Debian source and binary packages by invoking the debian/rules script.
6. Check the quality of the Debian package with the lintian command. (recommended)
8. Upload the set of the Debian source and binary package files with the dput command to the Debian archive.
Here, please replace each part of the filename as:
• the package part with the Debian source package name
• the binarypackage part with the Debian binary package name
32
CHAPTER 5. BASICS 5.2. PACKAGE NAME AND VERSION
Tip
Many patch management and VCS usage strategies for the Debian packaging
are practiced. You don’t need to use all of them.
Tip
• using the dh command to invoke many utility scripts automatically from the debhelper package, and
• 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.
33
CHAPTER 5. BASICS 5.3. NATIVE DEBIAN PACKAGE
In order to manage the package name and version information effectively under popular tools such as the
aptitude command, it is a good idea to keep the length of package name to be equal or less than 30 characters; and
the total length of version and revision to be equal or less than 14 characters. 1
In order to avoid name collisions, the user visible binary package name should not be chosen from any generic
words.
If upstream does not use a normal versioning scheme such as 2.30.32 but uses some kind of date such as
11Apr29, a random codename string, or a VCS hash value as part of the version, make sure to remove them from
the upstream version. Such information can be recorded in the debian/changelog file. If you need to invent a
version string, use the YYYYMMDD format such as 20110429 as upstream version. This ensures that the dpkg
command interprets later versions correctly as upgrades. If you need to ensure a smooth transition to a normal
version scheme such as 0.1 in the future, use the 0~YYMMDD format such as 0~110429 as upstream version,
instead.
Version strings can be compared using the dpkg command as follows.
0.0 < 0.5 < 0.10 < 0.99 < 1 < 1.0~rc1 < 1.0 < 1.0+b1 < 1.0+nmu1 < 1.1 < 2.0
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.
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
1 For more than 90% of packages, the package name is equal or less than 24 characters; the upstream version is equal or less than 10
34
CHAPTER 5. BASICS 5.4. DEBIAN/RULES
If you need to create a native Debian package, create it in the “3.0 (native)” format using dpkg-source(1).
Tip
Some people promote packaging even programs that have been written only for
Debian in the non-native package format. The required tarball without debian/*
files needs to be manually generated in advance before the standard workflow
in Section 5.1. a They claim that the use of non-native package format eases
communication with the downstream distributions.
a Use of the “debmake -t …” command can help this workflow. See Section 6.2.
Tip
There is no need to create the tarball in advance if the native package format is
used. The native Debian package can be created by setting the debian/source/-
format file to “3.0 (native)”, setting the debian/changelog file to have the version
without the Debian revision (1.0 instead of 1.0-1), and invoking the “dpkg-source
-b .” command within the source tree. The tarball containing the source is gen-
erated by this.
5.4 debian/rules
The debian/rules script is the executable script to build the Debian package.
• The debian/rules script re-targets the upstream build system (see Section 5.16) to install files in the $(DEST-
DIR) and creates the archive file of the generated files as the deb file.
– The deb file is used for the binary distribution and installed to the system using the dpkg command.
• The dh command is normally used as the front-end to the build system inside the debian/rules script.
• $(DESTDIR) path depends on the build type.
5.4.1 dh
The dh command from the debhelper package with help from its associated packages functions as the wrapper
to the typical upstream build systems and offers us uniform access to them by supporting all the Debian policy
stipulated targets of the debian/rules file.
• 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
35
CHAPTER 5. BASICS 5.4. DEBIAN/RULES
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.)
#!/usr/bin/make -f
#export DH_VERBOSE = 1
%:
dh $@
Essentially, this dh command functions as the sequencer to call all required dh_* commands at the right mo-
ment.
Note
The debmake command sets the debian/control file with “Build-Depends: deb-
helper (>=9)” and the debian/compat file with “9”.
Tip
36
CHAPTER 5. BASICS 5.4. DEBIAN/RULES
• setup.py, or
• Build.PL.
If this is the case, you should add the override_dh_auto_build target and executing the “dh_auto_build --
arguments” command. This ensures passing arguments to the such build system after the default parameters that
dh_auto_build usually passes.
Tip
Please try not to execute the above build system commands directly if they are
supported by the dh_auto_build command.
The debmake command creates the initial template file taking advantage of the above simple debian/rules file
example while adding some extra customizations for package hardening, etc. You need to know how underlying
build systems work under the hood (see Section 5.16) to address their irregularities using package customization.
• See Section 4.6 for basic customization of the template debian/rules file generated by the debmake com-
mand.
• See Section 5.20 for multiarch customization.
• See Section 5.21 for hardening customization.
37
CHAPTER 5. BASICS 5.5. DEBIAN/CONTROL
Tip
It was useful to include buildflags.mk in debian/rules to set the build flags
such as CPPFLAGS, CFLAGS, LDFLAGS, etc. properly while honoring
DEB_CFLAGS_MAINT_APPEND, DEB_BUILD_MAINT_OPTIONS, etc. for
the debhelper “compat <= 8”. Now you should use the debhelper “compat >=
9”, should not include buildflags.mk without specific reasons, and should let the
dh command set these build flags.
• Use “dh $@” in the debian/rules to access the latest debhelper features.
• Export the build environment as “LC_ALL=C.UTF-8” (see Section 7.15).
• Set the timestamp used in the upstream source from the value of the debhelper-provided environment variable
$SOURCE_DATE_EPOCH.
– ReproducibleBuilds Howto.
– ReproducibleBuilds TimestampsProposal.
5.5 debian/control
The debian/control file consists of blocks of meta data separated by a blank line. Each block of meta data defines
the following in this order:
38
CHAPTER 5. BASICS 5.5. DEBIAN/CONTROL
5.5.1.1 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:
• Multi-Arch:
• Depends:
• Pre-Depends:
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, e.g., in the full form “foo:bin,foo-doc:doc,libfoo1:lib,libfoo-
dev:dev” or in the short form, “-doc,libfoo1,libfoo-dev”.
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)
• python: Python script package (all, foreign) (alias: py)
• python3: Python3 script package (all, foreign) (alias: py3)
• ruby: Ruby script package (all, foreign) (alias: rb)
• script: Shell script package (all, foreign) (alias: sh)
The pair values in the parentheses, such as (any, foreign), are the Architecture and Multi-Arch stanza values
set in the debian/control file.
In many cases, the debmake command makes good guesses for type from binarypackage. If type is not
obvious, type is set to bin. For example, libfoo sets type to lib, and font-bar sets type to data, …
If the source tree contents do not match settings for type, the debmake command warns you.
39
CHAPTER 5. BASICS 5.5. DEBIAN/CONTROL
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:
• Use the unversioned -dev package name: libfoo-dev
– This is the typical one for leaf library packages.
– Only one version of the library source package is allowed in the archive.
* The associated library package needs to be renamed from libfoo7 to libfoo8 to prevent dependency
breakage in the unstable archive 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.
* Make all dependent packages depend on libfoo-dev.
* Make both libfoo7-dev and libfoo8-dev provide libfoo-dev.
* The source package needs to be renamed as libfoo7-7.0.tar.gz and libfoo8-8.0.tar.gz respectively
from libfoo-?.0.tar.gz.
* The package specific install file path including libfoo7 and libfoo8 respectively for header files
etc. needs to be chosen to make them co-installable.
– Do not use this heavy handed approach, if possible.
– This approach should be used if the update of multiple dependent packages require manual code updates,
etc. (API change) Otherwise, the affected packages become RC buggy with FTBFS.
Tip
If the data encoding scheme changes (e.g., latin1 to utf-8), the same care as the
API change needs to be taken.
40
CHAPTER 5. BASICS 5.6. DEBIAN/CHANGELOG
5.5.2 Substvar
The debian/control file also defines the package dependency in which the variable substitutions mechanism (sub-
stvar) 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.
5.6 debian/changelog
The debian/changelog file records the Debian package history and defines the upstream package version and the
Debian revision in its first line. The changes need to be documented in the specific, formal, and concise style.
• Even if you are uploading your package by yourself, you must document all non-trivial user-visible changes
such as:
41
CHAPTER 5. BASICS 5.7. DEBIAN/COPYRIGHT
• 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 second guess your thought behind your package.
– The sponsor’s time is more valuable than yours.
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.
The debchange command (alias dch) is commonly used to edit this.
Tip
You can edit the debian/changelog file manually with any text editor as long as
you follow the formatting convention used by the debchange command.
Tip
The date string used in the debian/changelog file can be manually generated
by the “LC_ALL=C date -R” command.
5.7 debian/copyright
Debian takes the copyright and license matters very seriously. The “Debian Policy Manual” enforces having a
summary of them in the debian/copyright file in the package.
You should format it as a machine-readable debian/copyright file (DEP-5).
Caution
The debian/copyright file should be sorted to keep the generic file patterns at
the top of the list. See Section 6.4.
The debmake command creates the initial DEP-5 compatible template file by scanning the entire source tree.
It uses an internal license checker to classify each license text. 5
Unless specifically requested to be pedantic with the -P option, the debmake command skips reporting for
auto-generated files with permissive licenses to be practical.
4 Ifyou are using the vim editor, make sure to save this with the “:wq” command.
5 The licensecheck command from the devscripts package was referenced to make this internal checker. Now the licensecheck command
is provided in an independent licensecheck package with a lot of improvements.
42
CHAPTER 5. BASICS 5.8. DEBIAN/PATCHES/*
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
The debmake command focuses on bunching up same copyright and license
claims in detail to create template for debian/copyright. In order to do this within
reasonable time, it only picks the first section which looks like copyright and li-
cense claims. So its license assignment may not be optimal. Please also use
other tools such as licensecheck.
Tip
You are highly encouraged to check the license status with the licensecheck(1)
command and, as needed, with your manual code review.
5.8 debian/patches/*
The -p1 patches in the debian/patches/ directory are applied in the sequence defined in the debian/patches/series
file to the upstream source tree before the build process.
Note
The native Debian package (see Section 5.3) doesn’t use these files.
* Patches may come from other distros, mailing list postings, or cherry-picked patches from the
upstream git repository with the “git format-patches” command
– Missing the .pc/ directory
– Unmodified upstream source tree
– Manually update the debian/patches/series file
43
CHAPTER 5. BASICS 5.8. DEBIAN/PATCHES/*
Wherever these patches come from, it is a good idea to tag them with a DEP-3 compatible header.
Tip
The dgit package offers an alternative git integration tool with the Debian package
archive.
5.8.1 dpkg-source -x
The “dpkg-source -x” command unpacks the Debian source package.
It normally applies the patches in the debian/patches/ directory to the source tree and records the patch state
in the .pc/ directory.
If you wish to keep the source tree unmodified (for example, for use in Section 5.13), please use the --skip-
patches option.
44
CHAPTER 5. BASICS 5.9. DEBIAN/UPSTREAM/SIGNING-KEY.ASC
There is one advantage of using the dpkg-source command over the dquilt command. While the dquilt com-
mand cannot handle modified binary files automatically, the dpkg-source command detects modified binary files
and lists them in the debian/source/include-binaries file to include them in the Debian tarball.
5.9 debian/upstream/signing-key.asc
Some packages are signed by a GPG key.
For example, GNU hello can be downloaded via HTTP from https://ftp.gnu.org/gnu/hello/ . There are sets of
files:
$ wget https://ftp.gnu.org/gnu/hello/hello-2.9.tar.gz
...
$ wget https://ftp.gnu.org/gnu/hello/hello-2.9.tar.gz.sig
...
$ 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: Can't check signature: public key not found
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.
Tip
If your network environment blocks access to the HKP port 11371, use
“hkp://keyserver.ubuntu.com:80” instead.
After confirming the key ID 80EE4A00 is a trustworthy one, download its public key into the debian/upstream/signing-
key.asc file.
45
CHAPTER 5. BASICS 5.10. DEBIAN/WATCH AND DFSG
version=4
pgpsigurlmangle=s/$/.sig/ https://ftp.gnu.org/gnu/hello/ hello-(\d[\d.]*)\.tar ←-
\.(?:gz|bz2|xz)
Now the uscan command will check the authenticity of the package using the GPG signature.
• The resulting tarball has the version number with an additional suffix +dfsg.
Tip
Check debhelper(7) for the latest available set of the dh_* commands.
These debian/binarypackage.* files provide very powerful means to set the installation path of files. Even an
upstream source without its build system can be packaged just by using these files. See Section 8.2 as an example.
The ”-x[1234] ” superscript notation that appears in the following list indicates the minimum value for the deb-
make -x option that will generate the associated template file. See Section 6.6 or debmake(1) for details.
Here is the alphabetical list of notable optional configuration files.
binarypackage.bug-control -x3 installed as usr/share/bug/binarypackage/control in binarypackage. See Sec-
tion 5.24.
46
CHAPTER 5. BASICS 5.11. OTHER DEBIAN/* FILES
binarypackage.conffile No need for this file under “compat >= 3” since all files in the etc/ directory are conffiles.
If the program you’re packaging requires every user to modify the configuration files in the /etc directory,
there are two popular ways to arrange for them not to be conffiles, keeping the dpkg command happy and
quiet.
• Create a symlink under the /etc directory pointing to a file under the /var directory generated by the
maintainer scripts.
• Create a file generated by the maintainer scripts under the /etc directory.
See dh_installdeb(1).
binarypackage.config This is the debconf config script used for asking any questions necessary to configure the
package. See Section 5.19.
47
CHAPTER 5. BASICS 5.11. OTHER DEBIAN/* FILES
48
CHAPTER 5. BASICS 5.11. OTHER DEBIAN/* FILES
README.Debian -x1 Installed into the first binary package listed in the debian/control file as usr/share/-
doc/binarypackage/README.Debian.
See dh_installdocs(1).
This file provides the information specific to the Debian package.
binarypackage.service -x3 If this exists, it is installed into lib/systemd/system/binarypackage.service in binary-
package.
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 or source.lintian-overrides -x3 These files are not installed, but will be 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 main-
tainer.
See “FILE FORMATS” in dpkg-source(1).
source/local-patch-header 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 main-
tainer.
+ See “FILE FORMATS” in dpkg-source(1).
binarypackage.symbols -x2 The symbols files, if present, are passed to the dpkg-gensymbols command to be
processed and installed.
See dh_makeshlibs(1) and Section 5.18.1..
binarypackage.templates This is the debconf templates file used for asking any questions necessary to configure
the package. See Section 5.19.
tests/control This is the RFC822-style test meta data file defined in DEP-8. See autopkgtest(1) and Section 5.22.
TODO Installed into the first binary package listed in the debian/control file as usr/share/doc/binarypackage/TODO.Debian.
See dh_installdocs(1).
binarypackage.tmpfile -x3 If this exists, it is installed into usr/lib/tmpfiles.d/binarypackage.conf in binarypack-
age.
See dh_systemd_enable(1), dh_systemd_start(1), and dh_installinit(1).
binarypackage.upstart -x3 If this exists, it is installed into etc/init/package.conf in the package build directory.
(deprecated)
See dh_installinit(1) and Section 8.1.
watch -x1 The control file for the uscan command to download the latest upstream version.
This control file may be configured to verify the authenticity of the tarball using its GPG signature (see
Section 5.9).
See Section 5.10 and uscan(1).
49
CHAPTER 5. BASICS 5.12. CUSTOMIZATION OF THE DEBIAN …
• 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.
• Unusual 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.
• 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 5.11).
When these are not sufficient to make a good Debian package, modifications to the upstream source recorded
as the -p1 patches in the debian/patches/ directory is deployed. These patches are applied in the sequence defined
in the debian/patches/series file before building the package (see Section 5.8). Simple examples are given in
Section 4.8.
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.
• master branch
• upstream branch
– Record the upstream source tree untarred from the released upstream tarball.
50
CHAPTER 5. BASICS 5.14. RECORDING IN VCS (ALTERNATIVE)
Tip
It’s a good idea to add to the .gitignore file the listing .pc.
Tip
Tip
You may also track the upstream VCS data with a branch different from the up-
stream branch to ease cherry-picking of patches.
Let the dpkg-source command invoked by the Debian package build process (dpkg-buildpackage, debuild,
…) generate the -p1 patch file debian/patches/debian-changes automatically.
Tip
This approach can be adopted for any VCS tools. Since this approach merges
all changes into a merged patch, it is desirable to keep the VCS data publicly
accessible.
51
CHAPTER 5. BASICS 5.15. BUILDING PACKAGE WITHOUT …
Tip
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.
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 3.5.
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 5. BASICS 5.16. UPSTREAM BUILD SYSTEMS
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 3.5 is too ag-
gressive. You can work around this problem by dropping the -I option for DE-
BUILD_DPKG_BUILDPACKAGE_OPTS in Section 3.5 while adding the “tar-
ignore=…” lines in the debian/source/local-options file for each package.
Tip
Before attempting to make a Debian package, you should become familiar with
the upstream build system of the upstream source code and try to build it.
53
CHAPTER 5. BASICS 5.16. UPSTREAM BUILD SYSTEMS
5.16.1 Autotools
Autotools (autoconf + automake) has 4 steps.
1. set up the build system (“vim configure.ac Makefile.am” and “autoreconf -ivf”)
2. configure the build system (“./configure”)
• Autotools Tutorial
• Introduction to the autotools (autoconf, automake, and libtool)
• Autotools Mythbuster
5.16.2 CMake
CMake has 4 steps.
The upstream tarball contains no auto-generated files and is generated by the tar command after step 1.
The package maintainer needs to take care of steps 2 to 4.
If you wish to learn more on the CMake, please see:
• CMake
• CMake tutorial
54
CHAPTER 5. BASICS 5.17. DEBUGGING INFORMATION
The upstream maintainer usually performs step 1 and builds the upstream tarball for distribution using the
“python setup.py sdist” command.
The package maintainer needs to take care of step 2. This is realized simply by the “dh $@” command used in
the debian/rules file, after jessie.
The situation of other build systems, such as CMake, are very similar to this Python one.
If you wish to learn more on Python3 and distutils, please see:
• Python3
• distutils
• dh_strip(1)
• strip(1)
• readelf(1)
• objcopy(1)
55
CHAPTER 5. BASICS 5.18. LIBRARY PACKAGE
* 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:
56
CHAPTER 5. BASICS 5.19. DEBCONF
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.
Caution
5.19 debconf
The debconf package enables us to configure packages during their installation in 2 main ways:
• non-interactively from the debian-installer pre-seeding.
• interactively from the menu interface (dialog, gnome, kde, …)
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.
57
CHAPTER 5. BASICS 5.20. MULTIARCH
• debian/binarypackage.template
– This is the debconf templates file used for asking any questions necessary to configure the package.
• package configuration scripts
– 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 “De-
bian Policy Manual”.
5.20 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
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:
See:
• Section 5.4.4
• dpkg-architecture(1)
• Section 5.5.1.1
• Section 5.5.1.2
58
CHAPTER 5. BASICS 5.20. MULTIARCH
Note
The --libexecdir option of the ./configure command specifies the default path to
install executable programs run by other programs rather than by users. Its Au-
totools default is /usr/libexec/ but its Debian non-multi-arch default is /usr/lib/.
If such executables are a part of a ”Multi-arch: foreign” package, a path such as
/usr/lib/ or /usr/lib/packagename may be more desirable than /usr/lib/<triplet>/,
which dh_auto_configure uses. The GNU Coding Standards: 7.2.5 Variables
for Installation Directories has a description for libexecdir as ”The definition of
libexecdir is the same for all packages, so you should install your data in a sub-
directory thereof. Most packages install their data under $(libexecdir)/package-
name/ …”. (It is always a good idea to follow GNU unless it conflicts with the
Debian policy.)
The shared library files in the default path /usr/lib/ and /usr/lib/<triplet>/ are loaded automatically.
For shared library files in another path, the GCC option -l must be set by the pkg-config command to make
them load properly.
59
CHAPTER 5. BASICS 5.21. COMPILER HARDENING
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>/.
8
The use of the file path containing packagename enables having more than 2 development libraries simultane-
ously installed on a system.
5.23 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 during
bootstrapping, the build-dependency needs to be reduced using the profile builds feature.
8 This path is compliant with the FHS. Filesystem Hierarchy Standard: /usr/lib : Libraries for programming and packages states ”Applica-
tions may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the
application must be placed within that subdirectory.”
60
CHAPTER 5. BASICS 5.24. BUG REPORTS
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.
• 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.
Tip
If you always remind the bug reporter of something or ask them about their situ-
ation, use these files to automate it.
61
Chapter 6
debmake options
Tip
Tip
For other interpreted languages that support the -b option, specify the pertinent type for the -b option.
For interpreted languages without the -b option support, specify the script type instead and add the interpreter
package as a dependency of the resulting binary package by adjusting the debian/control file.
62
CHAPTER 6. DEBMAKE OPTIONS 6.2. UPSTREAM SNAPSHOT (-D, -T)
$ cd /path/to/upstream-vcs
$ debmake -d -i debuild
Alternatively, the same can be made with the -t option if the upstream tarball can be made with the tar command.
$ cd /path/to/upstream-vcs
$ debmake -p package -t -i debuild
Unless you provide the upstream version with the -u option or with the debian/changelog file, a snapshot
upstream version is generated in the 0~%y%m%d%H%M format, e.g., 0~1403012359, from the UTC date and
time.
If the upstream VCS is hosted in the package/ directory instead of the upstream-vcs/ directory, the “-p package”
can be skipped.
If the upstream source tree in the VCS contains the debian/* files, the debmake command with either the -d
option or the -t option combined with the -i option automates 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 using the “debmake -t -i debuild” command may be
considered as the quasi-native Debian package scheme since the packaging situation resembles the native Debian
binary package building case using the debuild command without the upstream tarball.
Use of a non-native Debian package helps to ease communication with the downstream distros such as Ubuntu
for bug fixes etc.
6.4 debmake -k
When updating a package for the new upstream release, the debmake command can verify the content of the
existing debian/copyright file against the copyright and license situation of the entire updated source tree.
$ cd package-vcs
$ gbp import-orig --uscan --pristine-tar
... update source with the new upstream release
$ debmake -k | less
63
CHAPTER 6. DEBMAKE OPTIONS 6.5. DEBMAKE -J
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.
6.5 debmake -j
The generation of a functioning multi-binary package always requires more manual work than that of a functioning
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 4) 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, ..."
$ 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.
64
CHAPTER 6. DEBMAKE OPTIONS 6.6. DEBMAKE -X
6.6 debmake -x
The amount of template files generated by the debmake command depends on the -x[01234] option.
• See Section 8.1 for cherry-picking of the template files.
Note
None of the existing configuration files are modified by the debmake command.
6.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.
6.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.
65
Chapter 7
Tips
7.1 debdiff
You can compare file contents in two source Debian packages with the debdiff command.
You can also compare file lists in two sets of binary Debian packages with the debdiff command.
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.
7.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
7.3 debc
You should install generated packages with the debc command to test it locally.
$ debc package_version-rev_arch.changes
7.4 piuparts
You should install generated packages with the piuparts command to test it automatically.
66
CHAPTER 7. TIPS 7.5. DEBSIGN
Note
This is a very slow process with remote APT package repository access.
7.5 debsign
After completing the test of the package, you can sign it with the debsign command.
$ debsign package_version-rev_arch.changes
7.6 dput
After signing the package with the debsign command, you can upload the set of files for the Debian source and
binary packages with the dput command.
$ dput package_version-rev_arch.changes
7.7 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.
7.8 git-buildpackage
The git-buildpackage package offers many commands to automate packaging activities using the git repository.
• gbp import-dsc: import the previous Debian source package to the git repository.
• gbp import-orig: import the new upstream tar to the git repository.
– The --pristine-tar option for the git import-orig command enables storing the upstream tarball in the
same git repository.
– The --uscan option as the last argument of the gbp import-orig command enables downloading and
committing the new upstream tarball into the git repository.
• gbp dch: generate the Debian changelog from the git commit messages.
• gbp buildpackage: build the Debian binary package from the git repository.
• gbp pull: update the debian, upstream and pristine-tar branches safely from the remote repository.
• git-pbuilder: build the Debian binary package from the git repository using the pbuilder package.
• The gbp pq, git-dpm or quilt (or alias dquilt) commands are used to manage quilt patches.
67
CHAPTER 7. TIPS 7.9. UPSTREAM GIT REPOSITORY
– The dquilt command is the simplest to learn and requires you to commit the resulting files manually
with the git command to the master branch.
– The “gbp pq” command provides the equivalent functionality of patch set management without using
dquilt and eases including upstream git repository changes by cherry-picking.
– The “git dpm” command provides more enhanced functionality than that of the ‘gbp pq’’ command.
Package history management with the git-buildpackage package is becoming the standard practice for most
Debian maintainers.
See:
• Building Debian Packages with git-buildpackage
• https://wiki.debian.org/GitPackagingWorkflow
• https://wiki.debian.org/GitPackagingWorkflow/DebConf11BOF
• https://raphaelhertzog.com/2010/11/18/4-tips-to-maintain-a-3-0-quilt-debian-source-package-in-a-vcs/
• The systemd packaging practice documentation on Building from source.
Tip
Relax. You don’t need to use all the wrapper tools. Use only ones which match
your needs.
Tip
Caution
The content of the released upstream tarball may not match exactly with the cor-
responding content of the upstream git repository. It may contain some auto-
generated files or miss some files. (Autotools, distutils, …)
68
CHAPTER 7. TIPS 7.10. CHROOT
7.10 chroot
The chroot for a clean package build environment can be created and managed using the tools described in Chap-
ter 3. 1
Here is a quick summary of available package build commands. There are many ways to do the same thing.
• dpkg-buildpackage = core of package building tool
• debuild = dpkg-buildpackage + lintian (build under the sanitized environment variables)
• pbuilder = core of the Debian chroot environment tool
• pdebuild = pbuilder + dpkg-buildpackage (build in the chroot)
• cowbuilder = speed up the pbuilder execution
• git-pbuilder = the easy-to-use command line syntax for pdebuild (used by gbp buildpackge)
• gbp = manage the Debian source under git
• gbp buildpackge = pbuilder + dpkg-buildpackage + gbp
A clean sid distribution chroot environment can be used as follows.
• The chroot filesystem creation command for the sid distribution
– pbuilder create
– git-pbuilder create
• The master chroot filesystem path for the sid distribution chroot filesystem
– /var/cache/pbuilder/base.cow
– pdebuild
– git-pbuilder
– gbp buildpackage
– pbuilder --update
– git-pbuilder update
• The master chroot filesystem path for the dist distribution chroot
– path: /var/cache/pbuilder/base-dist.cow
– pdebuild -- --basepath=/var/cache/pbuilder/base-dist.cow
1 The git-pbuilder style organization is deployed here. See https://wiki.debian.org/git-pbuilder . Be careful since many HOWTOs use
different organization.
69
CHAPTER 7. TIPS 7.10. CHROOT
– DIST=dist git-pbuilder
– gbp buildpackage --git-dist=dist
• The command to update the dist chroot
– pbuilder update --basepath=/var/cache/pbuilder/base-dist.cow
– DIST=dist git-pbuilder update
• The command to login to the dist chroot to modify it
– pbuilder --login --basepath=/var/cache/pbuilder/base-dist.cow --save-after-login
– DIST=dist git-pbuilder login --save-after-login
Tip
A custom environment with some pre-loaded packages needed for the new ex-
perimental packages, this “git-pbuilder login --save-after-login” command is
quite handy.
Tip
Tip
The chroot filesystem can be cloned simply by copying with the “cp -a base-
dist.cow base-customdist.cow” command. The new chroot filesystem can be
accessed as “gbp buildpackage --git-dist=customdist” and “DIST=customdist
git-pbuilder …”.
Tip
When the orig.tar.gz file needs to be uploaded for a Debian revision other than
0 or 1 (e.g., for a security upload), add the -sa option to the end of dpkg-
buildpackage, debuild, pdebuild, and git-pbuilder commands. For the “gbp
buildpackage” command, temporarily modify the builder setting of ~/.gbp.conf.
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.
70
CHAPTER 7. TIPS 7.11. NEW DEBIAN REVISION
$ dquilt push -a
$ dquilt new bugname.patch
$ dquilt add buggy
$ vim buggy
...
$ dquilt refresh
$ dquilt header -e
$ dquilt pop -a
$ dch -i
Alternatively if the package is managed in the git repository using the git-buildpackage command with its
default configuration:
New Debian revision with the gbp-pq command
Please make sure to describe concisely the changes that fix reported bugs and close those bugs by adding
“Closes: #<bug_number>” in the debian/changelog file.
Tip
71
CHAPTER 7. TIPS 7.12. NEW UPSTREAM RELEASE
$ wget https://example.org/foo/foo-newversion.tar.gz
$ cd foo-oldversion
$ uupdate -v newversion ../foo-newversion.tar.gz
...
$ cd ../foo-newversion
$ while dquilt push; do dquilt refresh; done
$ dch
7.12.2 uscan
You can automatically update to the new upstream source with the uscan command from the devscripts package.
It requires having the old Debian source package and the debian/watch file in it.
$ cd foo-oldversion
$ uscan
...
$ while dquilt push; do dquilt refresh; done
$ dch
7.12.3 gbp
You can automatically update to the new upstream source with the “gbp import-orig --pristine-tar” command
from the git-buildpackage package. It requires having the old Debian source in the git repository and the new
upstream tarball.
Tip
If upstream uses a git repository, please also use the --upstream-vcs-tag option
for the gbp import-orig command.
72
CHAPTER 7. TIPS 7.13. 3.0 SOURCE FORMAT
$ cd foo-vcs
$ git checkout master
$ gbp pq import
$ git checkout master
$ gbp import-orig --pristine-tar --uscan
...
$ gbp pq rebase
$ git checkout master
$ gbp pq export
$ gbp pq drop
$ git add debian/patches
$ dch -v <newversion>
$ git commit -a -m "Refresh patches"
Tip
If upstream uses a git repository, please also use the --upstream-vcs-tag option
for the gbp import-orig command.
7.14 CDBS
The Common Debian Build System (CDBS) is a wrapper system over the debhelper package. The CDBS is based
on the Makefile inclusion mechanism and configured by the DEB_* configuration variables set in the debian/rules
file.
Before the introduction of the dh command to the debhelper package at the version 7, the CDBS was the only
approach to create a simple and clean debian/rules file.
3 You can split the big.diff file into many small incremental patch files using the splitdiff command.
73
CHAPTER 7. TIPS 7.15. BUILD UNDER UTF-8
For many simple packages, the dh command alone allows us to make a simple and clean debian/rules file now.
It is desirable to keep the build system simple and clean by not using the superfluous CDBS.
Note
Neither “the CDBS magically does the job for me with less typing” nor “I don’t un-
derstand the new dh syntax” can be an excuse to keep using the CDBS system.
For some complicated packages such as GNOME related ones, the CDBS is leveraged to automate their uniform
packaging by the current maintainers with justification. If this is the case, please do not bother converting from the
CDBS to the dh syntax.
Note
If you are working with a team of maintainers, please follow the established prac-
tice of the team.
When converting packages from the CDBS to the dh syntax, please use the following as your reference:
• CDBS Documentation
• The Common Debian Build System (CDBS), FOSDEM 2009
LC_ALL := C.UTF-8
export LC_ALL
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.
74
CHAPTER 7. TIPS 7.18. SKIPPED UPLOADS
• dpkg-buildpackage -sa
• debuild -sa
• pdebuild --debbuildopts -sa
• git-pbuilder -sa
Tip
On the other hand, the -sd option will force the exclusion of the original orig.tar.gz
source.
Tip
• dpkg-buildpackage -v1.2
• debuild -v1.2
• pdebuild --debbuildopts -v1.2
• git-pbuilder -v1.2
• For gbp buildpackage, edit the ~/.gbp.conf file.
• excluding some packages for the bootstrapping process (see also BuildProfileSpec)
75
CHAPTER 7. TIPS 7.20. OTHER DISTROS
– building packages with the DEB_BUILD_PROFILES environment variable set to the pertinent profile
name
– packagename_version.orig.tar.gz
– packagename_version.orig-componentname.tar.gz
– dpkg-source --commit
#!/bin/sh
FCSRPM=$(basename $1)
mkdir ${FCSRPM}; cd ${FCSRPM}/
wget $1
rpm2cpio ${FCSRPM} | cpio -dium
Many upstream tarballs contain the SPEC file named as packagename.spec or packagename.spec.in used by
the RPM system. This can be used as the baseline for the Debian package, too.
7.21 Debug
When you face build problems or core dumps of generated binary programs, you need to resolve them yourself.
That’s debug.
This is too deep a topic to describe here. So, let me just list few pointers and hints for some typical debug tools.
• core dump
– “man core”
– Update the “/etc/security/limits.conf” file to include the following:
– “info gdb”
– “Debugging with GDB” in /usr/share/doc/gdb-doc/html/gdb/index.html
76
CHAPTER 7. TIPS 7.21. DEBUG
– “man ltrace”
– Install the libterm-readline-gnu-perl package or its equivalent to add input line editing capability with
history support.
– “man lsof”
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”’ .
77
Chapter 8
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.
• Programing in the POSIX shell, Python3, and C.
• Method to create a desktop GUI program launcher with icon graphics.
• Conversion of a command from CLI to GUI.
• Conversion of a program to use gettext for internationalization and localization: POSIX shell, Python3, and
C sources.
• Overview of many build systems: Makefile, Python distutils, Autotools, and CMake.
Please note that Debian takes a few things seriously:
• Free software (a.k.a. Libre software)
• Stability and security of OS
• Universal OS realized via:
The typical packaging example presented in Chapter 4 is the prerequisite for this chapter.
Some details are intentionally left vague in the following sections. Please try to read the pertinent documentation
and practice yourself to find them out.
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.
78
CHAPTER 8. MORE EXAMPLES 8.1. CHERRY-PICK TEMPLATES
$ mkdir debhello-0.1
$ tree
.
└── debhello-0.1
1 directory, 0 files
Let’s generate the maximum amount of template files by specifying the -x4 option.
Let’s also use the “-p debhello -t -u 0.1 -r 1” options to make the missing upstream tarball.
$ cd ..
$ tree
.
├── debhello-0.1
│ └── debian
│ ├── README.Debian
│ ├── changelog
│ ├── clean
│ ├── compat
│ ├── control
│ ├── copyright
│ ├── debhello.bug-control.ex
│ ├── debhello.bug-presubj.ex
│ ├── debhello.bug-script.ex
│ ├── debhello.conffiles.ex
...
│ └── watch
├── debhello-0.1.tar.gz
└── debhello_0.1.orig.tar.gz -> debhello-0.1.tar.gz
5 directories, 51 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.
Tip
The generated template files can be made more verbose by invoking the deb-
make command with the -T option (tutorial mode).
79
CHAPTER 8. MORE EXAMPLES 8.2. NO MAKEFILE (SHELL, CLI)
$ wget http://www.example.org/download/debhello-0.2.tar.gz
...
$ tar -xzmf debhello-0.2.tar.gz
$ tree
.
├── debhello-0.2
│ ├── LICENSE
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ └── hello.1
│ └── scripts
│ └── hello
└── debhello-0.2.tar.gz
4 directories, 6 files
$ cat debhello-0.2/scripts/hello
#!/bin/sh -e
echo "Hello from the shell!"
echo ""
echo -n "Type Enter to exit this program: "
read X
$ 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;
80
CHAPTER 8. MORE EXAMPLES 8.2. NO MAKEFILE (SHELL, CLI)
$ cd debhello-0.2
$ debmake -b':sh'
I: set parameters
I: sanity check of parameters
I: pkg="debhello", ver="0.2", rev="1"
I: *** start packaging in "debhello-0.2". ***
I: provide debhello_0.2.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-0.2.tar.gz debhello_0.2.orig.tar.gz
I: pwd = "/path/to/debhello-0.2"
I: parse binary package settings: :sh
I: binary package=debhello Type=script / Arch=all M-A=foreign
...
$ cd ..
$ tree
.
├── debhello-0.2
│ ├── LICENSE
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── debian
│ │ ├── README.Debian
│ │ ├── changelog
│ │ ├── compat
│ │ ├── control
│ │ ├── copyright
│ │ ├── patches
│ │ │ └── series
│ │ ├── rules
│ │ ├── source
│ │ │ ├── format
│ │ │ └── local-options
│ │ └── watch
│ ├── man
│ │ └── hello.1
│ └── scripts
│ └── hello
├── debhello-0.2.tar.gz
└── debhello_0.2.orig.tar.gz -> debhello-0.2.tar.gz
7 directories, 17 files
$ cat debhello-0.2/debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
%:
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):
81
CHAPTER 8. MORE EXAMPLES 8.2. NO MAKEFILE (SHELL, CLI)
$ cat debhello-0.2/debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Firstname Lastname" <[email protected]>
Build-Depends: debhelper (>=11~)
Standards-Version: 4.1.4
Homepage: <insert the upstream URL, if relevant>
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 5.
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):
$ vim debhello-0.2/debian/rules
... hack, hack, hack, ...
$ cat debhello-0.2/debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
%:
dh $@
$ vim debhello-0.2/debian/control
... hack, hack, hack, ...
$ cat debhello-0.2/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper (>=11~)
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}
Description: example package in the debmake-doc package
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)'.
82
CHAPTER 8. MORE EXAMPLES 8.2. NO MAKEFILE (SHELL, CLI)
Warning
$ vim debhello-0.2/debian/install
... hack, hack, hack, ...
$ cat debhello-0.2/debian/install
data/hello.desktop usr/share/applications
data/hello.png usr/share/pixmaps
scripts/hello usr/bin
$ vim debhello-0.2/debian/manpages
... hack, hack, hack, ...
$ cat debhello-0.2/debian/manpages
man/hello.1
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=0.2):
$ tree debhello-0.2/debian
debhello-0.2/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── install
├── manpages
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
2 directories, 12 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 debhello-0.2
$ debuild
dpkg-buildpackage -us -uc -ui -i
...
fakeroot debian/rules clean
dh clean
...
debian/rules build
dh build
dh_update_autotools_config
dh_autoreconf
83
CHAPTER 8. MORE EXAMPLES 8.2. NO MAKEFILE (SHELL, CLI)
create-stamp debian/debhelper-build-stamp
fakeroot debian/rules binary
dh binary
dh_testroot
dh_prep
rm -f -- debian/debhello.substvars
rm -fr -- debian/.debhelper/generated/debhello/ debian/debhello/ debi...
...
fakeroot debian/rules binary
dh binary
...
$ cd ..
$ tree -FL 1
.
├── debhello-0.2/
├── debhello-0.2.tar.gz
├── debhello_0.2-1.debian.tar.xz
├── debhello_0.2-1.dsc
├── debhello_0.2-1_all.deb
├── debhello_0.2-1_amd64.build
├── debhello_0.2-1_amd64.buildinfo
├── debhello_0.2-1_amd64.changes
└── debhello_0.2.orig.tar.gz -> debhello-0.2.tar.gz
1 directory, 8 files
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:
84
CHAPTER 8. MORE EXAMPLES 8.3. MAKEFILE (SHELL, CLI)
debian/control
debian/copyright
debian/install
debian/manpages
debian/patches/
debian/patches/series
debian/rules
debian/source/
debian/source/format
debian/watch
$ dpkg -c debhello_0.2-1_all.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/applications/
-rw-r--r-- root/root ... ./usr/share/applications/hello.desktop
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
drwxr-xr-x root/root ... ./usr/share/man/
drwxr-xr-x root/root ... ./usr/share/man/man1/
-rw-r--r-- root/root ... ./usr/share/man/man1/hello.1.gz
drwxr-xr-x root/root ... ./usr/share/pixmaps/
-rw-r--r-- root/root ... ./usr/share/pixmaps/hello.png
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
.
85
CHAPTER 8. MORE EXAMPLES 8.3. MAKEFILE (SHELL, CLI)
├── debhello-1.0
│ ├── LICENSE
│ ├── Makefile
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ └── hello.1
│ └── scripts
│ └── hello
└── debhello-1.0.tar.gz
4 directories, 7 files
Here, the Makefile uses $(DESTDIR) and $(prefix) properly. All other files are the same as in Section 8.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
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:
: # 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 debhello-1.0
$ debmake -b':sh'
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
...
86
CHAPTER 8. MORE EXAMPLES 8.4. SETUP.PY (PYTHON3, CLI)
$ cat debhello-1.0/debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
%:
dh $@
#override_dh_auto_install:
# dh_auto_install -- prefix=/usr
#override_dh_install:
# dh_install --list-missing -X.pyc -X.pyo
$ vim debhello-1.0/debian/rules
... hack, hack, hack, ...
$ cat debhello-1.0/debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
%:
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 8.2.
There are several other template files under the debian/ directory. These also need to be updated.
Template files under debian/. (v=1.0):
$ tree debhello-1.0/debian
debhello-1.0/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
2 directories, 10 files
The rest of the packaging activities are practically the same as the ones in Section 8.2.
87
CHAPTER 8. MORE EXAMPLES 8.4. SETUP.PY (PYTHON3, CLI)
Debian packaging requires changing the last line to “python3 setup.py install --install-layout=deb” to install
files into the target system image location. This issue is automatically addressed when using the dh command for
Debian packaging.
Let’s get the source and make the Debian package.
Download debhello-1.1.tar.gz
$ wget http://www.example.org/download/debhello-1.1.tar.gz
...
$ tar -xzmf debhello-1.1.tar.gz
$ tree
.
├── debhello-1.1
│ ├── LICENSE
│ ├── MANIFEST.in
│ ├── PKG-INFO
│ ├── hello_py
│ │ └── __init__.py
│ ├── scripts
│ │ └── hello
│ └── setup.py
└── debhello-1.1.tar.gz
3 directories, 7 files
Here, the hello script and its associated hello_py module are as follows.
hello (v=1.1)
$ cat debhello-1.1/scripts/hello
#!/usr/bin/python3
import hello_py
if __name__ == '__main__':
hello_py.main()
hello_py/__init__.py (v=1.1)
$ cat debhello-1.1/hello_py/__init__.py
#!/usr/bin/python3
def main():
print('Hello Python3!')
input("Press Enter to continue...")
return
if __name__ == '__main__':
main()
These are packaged using the Python distutils with the setup.py and MANIFEST.in files.
setup.py (v=1.1)
$ cat debhello-1.1/setup.py
#!/usr/bin/python3
# vi:se ts=4 sts=4 et ai:
from distutils.core import setup
88
CHAPTER 8. MORE EXAMPLES 8.4. SETUP.PY (PYTHON3, CLI)
setup(name='debhello',
version='4.0',
description='Hello Python',
long_description='Hello Python program.',
author='Osamu Aoki',
author_email='[email protected]',
url='http://people.debian.org/~osamu/',
packages=['hello_py'],
package_dir={'hello_py': 'hello_py'},
scripts=['scripts/hello'],
classifiers = ['Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Topic :: Utilities',
],
platforms = 'POSIX',
license = 'MIT License'
)
MANIFEST.in (v=1.1)
$ cat debhello-1.1/MANIFEST.in
include MANIFEST.in
include LICENSE
Tip
Many modern Python packages are distributed using setuptools. Since setup-
tools is an enhanced alternative to distutils, this example is useful for them.
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 debhello-1.1
$ debmake -b':py3'
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
...
$ cat debhello-1.1/debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
89
CHAPTER 8. MORE EXAMPLES 8.4. SETUP.PY (PYTHON3, CLI)
#export DH_VERBOSE = 1
%:
dh $@ --with python3 --buildsystem=pybuild
$ cat debhello-1.1/debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Firstname Lastname" <[email protected]>
Build-Depends: debhelper (>=11~), dh-python, python3-all
Standards-Version: 4.1.4
Homepage: <insert the upstream URL, if relevant>
X-Python3-Version: >= 3.2
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 5.
Let’s make this Debian package better as the maintainer.
debian/rules (maintainer version, v=1.1):
$ vim debhello-1.1/debian/rules
... hack, hack, hack, ...
$ cat debhello-1.1/debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
%:
dh $@ --with python3 --buildsystem=pybuild
$ vim debhello-1.1/debian/control
... hack, hack, hack, ...
$ cat debhello-1.1/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper (>= 12~), dh-python, python3-all
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
X-Python3-Version: >= 3.2
Package: debhello
Architecture: all
90
CHAPTER 8. MORE EXAMPLES 8.5. MAKEFILE (SHELL, GUI)
Multi-Arch: foreign
Depends: ${misc:Depends}, ${python3:Depends}
Description: example package in the debmake-doc package
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)'.
The hello command does not come with the upstream-provided manpage; let’s add it as the maintainer.
debian/manpages etc. (maintainer version, v=1.1):
$ vim debhello-1.1/debian/hello.1
... hack, hack, hack, ...
$ vim debhello-1.1/debian/manpages
... hack, hack, hack, ...
$ cat debhello-1.1/debian/manpages
debian/hello.1
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 ones in Section 8.3.
Template files under debian/. (v=1.1):
$ tree debhello-1.1/debian
debhello-1.1/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── hello.1
├── manpages
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
2 directories, 12 files
91
CHAPTER 8. MORE EXAMPLES 8.5. MAKEFILE (SHELL, GUI)
$ wget http://www.example.org/download/debhello-1.2.tar.gz
...
$ tar -xzmf debhello-1.2.tar.gz
$ tree
.
├── debhello-1.2
│ ├── LICENSE
│ ├── Makefile
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ └── hello.1
│ └── scripts
│ └── hello
└── debhello-1.2.tar.gz
4 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!"
$ cat debhello-1.2/data/hello.desktop
[Desktop Entry]
Name=Hello
Name[fr]=Bonjour
Comment=Greetings
Comment[fr]=Salutations
Type=Application
Keywords=hello
Exec=hello
Terminal=false
Icon=hello.png
Categories=Utility;
$ cd debhello-1.2
$ debmake -b':sh'
I: set parameters
I: sanity check of parameters
I: pkg="debhello", ver="1.2", rev="1"
I: *** start packaging in "debhello-1.2". ***
I: provide debhello_1.2.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.2.tar.gz debhello_1.2.orig.tar.gz
I: pwd = "/path/to/debhello-1.2"
I: parse binary package settings: :sh
I: binary package=debhello Type=script / Arch=all M-A=foreign
...
92
CHAPTER 8. MORE EXAMPLES 8.5. MAKEFILE (SHELL, GUI)
$ cat debhello-1.2/debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Firstname Lastname" <[email protected]>
Build-Depends: debhelper (>=11~)
Standards-Version: 4.1.4
Homepage: <insert the upstream URL, if relevant>
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.
$ vim debhello-1.2/debian/control
... hack, hack, hack, ...
$ cat debhello-1.2/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper (>=11~)
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: zenity, ${misc:Depends}
Description: example package in the debmake-doc package
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)'.
$ tree debhello-1.2/debian
debhello-1.2/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
93
CHAPTER 8. MORE EXAMPLES 8.6. SETUP.PY (PYTHON3, GUI)
└── watch
2 directories, 10 files
The rest of the packaging activities are practically the same as in Section 8.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:
$ wget http://www.example.org/download/debhello-1.3.tar.gz
...
$ tar -xzmf debhello-1.3.tar.gz
$ tree
.
├── debhello-1.3
│ ├── LICENSE
│ ├── MANIFEST.in
│ ├── PKG-INFO
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── hello_py
│ │ └── __init__.py
│ ├── man
│ │ └── hello.1
│ ├── scripts
│ │ └── hello
│ └── setup.py
└── debhello-1.3.tar.gz
5 directories, 10 files
$ cat debhello-1.3/scripts/hello
#!/usr/bin/python3
import hello_py
if __name__ == '__main__':
hello_py.main()
hello_py/__init__.py (v=1.3)
$ cat debhello-1.3/hello_py/__init__.py
#!/usr/bin/python3
from gi.repository import Gtk
94
CHAPTER 8. MORE EXAMPLES 8.6. SETUP.PY (PYTHON3, GUI)
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()
setup.py (v=1.3)
$ cat debhello-1.3/setup.py
#!/usr/bin/python3
# vi:se ts=4 sts=4 et ai:
from distutils.core import setup
setup(name='debhello',
version='4.1',
description='Hello Python',
long_description='Hello Python program.',
author='Osamu Aoki',
author_email='[email protected]',
url='http://people.debian.org/~osamu/',
packages=['hello_py'],
package_dir={'hello_py': 'hello_py'},
scripts=['scripts/hello'],
data_files=[
('share/applications', ['data/hello.desktop']),
('share/pixmaps', ['data/hello.png']),
('share/man/man1', ['man/hello.1']),
],
classifiers = ['Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Topic :: Utilities',
],
platforms = 'POSIX',
license = 'MIT License'
)
95
CHAPTER 8. MORE EXAMPLES 8.6. SETUP.PY (PYTHON3, GUI)
MANIFEST.in (v=1.3)
$ cat debhello-1.3/MANIFEST.in
include MANIFEST.in
include LICENSE
include data/hello.deskto
include data/hello.png
include man/hello.1
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 debhello-1.3
$ debmake -b':py3'
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
...
$ vim debhello-1.3/debian/rules
... hack, hack, hack, ...
$ cat debhello-1.3/debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
%:
dh $@ --with python3 --buildsystem=pybuild
$ vim debhello-1.3/debian/control
... hack, hack, hack, ...
$ cat debhello-1.3/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper (>=11~), dh-python, python3-all
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
X-Python3-Version: >= 3.2
Package: debhello
Architecture: all
Multi-Arch: foreign
Depends: gir1.2-gtk-3.0, python3-gi, ${misc:Depends}, ${python3:Depends}
Description: example package in the debmake-doc package
This is an example package to demonstrate Debian packaging using
the debmake command.
.
96
CHAPTER 8. MORE EXAMPLES 8.7. MAKEFILE (SINGLE-BINARY PACKAGE)
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
...
$ tar -xzmf debhello-1.4.tar.gz
$ tree
.
├── debhello-1.4
│ ├── LICENSE
│ ├── Makefile
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ └── hello.1
│ └── src
│ ├── config.h
│ └── hello.c
└── debhello-1.4.tar.gz
4 directories, 8 files
$ cat debhello-1.4/src/hello.c
#include "config.h"
#include <math.h>
97
CHAPTER 8. MORE EXAMPLES 8.7. MAKEFILE (SINGLE-BINARY PACKAGE)
#include <stdio.h>
int
main()
{
printf("Hello, I am " PACKAGE_AUTHOR "!\n");
printf("4.0 * atan(1.0) = %10f8\n", 4.0*atan(1.0));
return 0;
}
src/config.h (v=1.4):
$ cat debhello-1.4/src/config.h
#define PACKAGE_AUTHOR "Osamu Aoki"
Makefile (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
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 debhello-1.4
$ debmake
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:
98
CHAPTER 8. MORE EXAMPLES 8.8. MAKEFILE.IN + CONFIGURE …
$ tree debhello-1.4/debian
debhello-1.4/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
2 directories, 10 files
The rest of the packaging activities are practically the same as the one in Section 4.7.
Here is the generated dependency list of all binary packages.
The generated dependency list of all binary packages (v=1.4):
99
CHAPTER 8. MORE EXAMPLES 8.8. MAKEFILE.IN + CONFIGURE …
$ wget http://www.example.org/download/debhello-1.5.tar.gz
...
$ tar -xzmf debhello-1.5.tar.gz
$ tree
.
├── debhello-1.5
│ ├── LICENSE
│ ├── Makefile.in
│ ├── configure
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ └── hello.1
│ └── src
│ └── hello.c
└── debhello-1.5.tar.gz
4 directories, 8 files
$ cat debhello-1.5/src/hello.c
#include "config.h"
#ifdef WITH_MATH
# include <math.h>
#endif
#include <stdio.h>
int
main()
{
printf("Hello, I am " PACKAGE_AUTHOR "!\n");
#ifdef WITH_MATH
printf("4.0 * atan(1.0) = %10f8\n", 4.0*atan(1.0));
#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 \
100
CHAPTER 8. MORE EXAMPLES 8.8. MAKEFILE.IN + CONFIGURE …
$(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"
;;
--with-math)
WITH_MATH="1"
LINKLIB="-lm"
;;
--author)
PACKAGE_AUTHOR="${VAL}"
;;
*)
echo "W: Unknown argument: ${1}"
esac
shift
done
101
CHAPTER 8. MORE EXAMPLES 8.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
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 debhello-1.5
$ debmake
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
...
The result is similar to Section 4.5 but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=1.5):
$ cat debhello-1.5/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,--as-needed
%:
dh $@
$ vim debhello-1.5/debian/rules
... hack, hack, hack, ...
$ cat debhello-1.5/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 -- \
--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 4.7.
102
CHAPTER 8. MORE EXAMPLES 8.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
This source usually comes with the upstream auto-generated Makefile.in and configure files, too. This source
can be packaged using these files as in Section 8.8 with the help of the autotools-dev package.
The better alternative is to regenerate these files using the latest Autoconf and Automake packages if the up-
stream provided Makefile.am and configure.ac are compatible with the latest version. This is advantageous for
porting to new CPU architectures, etc. This can be automated by using the “--with autoreconf” option for the dh
command.
Let’s assume this upstream tarball to be debhello-1.6.tar.gz.
This type of source is meant to be installed as a non-system file, for example, as:
$ wget http://www.example.org/download/debhello-1.6.tar.gz
...
$ tar -xzmf debhello-1.6.tar.gz
$ tree
.
├── debhello-1.6
│ ├── Makefile.am
│ ├── configure.ac
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ ├── Makefile.am
│ │ └── hello.1
│ └── src
│ ├── Makefile.am
│ └── hello.c
└── debhello-1.6.tar.gz
4 directories, 9 files
$ cat debhello-1.6/src/hello.c
#include "config.h"
#ifdef WITH_MATH
# include <math.h>
#endif
#include <stdio.h>
int
main()
{
printf("Hello, I am " PACKAGE_AUTHOR "!\n");
#ifdef WITH_MATH
printf("4.0 * atan(1.0) = %10f8\n", 4.0*atan(1.0));
#else
printf("I can't do MATH!\n");
#endif
return 0;
}
103
CHAPTER 8. MORE EXAMPLES 8.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
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.] )
])
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
104
CHAPTER 8. MORE EXAMPLES 8.9. AUTOTOOLS (SINGLE-BINARY PACKAGE)
Tip
$ cd debhello-1.6
$ debmake
I: set parameters
I: sanity check of parameters
I: pkg="debhello", ver="1.6", rev="1"
I: *** start packaging in "debhello-1.6". ***
I: provide debhello_1.6.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-1.6.tar.gz debhello_1.6.orig.tar.gz
I: pwd = "/path/to/debhello-1.6"
I: parse binary package settings:
I: binary package=debhello Type=bin / Arch=any M-A=foreign
...
The result is similar to Section 8.8 but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=1.6):
$ cat debhello-1.6/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,--as-needed
%:
dh $@ --with autoreconf
#override_dh_install:
# dh_install --list-missing -X.la -X.pyc -X.pyo
$ vim debhello-1.6/debian/rules
... hack, hack, hack, ...
$ cat debhello-1.6/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 $@ --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 4.7.
105
CHAPTER 8. MORE EXAMPLES 8.10. CMAKE (SINGLE-BINARY PACKAGE)
$ wget http://www.example.org/download/debhello-1.7.tar.gz
...
$ tar -xzmf debhello-1.7.tar.gz
$ tree
.
├── debhello-1.7
│ ├── CMakeLists.txt
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
│ ├── man
│ │ ├── CMakeLists.txt
│ │ └── hello.1
│ └── src
│ ├── CMakeLists.txt
│ ├── config.h.in
│ └── hello.c
└── debhello-1.7.tar.gz
4 directories, 9 files
$ cat debhello-1.7/src/hello.c
#include "config.h"
#ifdef WITH_MATH
# include <math.h>
#endif
#include <stdio.h>
int
main()
{
printf("Hello, I am " PACKAGE_AUTHOR "!\n");
#ifdef WITH_MATH
printf("4.0 * atan(1.0) = %10f8\n", 4.0*atan(1.0));
#else
printf("I can't do MATH!\n");
#endif
return 0;
}
106
CHAPTER 8. MORE EXAMPLES 8.10. CMAKE (SINGLE-BINARY PACKAGE)
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
)
$ cd debhello-1.7
$ debmake
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
...
The result is similar to Section 8.8 but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=1.7):
$ cat debhello-1.7/debian/rules
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
107
CHAPTER 8. MORE EXAMPLES 8.10. CMAKE (SINGLE-BINARY 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,--as-needed
%:
dh $@
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_TARGET_MULTIARCH)"
$ cat debhello-1.7/debian/control
Source: debhello
Section: unknown
Priority: optional
Maintainer: "Firstname Lastname" <[email protected]>
Build-Depends: cmake, debhelper (>=11~)
Standards-Version: 4.1.4
Homepage: <insert the upstream URL, if relevant>
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.
$ vim debhello-1.7/debian/rules
... hack, hack, hack, ...
$ cat debhello-1.7/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
$ vim debhello-1.7/debian/control
... hack, hack, hack, ...
$ cat debhello-1.7/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: cmake, debhelper (>=11~)
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
108
CHAPTER 8. MORE EXAMPLES 8.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: example package in the debmake-doc package
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)'.
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 8.8.
$ wget http://www.example.org/download/debhello-2.0.tar.gz
...
$ tar -xzmf debhello-2.0.tar.gz
$ tree
.
├── debhello-2.0
│ ├── Makefile.am
│ ├── 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
5 directories, 12 files
109
CHAPTER 8. MORE EXAMPLES 8.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
$ cat debhello-2.0/src/hello.c
#include "config.h"
#include <stdio.h>
#include <sharedlib.h>
int
main()
{
printf("Hello, I am " PACKAGE_AUTHOR "!\n");
sharedlib();
return 0;
}
$ cat debhello-2.0/lib/sharedlib.h
int sharedlib();
$ cat debhello-2.0/lib/sharedlib.c
#include <stdio.h>
int
sharedlib()
{
printf("This is a shared library!\n");
return 0;
}
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
110
CHAPTER 8. MORE EXAMPLES 8.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
• libsharedlib-dev: type = dev
Here, the -b’,libsharedlib1,libsharedlib-dev’ option is used to specify the generated binary packages.
$ cd debhello-2.0
$ debmake -b',libsharedlib1,libsharedlib-dev'
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
111
CHAPTER 8. MORE EXAMPLES 8.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
The result is similar to Section 8.8 but with more template files.
Let’s inspect the notable template files generated.
debian/rules (template file, v=2.0):
$ cat debhello-2.0/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,--as-needed
%:
dh $@ --with autoreconf
#override_dh_install:
# dh_install --list-missing -X.la -X.pyc -X.pyo
$ vim debhello-2.0/debian/rules
... hack, hack, hack, ...
$ cat debhello-2.0/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 $@ --with autoreconf
override_dh_install:
dh_install --list-missing -X.la
$ vim debhello-2.0/debian/control
... hack, hack, hack, ...
$ cat debhello-2.0/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: debhelper (>=11~), dh-autoreconf
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: libsharedlib1 (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Description: example executable package
This is an example package to demonstrate Debian packaging using
the debmake command.
112
CHAPTER 8. MORE EXAMPLES 8.11. AUTOTOOLS (MULTI-BINARY PACKAGE)
.
The generated Debian package uses the dh command offered by the
debhelper package and the dpkg source format `3.0 (quilt)'.
.
This package provides the executable program.
Package: libsharedlib1
Section: libs
Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: example shared library package
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)'.
.
This package contains the shared library.
Package: libsharedlib-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libsharedlib1 (= ${binary:Version}), ${misc:Depends}
Description: example development package
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)'.
.
This package contains the development files.
$ vim debhello-2.0/debian/debhello.install
... hack, hack, hack, ...
$ cat debhello-2.0/debian/debhello.install
usr/bin/*
usr/share/man/*
$ vim debhello-2.0/debian/libsharedlib1.install
... hack, hack, hack, ...
$ cat debhello-2.0/debian/libsharedlib1.install
usr/lib/*/*.so.*
$ vim debhello-2.0/debian/libsharedlib-dev.install
... hack, hack, hack, ...
$ cat debhello-2.0/debian/libsharedlib-dev.install
###usr/lib/*/pkgconfig/*.pc
usr/include
usr/lib/*/*.so
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):
$ tree debhello-2.0/debian
debhello-2.0/debian
├── README.Debian
├── changelog
├── compat
113
CHAPTER 8. MORE EXAMPLES 8.12. CMAKE (MULTI-BINARY PACKAGE)
├── control
├── copyright
├── debhello.install
├── libsharedlib-dev.install
├── libsharedlib1.install
├── libsharedlib1.symbols
├── patches
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
2 directories, 14 files
The rest of the packaging activities are practically the same as the one in Section 8.8.
Here are the generated dependency list of all binary packages.
The generated dependency list of all binary packages (v=2.0):
$ wget http://www.example.org/download/debhello-2.1.tar.gz
...
$ tar -xzmf debhello-2.1.tar.gz
$ tree
.
├── debhello-2.1
│ ├── CMakeLists.txt
│ ├── data
│ │ ├── hello.desktop
│ │ └── hello.png
114
CHAPTER 8. MORE EXAMPLES 8.12. CMAKE (MULTI-BINARY PACKAGE)
│ ├── lib
│ │ ├── CMakeLists.txt
│ │ ├── sharedlib.c
│ │ └── sharedlib.h
│ ├── man
│ │ ├── CMakeLists.txt
│ │ └── hello.1
│ └── src
│ ├── CMakeLists.txt
│ ├── config.h.in
│ └── hello.c
└── debhello-2.1.tar.gz
5 directories, 12 files
$ cat debhello-2.1/src/hello.c
#include "config.h"
#include <stdio.h>
#include <sharedlib.h>
int
main()
{
printf("Hello, I am " PACKAGE_AUTHOR "!\n");
sharedlib();
return 0;
}
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@"
$ cat debhello-2.1/lib/sharedlib.h
int sharedlib();
$ cat debhello-2.1/lib/sharedlib.c
#include <stdio.h>
int
sharedlib()
{
printf("This is a shared library!\n");
return 0;
}
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
115
CHAPTER 8. MORE EXAMPLES 8.12. CMAKE (MULTI-BINARY PACKAGE)
)
$ 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
)
$ cd debhello-2.1
$ debmake -b',libsharedlib1,libsharedlib-dev'
I: set parameters
I: sanity check of parameters
I: pkg="debhello", ver="2.1", rev="1"
I: *** start packaging in "debhello-2.1". ***
I: provide debhello_2.1.orig.tar.gz for non-native Debian package
I: pwd = "/path/to"
I: $ ln -sf debhello-2.1.tar.gz debhello_2.1.orig.tar.gz
I: pwd = "/path/to/debhello-2.1"
I: parse binary package settings: ,libsharedlib1,libsharedlib-dev
I: binary package=debhello Type=bin / Arch=any M-A=foreign
...
The result is similar to Section 8.8 but not exactly the same.
Let’s inspect the notable template files generated.
debian/rules (template file, v=2.1):
$ cat debhello-2.1/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,--as-needed
%:
dh $@
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_TARGET_MULTIARCH)"
$ vim debhello-2.1/debian/rules
... hack, hack, hack, ...
$ cat debhello-2.1/debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
116
CHAPTER 8. MORE EXAMPLES 8.12. CMAKE (MULTI-BINARY PACKAGE)
%:
dh $@
override_dh_auto_configure:
dh_auto_configure -- \
-DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_HOST_MULTIARCH)"
override_dh_install:
dh_install --list-missing
$ vim debhello-2.1/debian/control
... hack, hack, hack, ...
$ cat debhello-2.1/debian/control
Source: debhello
Section: devel
Priority: optional
Maintainer: Osamu Aoki <[email protected]>
Build-Depends: cmake, debhelper (>=11~)
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: libsharedlib1 (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Description: example executable package
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)'.
.
This package provides the executable program.
Package: libsharedlib1
Section: libs
Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: example shared library package
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)'.
.
This package contains the shared library.
Package: libsharedlib-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libsharedlib1 (= ${binary:Version}), ${misc:Depends}
Description: example development package
This is an example package to demonstrate Debian packaging using
117
CHAPTER 8. MORE EXAMPLES 8.12. CMAKE (MULTI-BINARY PACKAGE)
$ vim debhello-2.1/debian/debhello.install
... hack, hack, hack, ...
$ cat debhello-2.1/debian/debhello.install
usr/bin/*
usr/share/man/*
$ vim debhello-2.1/debian/libsharedlib1.install
... hack, hack, hack, ...
$ cat debhello-2.1/debian/libsharedlib1.install
usr/lib/*/*.so.*
$ vim debhello-2.1/debian/libsharedlib-dev.install
... hack, hack, hack, ...
$ cat debhello-2.1/debian/libsharedlib-dev.install
###usr/lib/*/pkgconfig/*.pc
usr/include
usr/lib/*/*.so
This upstream CMakeList.txt needs to be patched to cope with the multiarch path.
debian/patches/* (maintainer version, v=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):
$ tree debhello-2.1/debian
debhello-2.1/debian
├── README.Debian
├── changelog
├── compat
├── control
├── copyright
├── debhello.install
├── libsharedlib-dev.install
├── libsharedlib1.install
├── libsharedlib1.symbols
├── patches
│ ├── 000-cmake-multiarch.patch
│ └── series
├── rules
├── source
│ ├── format
│ └── local-options
└── watch
2 directories, 15 files
The rest of the packaging activities are practically the same as the one in Section 8.8.
Here are the generated dependency list of all binary packages.
118
CHAPTER 8. MORE EXAMPLES 8.13. INTERNATIONALIZATION
8.13 Internationalization
Here is an example of updating the simple upstream C source debhello-2.0.tar.gz presented in Section 8.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.
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.
$ wget http://www.example.org/download/debhello-2.0.tar.gz
...
$ tar -xzmf debhello-2.0.tar.gz
$ tree
.
├── debhello-2.0
│ ├── Makefile.am
│ ├── 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
5 directories, 12 files
Internationalize this source tree with the gettextize command and remove files auto-generated by Autotools.
run gettextize (i18n):
119
CHAPTER 8. MORE EXAMPLES 8.13. INTERNATIONALIZATION
$ cd 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
Copying file m4/nls.m4
Copying file m4/po.m4
Copying file m4/progtest.m4
Creating m4/ChangeLog
Updating Makefile.am (backup is in Makefile.am~)
Updating configure.ac (backup is in configure.ac~)
Creating ChangeLog
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.
$ ls -l po
/build/debmake-doc-1.14/debhello-2.0-pkg2/step151.cmd: line 2: SOURCE_DATE_EP...
120
CHAPTER 8. MORE EXAMPLES 8.13. INTERNATIONALIZATION
total 60
-rw-r--r-- 1 pbuilder pbuilder 494 May 25 20:41 ChangeLog
-rw-r--r-- 1 pbuilder pbuilder 17577 May 25 20:41 Makefile.in.in
-rw-r--r-- 1 pbuilder pbuilder 3376 May 25 20:41 Makevars.template
-rw-r--r-- 1 pbuilder pbuilder 59 May 25 20:41 POTFILES.in
-rw-r--r-- 1 pbuilder pbuilder 2203 May 25 20:41 Rules-quot
-rw-r--r-- 1 pbuilder pbuilder 217 May 25 20:41 boldquot.sed
-rw-r--r-- 1 pbuilder pbuilder 1337 May 25 20:41 [email protected]
-rw-r--r-- 1 pbuilder pbuilder 1203 May 25 20:41 [email protected]
-rw-r--r-- 1 pbuilder pbuilder 672 May 25 20:41 insert-header.sin
-rw-r--r-- 1 pbuilder pbuilder 153 May 25 20:41 quot.sed
-rw-r--r-- 1 pbuilder pbuilder 432 May 25 20:41 remove-potcdate.sin
$ vim configure.ac
... hack, hack, hack, ...
$ cat 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])
121
CHAPTER 8. MORE EXAMPLES 8.13. INTERNATIONALIZATION
# 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):
lib/sharedlib.c (i18n):
The new gettext (v=0.19) can handle the i18n version of the desktop file directly.
data/hello.desktop.in (i18n):
122
CHAPTER 8. MORE EXAMPLES 8.13. INTERNATIONALIZATION
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
#: src/hello.c:8
#, c-format
msgid "Hello, I am "
msgstr ""
#: lib/sharedlib.c:6
#, c-format
msgid "This is a shared library!\n"
msgstr ""
#: data/hello.desktop.in:3
msgid "Hello"
msgstr ""
123
CHAPTER 8. MORE EXAMPLES 8.13. INTERNATIONALIZATION
#: data/hello.desktop.in:4
msgid "Greetings"
msgstr ""
#: data/hello.desktop.in:6
msgid "hello"
msgstr ""
#: data/hello.desktop.in:9
msgid "hello.png"
msgstr ""
#: 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 ""
124
CHAPTER 8. MORE EXAMPLES 8.14. DETAILS
The packaging activities are practically the same as the one in Section 8.11.
You can find more i18n examples in Section 8.14 for
• the POSIX shell script with Makefile (v=3.0),
• the Python3 script with distutils (v=3.1),
• the C source with Makefile.in + configure (v=3.2),
8.14 Details
Actual details of the examples presented and their variants can be obtained by the following.
How to get details
Each directory with the -pkg[0-9] suffix 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
125
Appendix A
debmake(1) manpage
A.1 NAME
debmake - program to make a Debian source package
A.2 SYNOPSIS
debmake [-h] [-c | -k] [-n | -a package-version.orig.tar.gz | -d | -t ] [-p package] [-u version] [-r revision] [-z exten-
sion] [-b ”binarypackage, …]” [-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]
A.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.
-k, --kludge compare the debian/copyright file with the source and exit.
The debian/copyright file must be organized to list the generic file patterns before the specific exceptions.
126
APPENDIX A. DEBMAKE(1) MANPAGE A.3. DESCRIPTION
-n, --native make a native Debian source package without .orig.tar.gz. This makes a “3.0 (native)” format pack-
age.
If you are thinking of packaging a Debian-specific source tree with debian/* in it into a native Debian pack-
age, please think otherwise. You can use the “debmake -d -i debuild” or “debmake -t -i debuild” commands
to make a “3.0 (quilt)” format non-native Debian package. The only difference is that the debian/changelog
file must use the non-native version scheme: version-revision. The non-native package is more friendly to
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, Python distutils,
…)
-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, e.g., in the full form “foo:bin,foo-doc:doc,libfoo1:lib,libfoo-
dev:dev” or in the short form, “-doc,libfoo1,libfoo-dev”.
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)
• python: Python script package (all, foreign) (alias: py)
• python3: Python3 script package (all, foreign) (alias: py3)
• ruby: Ruby script package (all, foreign) (alias: rb)
• script: Shell script package (all, foreign) (alias: sh)
The pair values in the parentheses, such as (any, foreign), are the Architecture and Multi-Arch stanza values
set in the debian/control file.
In many cases, the debmake command makes good guesses for type from binarypackage. If type is not
obvious, type is set to bin. For example, libfoo sets type to lib, and font-bar sets type to data, …
If the source tree contents do not match settings for type, the debmake command warns you.
127
APPENDIX A. DEBMAKE(1) MANPAGE A.3. DESCRIPTION
-l ”license_file,…”, --license ”license_file,…” add formatted license text to the end of the debian/copyright file
holding license scan results.
The default is to add COPYING and LICENSE, and license_file needs to list only the additional file names
all separated by “,”.
-m, --monoarch force packages to be non-multiarch.
-o file, --option file read optional parameters from file. (This is not for everyday use.)
The content of file is sourced as the Python3 code at the end of para.py. For example, the package description
can be specified by the following file.
-q, --quitearly quit early before creating files in the debian/ directory.
-s, --spec use upstream spec (setup.py for Python, etc.) for the package description.
-v, --version show version information.
-w ”addon,…”, --with ”addon,…” add extra arguments to the --with option of the dh(1) command as addon in
debian/rules.
The addon values are listed all separated by “,”, e.g., “-w ”python2,autoreconf””.
For Autotools based packages, setting autoreconf as addon forces running “autoreconf -i -v -f” for every
package building. Otherwise, autotools-dev as addon is used as the default.
For Autotools based packages, if they install Python programs, python2 as addon is needed for packages
with “compat < 9” since this is non-obvious. But for setup.py based packages, python2 as addon is not
needed since this is obvious and it is automatically set for the dh(1) command by the debmake command
when it is required.
-x n, --extra n generate 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: bare minimum configuration files. (default option if any of bare minimum configuration files
already exist)
128
APPENDIX A. DEBMAKE(1) MANPAGE A.4. EXAMPLES
• -x1: all -x0 files + desirable configuration files for the single binary package. (default option for the
single binary package if none of bare minimum configuration files exist)
• -x2: all -x1 files + desirable configuration files for the multi binary package. (default option for the
multi binary package if none of bare minimum configuration files exist)
• -x3: all -x2 files + unusual configuration template files. Unsual configuration template files are gen-
erated with the extra .ex suffix to ease their removal. To use these as configuration files, rename their
file names to ones without the .ex suffix.
• -x4: all -x3 files + copyright file examples.
-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.
A.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
For a typical Python module source tree:
• debmake -s -d -b”:python” -i debuild
For a typical Python module in the package-version.tar.gz archive:
• etc.
129
APPENDIX A. DEBMAKE(1) MANPAGE A.6. CAVEAT
A.6 CAVEAT
debmake is meant to provide template files for the package maintainer to work on. Comment lines started by #
contain the tutorial text. You must remove or edit such comment lines before uploading to the Debian archive.
The license extraction and assignment process involves a lot of heuristics; it may fail in some cases. It is highly
recommended to use other tools such as licensecheck from the devscripts package in conjunction with debmake.
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:
• Upstream package name (-p): [-+.a-z0-9]{2,}
• Binary package name (-b): [-+.a-z0-9]{2,}
A.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: print information
• p: list all global parameters
• d: list parsed parameters for all binary packages
• f: input filename for the copyright scan
A.8 AUTHOR
Copyright © 2014-2017 Osamu Aoki <[email protected]>
130
APPENDIX A. DEBMAKE(1) MANPAGE A.9. LICENSE
A.9 LICENSE
Expat License
131