Debian Packaging: From Source to Repository

Understanding APT Repositories

A practical Debian packaging course lesson covering understanding apt repositories.

Understanding APT Repositories

A .deb file can be installed directly, but distributing packages to many users is easier through an APT repository.

An APT repository provides package indexes and metadata that allow clients to discover, download, verify, install, and upgrade packages.

In this lesson, we will examine the structure of a Debian repository and understand how APT uses its metadata.

Learning Objectives

  • Understand the difference between a package file and a repository.
  • Recognize the dists/ and pool/ directories.
  • Understand package indexes and Release metadata.
  • Learn how repository signatures establish trust.
  • Prepare for publishing a repository with aptly.

1. Why Use an APT Repository?

Installing a local package is straightforward:

1
sudo apt install ./syspeek_0.1.0-1_amd64.deb

But users would need to download each new version manually.

An APT repository provides a central location where clients can retrieve package metadata and updates using familiar commands:

1
2
sudo apt update
sudo apt install syspeek

It also supports version upgrades and dependency resolution.

2. A Simplified Repository Structure

A Debian repository commonly has a structure similar to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
repository/
├── dists/
│   └── trixie/
│       ├── InRelease
│       ├── Release
│       ├── Release.gpg
│       └── main/
│           └── binary-amd64/
│               └── Packages.gz
└── pool/
    └── main/
        └── s/
            └── syspeek/
                └── syspeek_0.1.0-1_amd64.deb

The exact structure may include additional architectures, components, source indexes, and compression formats.

3. The pool Directory

The pool/ directory stores package files.

It is organized by component and commonly by the initial letter of the source package name.

The repository metadata points to these package files.

4. The dists Directory

The dists/ directory contains distribution metadata.

A suite such as trixie has a Release file describing the repository metadata and checksums for package indexes.

The Packages index contains information about available binary packages, including:

  • Package name.
  • Version.
  • Architecture.
  • Dependencies.
  • Description.
  • Download filename.
  • Size and checksums.

APT downloads these indexes when the user runs:

1
sudo apt update

It then uses them to resolve package installation and upgrade requests.

5. Components and Architectures

A repository may publish components such as:

  • main
  • contrib
  • non-free
  • non-free-firmware

A private repository often uses a single component such as main.

Binary indexes are separated by architecture, for example:

1
2
binary-amd64/
binary-arm64/

Source package indexes are also available when the repository publishes source packages.

6. Repository Signing

APT repositories use signed Release metadata to authenticate repository metadata.

A signed InRelease file combines the Release information and its signature. Alternatively, a repository may provide Release and a detached Release.gpg signature.

The client verifies the signature using a trusted repository key.

Checksums in the signed metadata then protect the package indexes and, through their checksums, the package files.

HTTPS protects transport, but it does not replace repository metadata signing.

7. How APT Uses a Repository

A simplified client workflow is:

  1. Read configured repository sources.
  2. Download Release metadata.
  3. Verify its signature.
  4. Download package indexes.
  5. Verify their checksums.
  6. Resolve dependencies.
  7. Download the selected package files.
  8. Verify package checksums and install packages.

This is why a repository is more than a directory containing .deb files.

8. What We Learned

We explored the pool/ and dists/ directories, package indexes, distribution metadata, architectures, components, and repository signing.

Exercises

  1. Inspect the contents of /var/lib/apt/lists/ on your Debian system.
  2. Find a Packages index and locate an entry for a familiar package.
  3. Inspect the configured sources in /etc/apt/sources.list and /etc/apt/sources.list.d/.
  4. Explain why signing Release metadata is important.

What’s Next?

Next, we will use aptly to create a local repository and add our Syspeek package to it.

Next: Creating a Repository with aptly