Debian Packaging: From Source to Repository
The Debian Control File
A practical Debian packaging course lesson covering the debian control file.
The Debian Control File
The debian/control file is one of the most important files in a Debian package. It describes the source package, the binary packages produced from it, and the dependencies required to build and install them.
In this lesson, we will write the first control file for Syspeek.
Learning Objectives
- Distinguish source-package metadata from binary-package metadata.
- Understand the most common control fields.
- Declare build dependencies.
- Declare runtime dependencies.
- Validate the control file’s basic structure.
1. Source and Binary Stanzas
A control file contains one or more paragraphs, also called stanzas. The first stanza describes the source package. Each following stanza describes a binary package.
For our project, we will produce one binary package named syspeek.
Open the file:
1
2
cd ~/packaging-lab/syspeek
nano debian/control
Add:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Source: syspeek
Section: utils
Priority: optional
Maintainer: Example Maintainer <[email protected]>
Build-Depends:
debhelper-compat (= 13),
golang-any
Standards-Version: 4.7.0
Rules-Requires-Root: no
Package: syspeek
Architecture: any
Depends: ${misc:Depends}
Description: concise Linux system information utility
Syspeek displays basic information about a Linux system,
including its distribution, architecture, and CPU count.
Replace the example maintainer identity with a name and address appropriate for your package before publishing it.
2. Important Source Fields
Source: source package name.Section: broad archive category.Priority: relative package priority.Maintainer: person or team responsible for the package.Build-Depends: packages needed to build the source.Standards-Version: Debian Policy version against which the package is checked.Rules-Requires-Root: declares whether root privileges are required for the package build.
debhelper-compat (= 13) selects debhelper compatibility level 13 through a build dependency. Do not also add a separate debian/compat file when using this mechanism.
golang-any asks for a suitable Go compiler package on the target build architecture.
3. Important Binary Fields
Package: binary package name.Architecture: architectures on which the package can be built.Depends: packages required when the binary package is installed.Description: short summary followed by a longer description.
We use Architecture: any because the executable is built for the target architecture. This is different from an architecture-independent package, which would use all.
The ${misc:Depends} substitution variable is populated by debhelper when needed. It should normally be included in packages using debhelper.
4. Build Dependencies vs. Runtime Dependencies
Build dependencies are needed to create the package. Runtime dependencies are needed by users after installation.
For example:
- The Go compiler is a build dependency.
- A library required by the running executable may be a runtime dependency.
- A packaging helper such as debhelper is a build dependency, not normally a runtime dependency.
Do not copy every build dependency into Depends. Doing so would force users to install tools they do not need.
5. Validate the File
Install devscripts and dpkg-dev if you have not already done so, then run:
1
dpkg-parsechangelog --file debian/changelog
The changelog is not complete yet, so this command will become useful after the next lesson.
For a quick syntax-oriented inspection, use:
1
dpkg-checkbuilddeps
It checks whether the declared build dependencies are installed. At this stage it may report missing packages; that is expected until the build environment is prepared.
6. What We Learned
The control file has separate source and binary stanzas. We declared the tools needed to build Syspeek and the metadata needed to describe the resulting package.
Exercises
- Explain why
golang-anybelongs inBuild-Depends. - Change the package description without making it empty or overly generic.
- Look at the control file of an installed Debian package and identify its
Dependsfield.
What’s Next?
A package also needs a version history and accurate licensing information. Next, we will write debian/changelog and debian/copyright.
Next: Changelog and Copyright