Chapter 1. Getting started The Right Way

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).

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 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.

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.

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.debian.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.

1.1. Social dynamics of Debian 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)

1.2. Programs needed for development 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 package or with 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).) 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.