Table of Contents
The rewrite of this tutorial document with updated contents and more practical examples is available as Guide for Debian Maintainers. Please use this new tutorial as the primary tutorial document.
This document tries to describe the building of a Debian package to ordinary Debian users and prospective developers. It uses fairly non-technical language, and it's well covered with working examples. 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).
This document is made available for the Debian Buster
release since this offers many translations. This document will be dropped in the following releases since contents are getting outdated.
[1]
One of the things that makes Debian such a top-notch distribution is its package system. While there is a vast quantity of software already in the Debian format, sometimes you need to install software that isn't. You may be wondering how you can make your own packages; and perhaps you think it is a very difficult task. Well, if you are a real novice on Linux, it is hard, but if you were a rookie, you wouldn't be reading this document now :-) You do need to know a little about Unix programming but you certainly don't need to be a wizard. [2]
One thing is certain, though: to properly create and maintain Debian packages takes many hours. Make no mistake, for our system to work the maintainers need to be both technically competent and diligent.
If you need some help with packaging, please read Section 1.4, “Where to ask for help”.
Newer versions of this document should always be available online at
http://www.buy-develop.eu.org/doc/maint-guide/ and in the
maint-guide
package.
The translations may be available in packages such as
maint-guide-es
.
Please note that this documentation may be slightly outdated.
Since this is a tutorial, I choose to explain each detailed step for some important topics. Some of them may look irrelevant to you. Please be patient. I have also intentionally skipped some corner cases and provided only pointers to keep this document simple.
Here are some observations of Debian's social dynamics, presented in the hope that it will prepare you for interactions with Debian:
We all are volunteers.
You cannot impose on others what to do.
You should be motivated to do things by yourself.
Friendly cooperation is the driving force.
Your contribution should not overstrain others.
Your contribution is valuable only when others appreciate it.
Debian is not your school where you get automatic attention of teachers.
You should be able to learn many things by yourself.
Attention from other volunteers is a very scarce resource.
Debian is constantly improving.
You are expected to make high quality packages.
You should adapt yourself to change.
There are several types of people interacting around Debian with different roles:
upstream author: the person who made the original program.
upstream maintainer: the person who currently maintains the program.
maintainer: the person making the Debian package of the program.
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 cannot 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 package to become an official Debian Developer. Contributing 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.2, “Choose your program”).
Since we focus only on technical aspects of packaging in this document, please refer to the following to learn how Debian functions and how you can get involved:
Debian: 17 years of Free Software, "do-ocracy", and democracy (Introductory slides)
How can you help Debian? (official)
The Debian GNU/Linux FAQ, Chapter 13 - "Contributing to the Debian Project" (semi-official)
Debian Wiki, HelpDebian (supplemental)
Debian New Member site (official)
Debian Mentors FAQ (supplemental)
Before you start anything, you should make sure that you have properly
installed some additional packages needed for development. Note that the list
doesn't contain any packages marked essential
or
required
- we expect that you have those installed already.
The following packages come with the standard Debian installation, so you
probably have them already (along with any additional packages they depend on).
Still, you should check them with aptitude show
or with package
dpkg -s
.
package
The most important package to install on your development system is the
build-essential
package. Once you try
to install that, it will pull in other packages required to
have a basic build environment.
For some types of packages, that is all you will require; however, there is another set of packages that while not essential for all package builds are useful to have installed or may be required by your package:
autoconf
, automake
, and autotools-dev
- many newer programs use configure
scripts and Makefile
files preprocessed with the help of
programs like these (see info autoconf
, info
automake
). autotools-dev
keeps up-to-date versions of certain auto files and has documentation about the
best way to use those files.
debhelper
and
dh-make
-
dh-make
is necessary to create
the skeleton of our example package, and it will use some of the
debhelper
tools for creating
packages. They are not essential for this purpose, but are
highly recommended for new maintainers. It makes
the whole process very much easier to start, and to control afterwards.
(See dh_make(8), debhelper(1).) [3]
The new debmake
may be used as the alternative to the standard dh-make
.
It does more and comes with HTML documentation with extensive packaging examples in debmake-doc
.
devscripts
- this package contains some
useful scripts that can be helpful for maintainers, but they are also
not necessary for building packages. Packages recommended and suggested
by this package are worth looking into. (See /usr/share/doc/devscripts/README.gz
.)
fakeroot
- this utility lets you
emulate being root, which is necessary for some parts of the build process.
(See fakeroot(1).)
file
- this handy program can determine
what type a file is. (See file(1).)
gfortran
- the GNU Fortran 95 compiler,
necessary if your program is written in Fortran. (See gfortran(1).)
git
- this package provides a popular
version control system designed to handle very large projects with speed and
efficiency; it is used for many high profile open source projects, most notably
the Linux kernel. (See git(1),
git Manual (/usr/share/doc/git-doc/index.html
).)
gnupg
- a tool that enables you to
digitally sign packages. This is especially important if
you want to distribute packages to other people, and you will certainly be doing that
when your work gets included in the Debian distribution. (See gpg(1).)
gpc
- the GNU Pascal compiler,
necessary if your program is written in Pascal. Worthy of note here is
fp-compiler
, the Free Pascal Compiler,
which is also good at this task. (See gpc(1),
ppc386(1).)
lintian
- this is the Debian package
checker, which lets you know of any common mistakes after you build the
package and explains the errors found. (See lintian(1),
Lintian User's Manual.)
patch
- this very useful utility will
take a file containing a difference listing (produced by the
diff program) and apply it to the original file, producing a
patched version. (See patch(1).)
patchutils
- this package contains some
utilities to work with patches such as the lsdiff,
interdiff and filterdiff commands.
pbuilder
- this package contains
programs which are used for creating and maintaining a chroot
environment. Building a Debian package in this chroot
environment verifies the proper build dependency and avoids FTBFS (Fails To
Build From Source) bugs. (see pbuilder(8) and pdebuild(1))
perl
- Perl is one of the most used
interpreted scripting languages on today's Unix-like systems, often referred to
as Unix's Swiss Army Chainsaw. (See perl(1).)
python
- Python is another of the most
used interpreted scripting languages on the Debian system, combining
remarkable power with very clear syntax. (See python(1).)
quilt
- this package helps you to
manage large numbers of patches by keeping track of the changes each patch
makes. Patches can be applied, un-applied, refreshed, and more. (See
quilt(1),
and /usr/share/doc/quilt/quilt.pdf.gz
.)
xutils-dev
- some programs, usually
those made for X11, also use these programs to generate
Makefile
files from sets of macro functions. (See
imake(1), xmkmf(1).)
The short descriptions that are given above only serve to introduce you to what each package does. Before continuing please read the documentation of each relevant program including ones installed through the package dependency such as make, at least, for the standard usage. It may seem like heavy going now, but later on you'll be very glad you read it. If you have specific questions later, I would suggest re-reading the documents mentioned above.
The following is the very important documentation which you should read along with this document:
debian-policy
- the Debian Policy
Manual includes explanations of the structure and contents of the
Debian archive, several OS design issues, the Filesystem Hierarchy Standard
(FHS, which says where each file and directory should be), etc. For you, the most
important thing is that it describes requirements that each package must
satisfy to be included in the distribution. (See the local copies of
/usr/share/doc/debian-policy/policy.pdf.gz
and /usr/share/doc/debian-policy/fhs/fhs-3.0.pdf.gz
.)
developers-reference
- the Debian Developer's Reference
describes all matters not specifically about the technical
details of packaging, like the structure of the archive, how to rename, orphan,
or adopt packages, how to do NMUs, how to manage bugs, best packaging practices,
when and where to upload, etc. (See the local copy of
/usr/share/doc/developers-reference/developers-reference.pdf
.)
The following is the important documentation which you should read along with this document:
Autotools Tutorial provides a very good tutorial for the GNU Build System known as the GNU Autotools, whose most important components are Autoconf, Automake, Libtool, and gettext.
gnu-standards
- this package contains
two pieces of documentation from the GNU project:
GNU Coding Standards, and
Information for Maintainers of GNU Software.
Although Debian does not require these to
be followed, these are still helpful as guidelines and common sense.
(See the local copies of
/usr/share/doc/gnu-standards/standards.pdf.gz
and
/usr/share/doc/gnu-standards/maintain.pdf.gz
.)
If this document contradicts any of the documents mentioned above, they
are correct. Please file a bug report on the
maint-guide
package using
reportbug.
The following is an alternative tutorial document that you may read along with this document:
Before you decide to ask your question in some public place, please read this fine documentation:
files in /usr/share/doc/
for all pertinent packages
package
contents of man
for all pertinent commands
command
contents of info
for all pertinent commands
command
contents of [email protected] mailing list archive
contents of [email protected] mailing list archive
You can use web search engines more effectively by including search strings
such as site:lists.debian.org
to limit the domain.
Making a small test package is a good way to learn details of packaging. Inspecting existing well maintained packages is the best way to learn how other people make packages.
If you still have questions about packaging that you couldn't find answers to in the available documentation and web resources, you can ask them interactively:
[email protected] mailing list. (This mailing list is for the novice.)
[email protected] mailing list. (This mailing list is for the expert.)
IRC such as #debian-mentors
.
Teams focusing on a specific set of packages. (Full list at https://wiki.debian.org/Teams)
Language-specific mailing lists such as debian-devel-{french,italian,portuguese,spanish}@lists.debian.org or [email protected]. (Full listing at https://lists.debian.org/devel.html and https://lists.debian.org/users.html)
The more experienced Debian developers will gladly help you, if you ask properly after making your required efforts.
When you receive a bug report (yes, actual bug reports!), you will know that it is time for you to dig into the Debian Bug Tracking System and read the documentation there, to be able to deal with the reports efficiently. I highly recommend reading the Debian Developer's Reference, 5.8. "Handling bugs".
Even if it all worked well, it's time to start praying. Why? Because in just a few hours (or days) users from all around the world will start to use your package, and if you made some critical error you'll get mailbombed by numerous angry Debian users… Just kidding. :-)
Relax and be ready for bug reports, because there is a lot more work to be done before your package will be fully in line with Debian policies and its best practice guidelines (once again, read the real documentation for details). Good luck!
[1] The document assumes you are using a
jessie
or newer system. If you need to follow this
text in an older system (including an older Ubuntu system etc.), you must
install backported dpkg
and
debhelper
packages, at least.
[2] You can learn about the basic handling of a Debian system from the Debian Reference. It contains some pointers to learn about Unix programming, too.
[3] There are also some more specialized
but similar packages such as
dh-make-perl
,
dh-make-php
, etc.