Fix armbian header (#4144)

* bsp: quote pattern passed to grep

This fixes a regression from #4013

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>

* bsp: refactor DISTRIBUTION_CODENAME logic

There's no need to repeat the check for /etc/armbian-distribution-status
over and over again, let's just use an if-statement instead.

Similarly, let's not repeat the logic to look up DISTRIBUTION_STATUS in
/etc/armbian-distribution-status; we can just do it at the end instead.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>

* bsp: only fallback to /etc/os-release if /etc/lsb-release failed

This fixes a regression from #3619

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>

* bsp: only fallback to "lsb_release -c" if all else failed

Debian Bookwork and Sid both neither have the debian-edu-config package
by default (which provodes /etc/lsb-release in Debian), nor does their
version of base-files (12.2) contain the VERSION_CODENAME field.

So we need another fallback. We *do* have lsb_release, which can provide
this information as well. So let's do that, but add a check as well in
case neither the lsb-release nor the lsb-release-minimal packages is
installed on a user's system.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
This commit is contained in:
Erik Faye-Lund 2022-09-03 23:21:00 +02:00 committed by GitHub
parent 48628eb431
commit 10aeb2f305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,13 @@ THIS_SCRIPT="header"
MOTD_DISABLE=""
[[ -f /etc/armbian-release ]] && . /etc/armbian-release
[[ -f /etc/armbian-distribution-status ]] && . /etc/armbian-distribution-status
[[ -f /etc/lsb-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(grep $DISTRIBUTION_CODENAME /etc/armbian-distribution-status | cut -d"=" -f2)
[[ -f /etc/os-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(grep $DISTRIBUTION_CODENAME /etc/armbian-distribution-status | cut -d"=" -f2)
if [[ -f /etc/armbian-distribution-status ]]; then
. /etc/armbian-distribution-status
[[ -f /etc/lsb-release ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2)
[[ -z "$DISTRIBUTION_CODENAME" && -f /etc/os-release ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2)
[[ -z "$DISTRIBUTION_CODENAME" && -x /usr/bin/lsb_release ]] && DISTRIBUTION_CODENAME=$(/usr/bin/lsb_release -c | cut -d":" -f2 | tr -d "\t")
DISTRIBUTION_STATUS=$(grep "$DISTRIBUTION_CODENAME" /etc/armbian-distribution-status | cut -d"=" -f2)
fi
[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd
for f in $MOTD_DISABLE; do