Debian Packaging: From Source to Repository
The Debian Packaging Directory
A practical Debian packaging course lesson covering the debian packaging directory.
The Debian Packaging Directory
Our Syspeek application now works, but Debian does not yet know how to build or install it as a package. Debian packaging instructions live in a directory named debian/ at the root of the source tree.
In this lesson, we will create that directory, understand its most important files, and prepare the skeleton for our first package.
Learning Objectives
- Understand the purpose of the
debian/directory. - Create the Debian source-package format declaration.
- Identify the files used to describe, build, and document a package.
- Prepare the project for the next packaging lessons.
1. Where Packaging Files Live
Move into the Syspeek project:
1
cd ~/packaging-lab/syspeek
The source tree will eventually look like this:
1
2
3
4
5
6
7
8
9
10
syspeek/
├── debian/
│ ├── changelog
│ ├── control
│ ├── copyright
│ ├── rules
│ └── source/
│ └── format
├── go.mod
└── main.go
The debian/ directory is not part of the Go application itself. It contains instructions and metadata used by Debian packaging tools.
2. Declare the Source Format
Create the directory and format file:
1
2
mkdir -p debian/source
printf '3.0 (quilt)\n' > debian/source/format
The 3.0 (quilt) format is the standard modern Debian source package format. It supports a Debian-specific patch series while keeping the upstream source separate.
3. Understand the Main Files
| File | Purpose |
|---|---|
control |
Source and binary package metadata, including dependencies |
changelog |
Package version history and release information |
copyright |
Copyright and licensing information |
rules |
Build instructions, usually implemented with debhelper |
source/format |
Declares the Debian source package format |
*.install |
Optional file-installation rules |
*.service |
Optional systemd unit files |
patches/ |
Optional quilt patch series |
Not every package needs every possible file. We should add files only when the package requires them.
4. Create the Directory Skeleton
For now, create the basic structure:
1
2
3
4
mkdir -p debian/source
touch debian/control debian/changelog debian/copyright debian/rules
printf '3.0 (quilt)\n' > debian/source/format
chmod +x debian/rules
The rules file must be executable because build tools invoke it as a program.
Inspect the result:
1
find debian -maxdepth 2 -type f -print
The files are empty at this stage. We will fill them in over the next lessons.
5. Why Keep Packaging Separate?
Separating application source from Debian-specific metadata has several advantages:
- The application can remain usable outside Debian.
- Debian-specific changes are easy to review.
- The same upstream source can be packaged for multiple distributions.
- Package metadata and build instructions can be version-controlled with the source.
For our course, all examples remain in this project. We do not need a separate repository for the application or for the APT repository.
6. What We Learned
The debian/ directory is the control center of a Debian source package. We created its initial structure and declared the 3.0 (quilt) source format.
Exercises
- Inspect the
debian/directory withtree debian(installtreeif needed). - Read the Debian Policy chapter about source packages.
- Find another Debian source package and compare its
debian/directory with ours.
What’s Next?
Next, we will populate debian/control, the file that identifies the source package, describes the binary package, and declares build and runtime dependencies.
Next: The Debian Control File