From 91ffc79c7be1b98844bc88258ea067291d81633c Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 2 Jun 2025 09:11:19 -0600 Subject: [PATCH] better version check in linux build script (#9496) * better version check in linux build script Running `BuildLinux.sh` on Debian Trixie (and probably on other platforms) results in this warning: ``` $ sudo ./BuildLinux.sh -u ./linux.d/debian: line 32: [: ==: unary operator expected ./linux.d/debian: line 32: [: ==: unary operator expected ... ``` The script is looking for the `VERSION_ID` variable in `/etc/os-release`, but that variable is optional (see https://www.linux.org/docs/man5/os-release.html) and is not present in my install of Debian Trixie. The script handles the missing variable incorrectly, resulting in the above warning. This commit fixes the version check to be more tolerant and IMO clearer. Tested on Ubuntu 22.04, 24.04, and Debian Trixie. --- linux.d/debian | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux.d/debian b/linux.d/debian index bc4e712c57..10d866fcb5 100644 --- a/linux.d/debian +++ b/linux.d/debian @@ -28,12 +28,16 @@ REQUIRED_DEV_PACKAGES=( if [[ -n "$UPDATE_LIB" ]] then - # for ubuntu 22+ and 23+: - ubu_major_version="$(grep VERSION_ID /etc/os-release | cut -d "=" -f 2 | cut -d "." -f 1 | tr -d /\"/)" - if [ $ubu_major_version == "22" ] || [ $ubu_major_version == "23" ] - then - REQUIRED_DEV_PACKAGES+=(curl libfuse-dev libssl-dev libcurl4-openssl-dev m4) + source /etc/os-release + if [ "${ID}" == "ubuntu" ] && [ -n "${VERSION_ID}" ]; then + # It's ubuntu and we have a VERSION_ID like "24.04". + if dpkg --compare-versions "${VERSION_ID}" ge 22 && dpkg --compare-versions "${VERSION_ID}" lt 24 ; + then + # Some extra packages needed on Ubuntu 22.x and 23.x: + REQUIRED_DEV_PACKAGES+=(curl libfuse-dev libssl-dev libcurl4-openssl-dev m4) + fi fi + if [[ -n "$BUILD_DEBUG" ]] then REQUIRED_DEV_PACKAGES+=(libssl-dev libcurl4-openssl-dev)