Skip to content

Instantly share code, notes, and snippets.

@Mealman1551
Created February 6, 2025 17:20
Show Gist options
  • Save Mealman1551/f75223b3cade0a218d51c06f6cb08f40 to your computer and use it in GitHub Desktop.
Save Mealman1551/f75223b3cade0a218d51c06f6cb08f40 to your computer and use it in GitHub Desktop.

Debian Trixie and the New deb822 Format for APT Sources

Introduction

Since February 2025, Debian 13 (Trixie) and APT introduced the deb822 format for managing APT sources. This new format replaces the traditional /etc/apt/sources.list file with the more structured and readable /etc/apt/sources.list.d/debian.sources file.

This change was introduced by APT, starting with an update that enabled users to run:

apt modernize-sources

This command automatically converts the old sources.list format to the new deb822 format.

APT automatically creates a backup (/etc/apt/sources.list.bak) and a .save copy of the original sources.list before making changes. This ensures that users can revert if needed.

The new format enhances maintainability, security, and flexibility by adopting a key-value pair structure inspired by RFC822-style configuration files.


What is deb822?

The deb822 format is a structured configuration format based on the RFC822 standard. It is already used in Debian for various package-related files, such as dpkg status files and APT preferences.

The new format improves upon the classic sources.list syntax by making it:

  • More readable: Clearly structured with key-value pairs.
  • More modular: Each repository is defined in a separate block.
  • More secure: Explicitly defines trusted keys.
  • Easier to maintain: More flexible for future changes.

Comparison: Old vs. New Format

New deb822 Format (/etc/apt/sources.list.d/debian.sources)

# Modernized from /etc/apt/sources.list
Types: deb deb-src
URIs: http://deb.debian.org/debian/
Suites: trixie
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# Security updates
Types: deb deb-src
URIs: http://security.debian.org/debian-security/
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# Updates repository
Types: deb deb-src
URIs: http://deb.debian.org/debian/
Suites: trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Old sources.list Format (/etc/apt/sources.list)

deb http://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security/ trixie-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security/ trixie-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian/ trixie-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ trixie-updates main contrib non-free non-free-firmware

Key Advantages of deb822 Format

  1. Improved Readability

    • Clearly structured key-value pairs.
    • Easier to edit and maintain.
  2. Better Security

    • The Signed-By: field explicitly defines which key is used for signing.
    • Avoids the risks of globally trusted keys in /etc/apt/trusted.gpg.
  3. Modular and Flexible

    • Each repository definition is in a separate block.
    • Easier to enable/disable repositories.
  4. Supports Multiple Suites and Architectures

    • The Suites: field allows multiple suites per repository.
    • Works well with multi-architecture systems.
  5. Future-Proof

    • New features can be added without breaking the structure.

How to Migrate to deb822 Format

Step 1: Run the Automatic Conversion

sudo apt modernize-sources

This command will automatically convert your sources.list into the new deb822 format and place it in /etc/apt/sources.list.d/debian.sources.

APT will also create backups:

  • /etc/apt/sources.list.bak
  • /etc/apt/sources.list.save

These backups allow you to revert changes if necessary.

Step 2: Verify the New deb822 Configuration

Open the generated file to check its correctness:

sudo nano /etc/apt/sources.list.d/debian.sources

Step 3: Update APT Sources

sudo apt update

Conclusion

The transition to deb822 for APT sources in Debian Trixie is a major improvement. It makes managing repositories clearer, more secure, and more flexible. Debian has simplified the migration by adding the apt modernize-sources command, making it easier for users to switch.

Since APT automatically creates backups, users can safely migrate to deb822 without the risk of losing their original configuration.

All users are encouraged to update their APT sources to take advantage of these improvements.

For more information, refer to the Debian APT documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment