Don't break your Debian - Unstable repositories

If you have been using Debian for a longer period of time, likely you have added unstable repositories to your apt at some point. Later with a system update/upgrade you might have pretty much destroyed your system and ended up in dependency hell.

Sid has the same priority as any stable release you currently are using, this means newer versions of packages from sid will have higher priority. Apt will always update to the new version.

A good example is apt full-upgrade, before adding sid:

> apt full-upgrade

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

After:

> apt full-upgrade

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  libclang-rt-15-dev
The following packages will be upgraded:
  adduser bind9-dnsutils bind9-host bind9-libs 
  .... <many packages here> ....
  vim-common vim-nox vim-runtime vim-tiny xwayland zstd
131 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 226 MB of archives.
After this operation, 12.2 MB disk space will be freed.

apt-cache policy can provide us with more details, here is the output for libawl-php package:

libawl-php:
  Installed: (none)
  Candidate: 0.64-1
  Version table:
     0.64-1 500
        500 http://deb.debian.org/debian sid/main amd64 Packages
        500 http://deb.debian.org/debian sid/main i386 Packages
     0.63-1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        500 http://deb.debian.org/debian bookworm/main i386 Packages

To ensure this does not happen, you must reduce repository priority.

Set apt pin-priorities

File: /etc/apt/sources.list

deb http://deb.debian.org/debian sid main non-free-firmware
deb http://deb.debian.org/debian experimental main non-free-firmware

File: /etc/apt/preferences.d/experimental

Package: *
Pin: release n=experimental
Pin-Priority: 1

File: /etc/apt/preferences.d/sid

Package: *
Pin: release n=sid
Pin-Priority: 1

Reducing priorities to 1 from default 500 will ensure packages are not installed from these unstable repositories by default when doing system updates or resolving dependencies.

And our libawl-php will no longer be installed from sid:

libawl-php:
  Installed: (none)
  Candidate: 0.63-1
  Version table:
     0.64-1 1
          1 http://deb.debian.org/debian sid/main amd64 Packages
          1 http://deb.debian.org/debian sid/main i386 Packages
     0.63-1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        500 http://deb.debian.org/debian bookworm/main i386 Packages