Debian 12: ${VERSION_CODENAME} is Empty

Afternoon, I’m trying to install cockpit but I want the latest version using the instruction here Running Cockpit — Cockpit Project. After making the changes, the update fails because

${VERSION_CODENAME}

is empty. Where is the os-release file located if any or how do I solve this?

UPDATE: I believe I’ve found the file that is needed, its the “debian_version” file. I will use this instead.

Well the instruction even when using the correct file is producing an empty value:

. /etc/debian_version
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > \
    /etc/apt/sources.list.d/backports.list

cat backports.list:

deb http://deb.debian.org/debian -backports main

What is a sure way to do this using version file?

UPDATE: I just found this and try it

env -i bash -c '. /etc/os-release; echo $VERSION_CODENAME'
bookworm

here How to get the Debian codename without lsb_release and it works. Will give it a try.

This worked

env -i bash -c '. /etc/os-release; echo deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main' > /etc/apt/sources.list.d/backports.list

but what does this mean?:

root@kvmserver:/etc/apt/sources.list.d# apt update
Hit:1 http://security.debian.org/debian-security bookworm-security InRelease                          
Hit:2 http://deb.debian.org/debian bookworm InRelease                                                 
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Get:4 http://deb.debian.org/debian bookworm-backports InRelease [59.4 kB]
Get:5 http://deb.debian.org/debian bookworm-backports/main amd64 Packages [287 kB]
Get:6 http://deb.debian.org/debian bookworm-backports/main Translation-en [244 kB]
Fetched 590 kB in 2s (287 kB/s)          
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
N: Ignoring file ' ' in directory '/etc/apt/sources.list.d/' as it has no filename extension

UPDATE: I found the problem, some how I created a file with quotes. All is good! :blush:

:roll_eyes: Okay now this:

apt install -t ${VERSION_CODENAME}-backports cockpit
E: Option -t requires an argument.

These instruction from cockpit are not working, the ${VERSION_CODENAME} is empty at this stage of the installation. Is this env var suppose to be intialized?

I found this Use Awk To Get Debian/ubuntu/rpi VERSION_CODENAME and put this together:

VERSION_CODENAME=$(awk -F= '/VERSION_CODENAME/ { print $2 }' /etc/os-release)
apt install -t ${VERSION_CODENAME}-backports cockpit

and it works, but this

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package bookworm-backports

I do another update

apt 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 bookworm-backports InRelease                    
Get:4 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:5 http://security.debian.org/debian-security bookworm-security/non-free-firmware Sources [796 B]
Get:6 http://security.debian.org/debian-security bookworm-security/non-free-firmware amd64 Packages [688 B]

and see that the backports.list is not included. Where am I going wrong?