6.2. Configuring Package Sources

APT learns what repositories exist entirely from configuration: the one-line-per-source files of the older format, and the newer deb822 stanza files, both read from /etc/apt/sources.list and /etc/apt/sources.list.d/. Everything a source offers - which suites, which components, which architectures, and whose signature to trust - is stated there, so this configuration is also the security boundary of the whole system: a repository listed in these files can offer replacement versions of anything. The section works through the formats, the four suites a stable release uses, key management for third-party sources, and how to keep a foreign repository from overriding Debian's own packages.

6.2.1. Deb822 Source Files and Archive Components

Two syntaxes describe sources. The one-line format (Chapter 2 showed this machine's /etc/apt/sources.list in it) puts a whole source in a single deb URI suite components… line, with deb-src lines for source packages. The deb822 format, named after the RFC it resembles, uses multi-line stanzas of Field: value pairs - the same structure as package control fields - and current Debian installations write it to /etc/apt/sources.list.d/debian.sources. The example machine's four suites in that form (a stock installation writes the main, updates, and security stanzas; the backports stanza is the common local addition this machine carries):

Types: deb deb-src
URIs: https://deb.debian.org/debian
Suites: trixie trixie-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb deb-src
URIs: https://security.debian.org/debian-security
Suites: trixie-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://deb.debian.org/debian
Suites: trixie-backports
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

File contents, shown as a listing rather than a capture: the example machine keeps the one-line file from Chapter 2, and the stanza form above is that configuration in the format a current installer writes, with one deliberate trim - the backports stanza carries Types: deb only, since source indexes for backports are rarely used. Blank lines separate stanzas; each field applies to its own stanza only.

Field Description
Types deb for binary packages, deb-src for source indexes; both may be listed.
URIs Repository root; one stanza may list several mirrors of the same content.
Suites Distribution names to fetch; several may be listed.
Components Archive sections (below). main alone is common.
Architectures Restrict the source to named architectures; omit to accept all the machine has enabled.
Signed-By Key, keyring file, or fingerprint trusted to sign this source's metadata.
Enabled no disables a stanza without deleting it.

The stanza file earns its keep as configuration grows: one file holds several sources, comments can annotate each stanza, and a single Signed-By states exactly which key vouches for exactly which content - the per-source key binding that Section 6.2.3 exercises. Both formats accept either a suite name (stable) or a codename (trixie) in the Suites: field; the book and the example machine use codenames because they never change meaning when a release cycle moves.

The components field selects archive sections by licensing policy, a distinction Chapter 1 introduced. Debian 13's archive has four:

Component Contents
main Free software per the Debian Free Software Guidelines; the default and the only component the example system uses.
contrib Free software that depends on something outside main.
non-free-firmware Firmware blobs separated out so installs can exclude them; usable under special terms.
non-free Software whose licenses restrict use or redistribution.

Enabling contrib or the non-free components is a policy decision (Chapter 26 revisits it in the context of minimizing the installed base); a source line naming components the archive lacks is simply ignored for them.

6.2.2. Stable, Security, Updates, and Backports Suites

Four suites serve a stable release, each with a distinct purpose and freshness guarantee:

Suite Carries Urgency In a default install
trixie The release as published, plus rebuilt installation images. Point releases only. Yes.
trixie-security Security fixes, published as soon as ready. Days matter. Yes.
trixie-updates Corrections too urgent to wait for a point release but not security issues: time-zone and virus-scanner data that must stay current, firmware refreshes, fixes for regressions a point release introduced. Weeks. Yes.
trixie-backports Newer software rebuilt from testing against stable. Never urgent; opt-in per package. Not written by the installer; when added it is pinned low by its own release flags.

The security suite lives on a different host - security.debian.org - because fixes must publish without waiting for the main mirror network. The version interplay between suites is visible in APT's own policy report; apt-cache policy shows, for one package, the installed version, the chosen candidate, and every known version with the priority that chose it:

$ apt-cache policy curl
curl:
  Installed: (none)
  Candidate: 8.14.1-2+deb13u7
  Version table:
     8.21.0-2~bpo13+1 100
        100 https://deb.debian.org/debian trixie-backports/main amd64 Packages
     8.14.1-2+deb13u7 500
        500 https://security.debian.org/debian-security trixie-security/main amd64 Packages
     8.14.1-2+deb13u5 500
        500 https://deb.debian.org/debian trixie/main amd64 Packages

Three facts are visible at once. The candidate 8.14.1-2+deb13u7 comes from the security archive - apt chose it over the older stable copy because both have priority 500 and the security version's u7 suffix sorts newer. The backports line lists 8.21.0-2~bpo13+1, a much newer upstream, at priority 100 - never the candidate, because backports is deliberately held below the level at which a version would win. And the +deb13u7 suffixes are Debian revision markers, counting updates within the release. The same structure with a different package:

$ apt-cache policy tmux
tmux:
  Installed: (none)
  Candidate: 3.5a-3
  Version table:
     3.7c-1~bpo13+1 100
        100 https://deb.debian.org/debian trixie-backports/main amd64 Packages
     3.5a-3 500
        500 https://deb.debian.org/debian trixie/main amd64 Packages

Here stable's 3.5a-3 is the candidate - no security or updates revision exists for tmux at this moment. The backport 3.7c-1~bpo13+1 sits at priority 100, waiting to be requested explicitly, which is exactly what Section 6.5.2 does. The priorities themselves have documented sources, apt_preferences(5) among them: 500 is the default for a regular repository, 100 for the installed database itself, and backports earns its 100 from its own Release file, which carries NotAutomatic: yes and ButAutomaticUpgrades: yes - flags that keep the suite from ever winning an installation by default while still letting an already-installed backport upgrade itself. Section 6.5.1 shows what the other priority ranges mean and how to set them.

Reading this report is the first check whenever versions look wrong: whatever apt is doing, apt-cache policy says which source and which priority produced the choice.

6.2.3. Repository Signing Keys and Signed-By

Every repository's metadata is signed, and APT verifies those signatures before using anything a source offers. The chain of trust has three links: the repository signs a Release file describing the suite - component lists, architecture lists, checksums of every index, and freshness dates - and publishes it in two equivalent forms, InRelease (the Release file clear-signed into a single piece) and the pair Release plus a detached Release.gpg; the client holds the repository's public key in a keyring file; and the source configuration binds the two with a Signed-By field naming that keyring. Nothing from an unsigned or wrongly signed source is used, and the indexes of a source that fails verification are left at their last good state.

Debian's own keys ship in the debian-archive-keyring package and are already bound: the deb822 listing in Section 6.2.1 names /usr/share/keyrings/debian-archive-keyring.gpg, and per-release automatic-signing keys arrive in /etc/apt/trusted.gpg.d/ as debian-archive-trixie-*.asc when the package updates. Third-party keys have their own convention, and the old helper is gone: apt-key, which once dropped keys into one global ring trusted for every source, was deprecated for years and is not present in Debian 13 at all. The supported practice is one exported key per repository, stored under /etc/apt/keyrings/, referenced by that repository's Signed-By - a key then vouches for exactly one source, and retiring the source retires the key with it.

To watch this work rather than read about it, the chapter now creates the signing key and the small practice archive announced in the introduction. First the key, in the root shell, kept in its own GnuPG home under /srv so it is never mixed with anyone's personal keyring:

# install -d -m 700 /srv/ch06-gnupg

Directory creation is silent on success. Generate the key:

# GNUPGHOME=/srv/ch06-gnupg gpg --batch --pinentry-mode loopback --passphrase "" --quick-generate-key "Debian Handbook Lab <lab@example.org>" ed25519 sign 2y
gpg: keybox '/srv/ch06-gnupg/pubring.kbx' created
gpg: /srv/ch06-gnupg/trustdb.gpg: trustdb created
gpg: directory '/srv/ch06-gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/srv/ch06-gnupg/openpgp-revocs.d/D5766FD3D63C13312FFB0B51BAB298F419FF7A9B.rev

The command prints its progress on standard error and creates an Ed25519 signing-only key valid for two years. The output lines name the pieces GnuPG made: the keybox holding key material, the trust database, and a revocation certificate - the emergency document that marks the key dead if it is ever compromised, stored outside the key itself. A production signing key deserves a passphrase and offline storage; this practice key is deliberately empty-passphrase and machine-local, and Section 6.6.2 returns to key hygiene for real archives.

Export the public half into APT's keyring directory - the public key is not secret, and it must be readable by every user APT runs as. The directory and both exports are silent; the redirections send the exported key to the named files, so nothing appears in the terminal:

# install -d -m 755 /etc/apt/keyrings
# GNUPGHOME=/srv/ch06-gnupg gpg --batch --armor --export lab@example.org > /etc/apt/keyrings/ch06-lab.asc
# GNUPGHOME=/srv/ch06-gnupg gpg --batch --export lab@example.org > /etc/apt/keyrings/ch06-lab.gpg

The ASCII-armored .asc copy is the one source files will name, and the binary .gpg copy suits gpgv's keyring argument in Section 6.6.5. Check what was published, as any user can:

$ gpg --show-keys --with-fingerprint /etc/apt/keyrings/ch06-lab.asc
pub   ed25519 2026-11-18 [SC] [expires: 2028-11-17]
      D576 6FD3 D63C 1331 2FFB  0B51 BAB2 98F4 19FF 7A9B
uid                      Debian Handbook Lab <lab@example.org>

gpg --show-keys reads a key file without any keyring of your own and prints the key's type, creation and expiry dates, and fingerprint - the identity a source's Signed-By can also pin as a fingerprint string when no key file is shipped. The first gpg run on an account also creates ~/.gnupg and reports that on standard error; those one-time setup lines are environment, not key data. The gpg options used here and in the rest of the chapter:

gpg option Description
--batch Never prompt; required for scripted use.
--pinentry-mode loopback --passphrase "" Take the passphrase from the argument instead of a prompt.
--quick-generate-key id type usage expire Create one key directly; 2y is two years.
--export name Write the public key (binary); --armor wraps it as text.
--clearsign file Sign a file into clear-signed text (InRelease).
-abs Make an armored, detached signature (Release.gpg).
--default-key id Choose the signing identity explicitly.
--show-keys --with-fingerprint file Display a key file's contents and fingerprint.

Second, the packages the archive will offer. The practice set is built by one script from john's workspace; it creates, for each package, a control file, a readme, and where the demonstrations need it a dependency, a recommendation, a configuration file, or a script. Save it as ~/debian-handbook/package-management/build-fixtures.sh:

#!/bin/sh
set -e
base=/home/john/debian-handbook/package-management/local-packages
rm -rf "$base"/*.deb "$base"/ch06-* "$base"/cowsay-99.0
mk() {
  pkg=$1
  ver=$2
  dir="$base/${pkg}-${ver}"
  mkdir -p "$dir/DEBIAN" "$dir/usr/share/doc/$pkg"
  cat > "$dir/DEBIAN/control" <<EOC
Package: $pkg
Version: $ver
Section: misc
Priority: optional
Architecture: all
Maintainer: Debian Handbook Lab <lab@example.org>
Description: Local test package $pkg version $ver
 Built by the Debian handbook package-management lab.
EOC
  printf "%s %s\n" "$pkg" "$ver" > "$dir/usr/share/doc/$pkg/README"
}
mk ch06-demo 1.0
mkdir -p "$base/ch06-demo-1.0/etc"
printf "mode=stable\n" > "$base/ch06-demo-1.0/etc/ch06-demo.conf"
printf "/etc/ch06-demo.conf\n" > "$base/ch06-demo-1.0/DEBIAN/conffiles"
mk ch06-demo 2.0
mkdir -p "$base/ch06-demo-2.0/etc"
printf "mode=updated\n" > "$base/ch06-demo-2.0/etc/ch06-demo.conf"
printf "/etc/ch06-demo.conf\n" > "$base/ch06-demo-2.0/DEBIAN/conffiles"
mk ch06-config 1.0
mkdir -p "$base/ch06-config-1.0/etc"
printf "enabled=true\n" > "$base/ch06-config-1.0/etc/ch06-config.conf"
printf "/etc/ch06-config.conf\n" > "$base/ch06-config-1.0/DEBIAN/conffiles"
mk ch06-dep 1.0
mk ch06-leaf 1.0
cat > "$base/ch06-leaf-1.0/DEBIAN/control" <<EOC
Package: ch06-leaf
Version: 1.0
Section: misc
Priority: optional
Architecture: all
Depends: ch06-dep (= 1.0)
Maintainer: Debian Handbook Lab <lab@example.org>
Description: Local test package ch06-leaf version 1.0
 Depends on ch06-dep for offline repository demonstrations.
EOC
mk ch06-extra 1.0
mk ch06-suite 1.0
cat > "$base/ch06-suite-1.0/DEBIAN/control" <<EOC
Package: ch06-suite
Version: 1.0
Section: misc
Priority: optional
Architecture: all
Recommends: ch06-extra
Maintainer: Debian Handbook Lab <lab@example.org>
Description: Local test package ch06-suite version 1.0
 Recommends ch06-extra for recommendation demonstrations.
EOC
mk ch06-lib 1.0
mk ch06-app 1.0
cat > "$base/ch06-app-1.0/DEBIAN/control" <<EOC
Package: ch06-app
Version: 1.0
Section: misc
Priority: optional
Architecture: all
Depends: ch06-lib (= 1.0)
Maintainer: Debian Handbook Lab <lab@example.org>
Description: Local test package ch06-app version 1.0
 Depends on ch06-lib for autoremove demonstrations.
EOC
mk ch06-fragile 1.0
cat > "$base/ch06-fragile-1.0/DEBIAN/postinst" <<EOS
#!/bin/sh
set -e
if [ -e /etc/ch06-fragile-block ]; then
  echo "ch06-fragile: refusing configuration because /etc/ch06-fragile-block exists" >&2
  exit 1
fi
exit 0
EOS
chmod 755 "$base/ch06-fragile-1.0/DEBIAN/postinst"
mk ch06-broken-deps 1.0
cat > "$base/ch06-broken-deps-1.0/DEBIAN/control" <<EOC
Package: ch06-broken-deps
Version: 1.0
Section: misc
Priority: optional
Architecture: all
Depends: ch06-missing-package (>= 1.0)
Maintainer: Debian Handbook Lab <lab@example.org>
Description: Local test package ch06-broken-deps version 1.0
 Has an intentionally unsatisfied dependency for repair demonstrations.
EOC
mk cowsay 99.0
mk ch06-tool 1.0
mkdir -p "$base/ch06-tool-1.0/usr/bin"
cat > "$base/ch06-tool-1.0/usr/bin/ch06-tool" <<EOS
#!/bin/sh
echo "ch06-tool 1.0 from the Debian handbook lab repository"
EOS
chmod 755 "$base/ch06-tool-1.0/usr/bin/ch06-tool"
mk ch06-locally-built 1.0
mkdir -p "$base/ch06-locally-built-1.0/usr/bin"
cat > "$base/ch06-locally-built-1.0/usr/bin/ch06-locally-built" <<EOS
#!/bin/sh
echo "locally built package works"
EOS
chmod 755 "$base/ch06-locally-built-1.0/usr/bin/ch06-locally-built"
for dir in "$base"/*/; do
  name=$(basename "$dir")
  pkg=${name%-*}
  ver=${name##*-}
  [ "$pkg" = ch06-locally-built ] && continue
  dpkg-deb --root-owner-group --build "$dir" "$base/${pkg}_${ver}_all.deb"
done
ls -1 "$base"/*.deb

Run it as john - package building needs no privilege, and --root-owner-group makes the content files root-owned inside the archive so they install with the right ownership:

$ bash ~/debian-handbook/package-management/build-fixtures.sh
dpkg-deb: building package 'ch06-app' in '/home/john/debian-handbook/package-management/local-packages/ch06-app_1.0_all.deb'.
dpkg-deb: building package 'ch06-broken-deps' in '/home/john/debian-handbook/package-management/local-packages/ch06-broken-deps_1.0_all.deb'.
dpkg-deb: building package 'ch06-config' in '/home/john/debian-handbook/package-management/local-packages/ch06-config_1.0_all.deb'.
dpkg-deb: building package 'ch06-demo' in '/home/john/debian-handbook/package-management/local-packages/ch06-demo_1.0_all.deb'.
dpkg-deb: building package 'ch06-demo' in '/home/john/debian-handbook/package-management/local-packages/ch06-demo_2.0_all.deb'.
dpkg-deb: building package 'ch06-dep' in '/home/john/debian-handbook/package-management/local-packages/ch06-dep_1.0_all.deb'.
dpkg-deb: building package 'ch06-extra' in '/home/john/debian-handbook/package-management/local-packages/ch06-extra_1.0_all.deb'.
dpkg-deb: building package 'ch06-fragile' in '/home/john/debian-handbook/package-management/local-packages/ch06-fragile_1.0_all.deb'.
dpkg-deb: building package 'ch06-leaf' in '/home/john/debian-handbook/package-management/local-packages/ch06-leaf_1.0_all.deb'.
dpkg-deb: building package 'ch06-lib' in '/home/john/debian-handbook/package-management/local-packages/ch06-lib_1.0_all.deb'.
dpkg-deb: building package 'ch06-suite' in '/home/john/debian-handbook/package-management/local-packages/ch06-suite_1.0_all.deb'.
dpkg-deb: building package 'ch06-tool' in '/home/john/debian-handbook/package-management/local-packages/ch06-tool_1.0_all.deb'.
dpkg-deb: building package 'cowsay' in '/home/john/debian-handbook/package-management/local-packages/cowsay_99.0_all.deb'.
/home/john/debian-handbook/package-management/local-packages/ch06-app_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-broken-deps_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-config_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-demo_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-demo_2.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-dep_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-extra_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-fragile_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-leaf_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-lib_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-suite_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/ch06-tool_1.0_all.deb
/home/john/debian-handbook/package-management/local-packages/cowsay_99.0_all.deb

Thirteen archives come out; the ch06-locally-built tree is deliberately left as a directory, because Section 6.5.3 builds it by hand. The names follow the archive convention name_version_architecture.deb. Note one deliberate fake in the set: cowsay 99.0 reuses the name of a real Debian package with an absurd version - it exists so Section 6.2.4 can demonstrate what a third-party archive can do to an established name, and so that the demonstration can be contained again.

Third, assemble the repository itself, in the root shell, following the layout of Figure 6.2.

Anatomy of a signed APT repository

Figure 6.2. The practice archive's tree and the order apt consumes it: the signature is checked before anything else, then freshness, then index checksums, and only then are packages fetched from the pool.

# install -d /srv/ch06-repo/pool/main /srv/ch06-repo/dists/trixie/main/binary-amd64

The pool receives twelve of the thirteen archives just built. The ch06-tool archive is held back deliberately: Section 6.6.3 publishes it through a second, separately managed repository, and keeping it out of this one is what makes that section's candidate report unambiguous. The braces expand to the twelve archive names, and the copy prints nothing on success:

# cp /home/john/debian-handbook/package-management/local-packages/{ch06-app_1.0,ch06-broken-deps_1.0,ch06-config_1.0,ch06-demo_1.0,ch06-demo_2.0,ch06-dep_1.0,ch06-extra_1.0,ch06-fragile_1.0,ch06-leaf_1.0,ch06-lib_1.0,ch06-suite_1.0,cowsay_99.0}_all.deb /srv/ch06-repo/pool/main/
# ls -1 /srv/ch06-repo/pool/main
ch06-app_1.0_all.deb
ch06-broken-deps_1.0_all.deb
ch06-config_1.0_all.deb
ch06-demo_1.0_all.deb
ch06-demo_2.0_all.deb
ch06-dep_1.0_all.deb
ch06-extra_1.0_all.deb
ch06-fragile_1.0_all.deb
ch06-leaf_1.0_all.deb
ch06-lib_1.0_all.deb
ch06-suite_1.0_all.deb
cowsay_99.0_all.deb

The two commands before the listing print nothing on success - install -d creates directories, cp copies. The tree now holds the twelve packages in pool/ and the empty index area dists/trixie/main/binary-amd64/ that a trixie suite, main component, amd64 architecture repository must provide. Build the package index over the pool - the cd puts the root shell in the repository root, and the following two commands use its relative paths:

# cd /srv/ch06-repo && apt-ftparchive packages pool > dists/trixie/main/binary-amd64/Packages
# gzip -kf dists/trixie/main/binary-amd64/Packages
# grep -c "^Package:" dists/trixie/main/binary-amd64/Packages
12

The apt-ftparchive packages run scans the pool and writes one stanza per archive - name, version, dependencies, description, size, checksum, and the Filename pool path clients fetch - into the Packages index; the redirection sends it to the index file, so the terminal shows nothing. gzip -kf makes the compressed copy clients may prefer, keeping the original with -k; it prints nothing either. The grep -c count confirms twelve stanzas for the twelve archives - ch06-demo appears once per version, its two stanzas the exact way indexes represent multiple versions of one package. apt-ftparchive comes from the apt-utils package, which the example system has installed; a minimal system needs it added once with apt-get install apt-utils.

The Release file is generated from the index directory, with the suite's identity supplied as options:

# apt-ftparchive -o APT::FTPArchive::Release::Origin="Debian Handbook Lab" -o APT::FTPArchive::Release::Label="Debian Handbook Lab" -o APT::FTPArchive::Release::Suite="trixie" -o APT::FTPArchive::Release::Codename="trixie" -o APT::FTPArchive::Release::Architectures="amd64 all" -o APT::FTPArchive::Release::Components="main" -o APT::FTPArchive::Release::Description="Debian handbook local package repository" release dists/trixie > dists/trixie/Release
# printf "Valid-Until: %s\n" "$(date -u -d "+7 days" "+%a, %d %b %Y %H:%M:%S UTC")" >> dists/trixie/Release
# grep -E "^(Origin|Codename|Valid-Until):" dists/trixie/Release
Codename: trixie
Origin: Debian Handbook Lab
Valid-Until: Wed, 25 Nov 2026 21:34:20 UTC

The first command writes the Release file - checksums for every index, plus the fields the options set: the Origin that pins and unattended upgrades key on, the suite and codename a source's Suites: line matches, the architectures and components offered, a human label, and a description - silently, through its redirection. The second appends the Valid-Until freshness bound, seven days out, with no output either; apt-ftparchive release does not set one itself, and Section 6.7.2 shows the failure a repository without a current Valid-Until produces. The grep confirms the three fields that matter most to the demonstrations ahead. Every field and its client-side meaning is tabulated in Section 6.6.2, which revisits this build from the publisher's perspective.

Sign the result with the key created at the start of the section, in both published forms. The first command moves the shell into the suite's directory and signs there; the second and the inspection below inherit that directory:

# cd /srv/ch06-repo/dists/trixie && GNUPGHOME=/srv/ch06-gnupg gpg --batch --yes --pinentry-mode loopback --passphrase "" --default-key lab@example.org --clearsign -o InRelease Release
gpg: using "lab@example.org" as default secret key for signing
# GNUPGHOME=/srv/ch06-gnupg gpg --batch --yes --pinentry-mode loopback --passphrase "" --default-key lab@example.org -abs -o Release.gpg Release
gpg: using "lab@example.org" as default secret key for signing
# sed -n "1,4p" InRelease
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Architectures: amd64 all

Each gpg run reports its choice of key on standard error and writes the signature; the sed excerpt shows InRelease opening as clear-signed text - the BEGIN PGP SIGNED MESSAGE envelope around the Release content, so one file carries both the metadata and its signature. The detached Release.gpg is the same signature as a separate file, for clients that fetch Release first. Publishing either form is enough; publishing both costs nothing.

Last, add the source, binding it to the exported key. Create /etc/apt/sources.list.d/ch06-local.sources with this content:

Types: deb
URIs: file:/srv/ch06-repo
Suites: trixie
Components: main
Signed-By: /etc/apt/keyrings/ch06-lab.asc

The file: URI scheme makes any directory on the machine a repository served from local disk - the same layout, signature, and client behavior as an https: source, with no network. A real third-party vendor's instructions would look like this stanza with https:// and their own key. Refresh and watch the verification happen:

$ sudo apt-get update
Get:1 file:/srv/ch06-repo trixie InRelease [1874 B]
Get:1 file:/srv/ch06-repo trixie InRelease [1874 B]
Get:2 file:/srv/ch06-repo trixie/main amd64 Packages [2686 B]
Hit:3 https://deb.debian.org/debian trixie InRelease
Hit:4 https://deb.debian.org/debian trixie-updates InRelease
Hit:5 https://security.debian.org/debian-security trixie-security InRelease
Hit:6 https://deb.debian.org/debian trixie-backports InRelease
Reading package lists...

Get marks fetched files - the practice archive's InRelease, verified against /etc/apt/keyrings/ch06-lab.asc before anything else was touched, then its Packages index; the doubled InRelease line is the file: transport's logging, not a second download. Hit marks indexes already current: the four Debian suites were refreshed earlier in the day, so apt checked their InRelease dates and reused them. A repository with no signature at all fails this step outright - an unsigned copy of this same tree is rejected with The repository '… trixie Release' is not signed - and a bad signature produces the failure Section 6.7.2 deliberately induces.

6.2.4. Evaluating and Isolating Third-Party Repositories

A third-party repository is an act of trust with system-wide reach: it can offer anything, including replacement versions of packages Debian ships, and every source competes on version numbers alone unless the administrator says otherwise. The practice archive is now exactly such a foreign source, and its fake cowsay 99.0 shows the reach concretely. Debian's real cowsay is version 3.03+dfsg2-8; with the source added, ask apt who wins:

$ apt-cache policy cowsay
cowsay:
  Installed: (none)
  Candidate: 99.0
  Version table:
     99.0 500
        500 file:/srv/ch06-repo trixie/main amd64 Packages
     3.03+dfsg2-8 500
        500 https://deb.debian.org/debian trixie/main amd64 Packages

Both versions carry the default priority 500, and between equal priorities apt takes the higher version - so the fabricated 99.0 is the candidate, and apt-get install cowsay would install the fake. A repository can do this to any package name it lists; version numbers, not source identity, are what apt ranks. The defense is a pin that demotes everything the source offers below Debian's own priority. Create /etc/apt/preferences.d/ch06-cowsay.pref:

Package: cowsay
Pin: release o=Debian Handbook Lab
Pin-Priority: 100

The three lines read: for the package cowsay, versions whose repository Origin is Debian Handbook Lab get priority 100. The o= matches the Origin: field set in the archive's Release file in Section 6.2.3 - apt-cache policy prints origins for exactly this use. Priority 100 sits below the 500 Debian's own packages carry, high enough to allow an explicit, per-command choice but never a default. Ask again:

$ apt-cache policy cowsay
cowsay:
  Installed: (none)
  Candidate: 3.03+dfsg2-8
  Version table:
     99.0 100
        500 file:/srv/ch06-repo trixie/main amd64 Packages
     3.03+dfsg2-8 500
        500 https://deb.debian.org/debian trixie/main amd64 Packages

The candidate is Debian's version again, and the version table shows why: the fake still exists but now weighs 100. A simulation confirms what an install would really do, with no privileges needed:

$ apt-get -s install cowsay
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
  filters cowsay-off
The following NEW packages will be installed:
  cowsay
0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded.
Inst cowsay (3.03+dfsg2-8 Debian:13.7/stable [all])
Conf cowsay (3.03+dfsg2-8 Debian:13.7/stable [all])

The banner is apt-get's own reminder of what -s means; the plan's two Inst and Conf lines name the package and version that would be installed - 3.03+dfsg2-8, from Debian:13.7/stable, the real Debian stable suite, not the practice archive. Section 6.3.2 performs the real install and gets exactly this version. The pin stays in place for the rest of the chapter: it is what keeps the fake cowsay from ever being chosen accidentally.

Priorities are ranges with defined meanings, and the whole mechanism is worth one table - it returns in Sections 6.5.1 and 6.5.2:

Priority range Meaning
≥ 1000 May downgrade to match - only for deliberate version forcing.
990 Set by apt-get -t suite for the named release.
500 Default for a regular repository.
100 Backports; also the installed database itself.
1–99 Installed only when the package is not installed at all.
< 0 Never chosen, whatever else is true.

Before adding a real third-party source, the same reasoning that built the pin applies as a checklist. Establish provenance: the key's fingerprint as published over an authenticated channel, not merely the download; a vendor page that tells you the fingerprint is the equivalent of Section 6.2.3's gpg --show-keys step. Establish scope: what packages the source intends to ship, whether it rebuilds packages Debian already provides, and who maintains it when something breaks. Bind the key to the one source with Signed-By in a dedicated .sources stanza, so retiring the source retires the trust. Demote the source below Debian with a pin unless you have a specific reason to let it win version comparisons, and prefer sources that name only what they actually maintain. The same discipline, scaled up to organizational archives, is what Section 6.6.2 builds on.