Skip to content

Build an APT Repository

Build a standard APT repository with by-hash indexes, install from it with apt, and keep it updated.

You have DEBs for Debian or Ubuntu hosts and want apt install to work against your own repository, with the same update behavior clients expect from a public archive. This tutorial builds an APT standard repository, which SOW maintains in a workspace: one suite, trixie, with amd64 and arm64 indexes over a single package pool, and an apt client that installs from it.

You need:

  • SOW 0.9.0 (Installation) and Python 3 for the preview server.
  • DEB files built for your clients, here /path/to/packages/.
  • An empty /srv/sow directory your user can create and write to, or another path.
  • For step 5, a Debian or Ubuntu host with apt. The preview listens on 127.0.0.1 only, so run the client on the same host or publish the repository first.

Create the workspace

mkdir -p /srv/sow
cd /srv/sow
sow init .
sow repo new pigsty
sow dist new trixie --format deb -r pigsty

sow init makes /srv/sow a workspace: sow.yml plus private state. pigsty is the standard repository inside it, the directory tree you will serve. trixie is a Dist, one named package set; its name becomes the Suites value in the client’s source configuration.

Set membership policy

If you need filtering or version limits, edit the generated sow.yml. This example keeps one version per package name and architecture and excludes debug symbol packages:

schema: sow/v3
architectures: [x86_64, aarch64]
repos:
  pigsty:
    dists:
      trixie:
        format: deb
        limit: 1
        exclude:
          - kind: [dbgsym, dbg]
targets: {}

Then validate it:

sow config check

Configuration uses the canonical names x86_64 and aarch64 (amd64 and arm64 are accepted as aliases), and SOW writes the Debian amd64 and arm64 indexes from them. Architecture-independent all packages enter both views.

Add DEBs

sow add /path/to/packages/*.deb -r pigsty -d trixie
sow check -r pigsty

add stores each accepted package once in the pool and builds the indexes. The public tree is:

  • /srv/sow/pigsty/
    • pool/
    • dists/trixie/
      • Release
      • main/
        • binary-amd64/
          • Packages
          • Packages.gz
          • by-hash/SHA256/
        • binary-arm64/

The Filename paths in Packages are relative to the repository root, so serve the complete pigsty/ directory. Release declares Acquire-By-Hash: yes, and each index is also stored under by-hash/SHA256/. During an update, a client that already fetched the previous Release still downloads the Packages file that matches it.

Preview over HTTP

Run this in a separate terminal and leave it running:

python3 -m http.server --bind 127.0.0.1 --directory /srv/sow/pigsty 8080

The preview serves the repository root to the same host only. For a persistent service or clients on other hosts, use Serve and publish.

Configure APT

On the host running the preview, save this as /etc/apt/sources.list.d/pigsty.sources. Use arm64 in Architectures on ARM64 clients. For a remote client, publish the repository first and use its public URL:

# /etc/apt/sources.list.d/pigsty.sources
Types: deb
URIs: http://127.0.0.1:8080
Suites: trixie
Components: main
Architectures: amd64
Trusted: yes

URIs points at the repository root, not at dists/. Trusted: yes accepts this unsigned example; Sign your repository replaces it with Signed-By.

Refresh and query it:

sudo apt update
apt-cache policy

The repository works when apt update completes and apt-cache policy lists trixie/main as a package source. After the preview, remove the test source file and stop the Python server.

Publish the repository

To give other hosts access, use sow publish with a filesystem or R2 target. It uploads packages and indexes before it updates Release and its signatures. The same tutorial covers manual delivery to isolated hosts.

Update the repository

sow add /path/to/new.deb -r pigsty -d trixie
sow check -r pigsty

add builds the update itself. With limit: 1, the newest version replaces the previous member for each package name and architecture. After you change sow.yml, run sow build -r pigsty to apply the new policy.

To withdraw a package, preview the selection with sow rm PACKAGE_NAME -r pigsty -d trixie --check, then repeat without --check. A package name selects all its versions and architectures; use a SHA-256 reference to select one package object.

Next