Debian Packaging: From Source to Repository

Creating a Repository with aptly

A practical Debian packaging course lesson covering creating a repository with aptly.

Creating a Repository with aptly

aptly is a tool for managing Debian repositories. It can create local repositories, manage package snapshots, publish repository metadata, and sign published repositories.

In this lesson, we will install aptly, create a local repository, and add our Syspeek package.

Learning Objectives

  • Install aptly.
  • Understand local repositories and snapshots.
  • Create a repository for Syspeek.
  • Add a Debian package.
  • Inspect repository contents.

1. Install aptly

On Debian, install aptly if it is available from your configured repositories:

1
2
sudo apt update
sudo apt install aptly

If your distribution does not provide the version you need, follow the official aptly installation documentation. Avoid downloading an arbitrary binary from an untrusted source.

Check the installation:

1
aptly version

2. Understand aptly’s Main Concepts

  • Local repository: a managed collection of packages.
  • Snapshot: an immutable point-in-time view of repository contents.
  • Published repository: repository metadata and package files made available to APT clients.

Snapshots are useful because they allow you to test and promote a known set of packages rather than changing a published repository in place.

3. Create a Local Repository

Create a repository named syspeek-repo:

1
2
3
4
aptly repo create \
    -distribution=trixie \
    -component=main \
    syspeek-repo

The distribution should match the Debian suite you intend to target. Change trixie if you are packaging for a different suite.

List local repositories:

1
aptly repo list

4. Add the Syspeek Package

Assuming your binary package is in the parent directory:

1
aptly repo add syspeek-repo ../syspeek_*.deb

Inspect the repository:

1
aptly repo show -with-packages syspeek-repo

You should see the Syspeek package and its version.

5. Create a Snapshot

Create a snapshot of the local repository:

1
2
aptly snapshot create syspeek-0.1.0 \
    from repo syspeek-repo

List snapshots:

1
aptly snapshot list

A snapshot records a stable view of the repository at a particular point in time.

For a later release, you can add a new package version, create another snapshot, and test it before publishing.

6. Why Snapshots Matter

Snapshots help make repository releases controlled and repeatable.

For example:

1
2
3
4
5
syspeek-repo
    |
    +-- syspeek 0.1.0
    |
    +-- snapshot: syspeek-0.1.0

When version 0.2.0 is ready, you can create a new snapshot without changing the existing one.

This makes it easier to roll back or compare releases.

7. Inspect aptly’s Data

aptly stores its state under its configured root directory. The default is commonly under the user’s home directory.

Inspect the configuration:

1
aptly config show

Do not manually edit aptly’s internal database files. Use aptly commands to manage repository contents.

8. What We Learned

We installed aptly, created a local repository, added our Syspeek package, and created a snapshot.

The package is now managed by aptly, but it is not yet published for APT clients.

Exercises

  1. Run aptly repo list.
  2. Inspect the package metadata with aptly repo show -with-packages.
  3. Create a second snapshot after adding another package version.
  4. Explain the difference between a local repository and a snapshot.

What’s Next?

Next, we will publish the snapshot and sign the repository metadata so that APT clients can verify it.

Next: Publishing and Signing the Repository