Skip to content

Commit b733088

Browse files
committed
(tasks) Translate Debian codename to version when version is n/a
The /etc/os-release data for Debian pre-release builds only contains the codename, not the version number. The VERSION_ID strings are all 'n/a'. This is a problem for installing openvox packages, because their naming scheme includes the release number. This patch adds a little static stranslation of codename to version when we encounter an 'n/a' version. This isn't the greatest solution, since it will need ongoing upkeep for future Debian releases, but it is self contained. I considered accepting a version override as a task parameter, but it's not simple for the caller to be able to consistently provide this information either. It's unknown to me whether the next Ubuntu LTS release will have a similar problem, but I haven't found a 26.04 codename either.
1 parent b9db5e9 commit b733088

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

files/common.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,41 @@ download() {
7474
fi
7575
}
7676

77+
# Debian pre-release builds do not contain their version number
78+
# in /etc/os-release. They do contain codename. Openvox packages
79+
# are named with the version number. Hence this lookup, that
80+
# unfotunately needs to be updated with each new Debian release...
81+
translate_codename_to_version() {
82+
local _codename="$1"
83+
84+
case "${_codename}" in
85+
trixie)
86+
echo '13'
87+
;;
88+
forky)
89+
echo '14'
90+
;;
91+
*)
92+
# VERSION_ID is set to 'n/a' in /etc/os-release, so
93+
# if we don't know the codename, let's return the same value.
94+
echo 'n/a'
95+
;;
96+
esac
97+
}
98+
7799
# Set platform, full_version and major_version variables by reaching
78100
# out to the puppetlabs-facts bash task as an executable.
79101
set_platform() {
80102
local facts="${installdir}/facts/tasks/bash.sh"
81103
if [ -e "${facts}" ]; then
82104
platform=$(bash "${facts}" platform)
83105
full_version=$(bash "${facts}" release)
106+
if [[ "${full_version}" == "n/a" ]]; then
107+
# Hit the facts json with blunt objects until the codename value
108+
# pops out...
109+
codename=$(bash "${facts}" | grep '"codename"' | cut -d':' -f2 | grep -oE '[^ "]+')
110+
full_version=$(translate_codename_to_version "${codename}")
111+
fi
84112
major_version=${full_version%%.*}
85113
else
86114
fail "Unable to find the puppetlabs-facts bash task to determine platform at '${facts}'."

0 commit comments

Comments
 (0)