Debian Packaging: From Source to Repository

Source Packages and Signing

A practical Debian packaging course lesson covering source packages and signing.

Source Packages and Signing

A Debian binary package is what users install. A Debian source package contains the source and packaging metadata needed to build those binaries.

When distributing packages, maintainers often need both source and binary artifacts, together with cryptographic signatures that allow recipients to verify their origin and integrity.

In this lesson, we will build a source package and introduce signing with GPG.

Learning Objectives

  • Understand the difference between source and binary packages.
  • Build Debian source-package artifacts.
  • Identify .dsc, .orig.tar, .debian.tar, and .changes files.
  • Understand GPG signing in Debian workflows.
  • Avoid confusing integrity checks with trust.

1. Source and Binary Packages

A binary package contains files ready to install on a target system.

A source package contains the material used to build the binary package. With the 3.0 (quilt) format, it commonly includes:

  • A .dsc descriptor.
  • An upstream source archive.
  • A Debian packaging archive.
  • A .changes file describing the generated artifacts.

The exact files depend on the source format and build options.

2. Prepare an Upstream Source Archive

For a simple teaching project without a separate upstream release archive, we can create an upstream tarball from the source tree.

The Debian source package workflow expects a source tree with a name and version matching the package metadata. In a real release, use a properly prepared upstream source tarball and ensure that it excludes generated build artifacts and local files.

For this course, keep the source tree clean and do not include the compiled syspeek executable.

3. Build a Source Package

From the project directory:

1
2
cd ~/packaging-lab/syspeek
dpkg-buildpackage -S -us -uc

The -S option requests a source-only build.

The -us and -uc options leave the source package and changes file unsigned.

For a source package that needs to include the upstream tarball, the appropriate first-upload options may include -sa. The exact choice depends on whether the upstream archive is already present in the archive or build directory.

4. Inspect the Generated Files

Look in the parent directory:

1
ls -lh ..

Common artifacts include:

1
2
3
4
syspeek_0.1.0-1.dsc
syspeek_0.1.0.orig.tar.*
syspeek_0.1.0-1.debian.tar.*
syspeek_0.1.0-1_source.changes

Some filenames or extensions may differ according to the source format and compression settings.

The .dsc file describes the source package and includes checksums for its components.

5. Understand GPG Signing

GPG signatures help recipients verify that an artifact was signed by the holder of a particular private key and that the signed content has not changed.

They do not automatically prove that the signer is trustworthy. Users still need a trusted way to obtain and verify the signing key.

List your secret keys:

1
gpg --list-secret-keys --keyid-format long

If you do not have a key, create one using:

1
gpg --full-generate-key

Choose an appropriate key type and expiry, and protect the private key carefully.

6. Sign Debian Artifacts

The debsign command from devscripts can sign a .changes file and the associated source package metadata.

For example:

1
debsign ../syspeek_0.1.0-1_source.changes

Use the actual filename generated by your build.

Do not share your private key or its passphrase. For public distribution, publish the corresponding public key through a trustworthy channel and document its fingerprint.

7. Verify Signatures

Use GPG to verify a signed file:

1
gpg --verify ../syspeek_0.1.0-1_source.changes

A successful cryptographic verification means the signature matches a key available to GPG. You must still verify that the key belongs to the maintainer you intend to trust.

8. What We Learned

We examined source-package artifacts, built a source package, and introduced GPG signing and verification.

Signing is a core part of a trustworthy package distribution workflow.

Exercises

  1. Compare the .dsc and .deb files.
  2. Inspect a .dsc file as text.
  3. Generate a test GPG key if you do not already have one.
  4. Verify a signed artifact and record the signing key fingerprint.

What’s Next?

We have software and package artifacts. Next, we will examine how APT repositories organize, index, and distribute those packages.

Next: Understanding APT Repositories