Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apt-add-repository doesn't work on debian 12 [closed]

Tags:

debian

When I try to add non-free on debian 12 (bookworm) with apt-add-repository nothing happens. This used to work on bullseye. I guess the reason is that package source files changed format. Old format was:

deb http://deb.debian.org/debian/ bookworm main

New format

Types: deb
# http://snapshot.debian.org/archive/debian/20230703T000000Z
URIs: http://deb.debian.org/debian
Suites: bookworm bookworm-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

When I run apt-add-repository the file doesn't change. No new components are added.

# apt-get update
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Reading package lists... Done
# apt-add-repository -y non-free
Adding component(s) 'non-free' to all repositories.
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Reading package lists... Done
# cat /etc/apt/sources.list.d/debian.sources 
Types: deb
# http://snapshot.debian.org/archive/debian/20230703T000000Z
URIs: http://deb.debian.org/debian
Suites: bookworm bookworm-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
# http://snapshot.debian.org/archive/debian-security/20230703T000000Z
URIs: http://deb.debian.org/debian-security
Suites: bookworm-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Is there any solution to that apart from manually editing the debian.sources file?

like image 943
Milosz Wasilewski Avatar asked Sep 15 '25 14:09

Milosz Wasilewski


1 Answers

This is most likely caused due to the introduction of a new standard data format for APT, DEB822.

It's already being shipped in Debian 12 (Bookworm) Docker containers (see: /etc/apt/sources.list.d/debian.sources and sources.list). However, the old format is still being used by apt-add-repository which is most likely why $ apt-add-repository non-free isn't able to parse and update the sources at all.

Workaround 1

Here's a workaround (which as of writing this adds non-free repositories in the old format for the current os-release and specified mirror url):

add-apt-repository -U http://deb.debian.org/debian -c non-free-firmware -c non-free

Edit: there's another bug at play here, this command needs to be executed twice (using e.g. !!) to take effect as it's not flushing to disk on the first run (perhaps due to new Python version in Bookworm?). Consider this example for installing steamcmd

apt -y install software-properties-common
dpkg --add-architecture i386
add-apt-repository -y -n -U http://deb.debian.org/debian -c non-free -c non-free-firmware
!!
apt update
apt install steamcmd

Workaround 2

Alternatively, append desired components manually to DEB822 sources to avoid software-properties-common python3 (apt-add-repository) dependencies all-together:

sed -i 's/^Components: main$/& contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources
apt update

Relevant:

  • non-free changes: https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#non-free-split
  • mirror components: https://wiki.debian.org/SourcesList#Component & http://ftp.debian.org/debian/dists/bookworm/
like image 190
xRiot Avatar answered Sep 18 '25 09:09

xRiot