Skip to content

Commit f2c8c68

Browse files
authored
Merge pull request #72 from Habbie/debian-ubuntu-numbered
build-debs: prefer [distro][number] over distribution codenames
2 parents eda76bd + cb22cad commit f2c8c68

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

helpers/build-debs.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,21 @@ for dir in "${dirs[@]}"; do
4444
exit 1
4545
fi
4646
# Let's try really hard to find the release name of the distribution
47-
distro_release="$(source /etc/os-release; printf ${VERSION_CODENAME})"
48-
if [ -z "${distro_release}" -a -n "$(grep 'VERSION_ID="14.04"' /etc/os-release)" ]; then
49-
distro_release='trusty'
50-
fi
51-
if [ -z "${distro_release}" ]; then
52-
distro_release="$(perl -n -e '/VERSION=".* \((.*)\)"/ && print $1' /etc/os-release)"
53-
fi
47+
# Prefer something that sorts well over time
48+
distro_release="$(source /etc/os-release; [ ! -z ${ID} ] && [ ! -z ${VERSION_ID} ] && echo -n ${ID}${VERSION_ID})" # this will look like 'debian12' or 'ubuntu22.04'
5449
if [ -z "${distro_release}" ]; then
55-
distro_release="$(perl -n -e '/PRETTY_NAME="Debian GNU\/Linux (.*)\/sid"/ && print $1' /etc/os-release)"
50+
# we should only end up here on Debian Testing
51+
distro="$(source /etc/os-release; echo -n ${ID})"
52+
if [ ! -z "${distro}" ]; then
53+
releasename="$(perl -n -e '/PRETTY_NAME="Debian GNU\/Linux (.*)\/sid"/ && print $1' /etc/os-release)"
54+
if [ ! -z "${releasename}" ]; then
55+
apt-get -y --no-install-recommends install distro-info-data
56+
releasenum="$(grep ${releasename} /usr/share/distro-info/debian.csv | cut -f1 -d,)"
57+
if [ ! -z "${releasenum}" ]; then
58+
distro_release="${distro}${releasenum}"
59+
fi
60+
fi
61+
fi
5662
fi
5763
if [ -z "${distro_release}" ]; then
5864
echo 'Unable to determine distribution codename!'

0 commit comments

Comments
 (0)