From 4322824061721b856d905749b414d2627ed11e67 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 23 Jun 2023 12:47:05 +0200 Subject: [PATCH] test/system: Fix reading the os-release(5) VERSION_ID on Ubuntu The current approach of extracting the VERSION_ID field from os-release(5) assumes that the value is not quoted. There's no guarantee that this will be the case. It only happens to be so on Fedora by chance, and is different on Ubuntu: $ cat /etc/os-release ... VERSION_ID="22.04" ... This means that "22.04", including the double quotes, is read as the value of VERSION_ID on Ubuntu, not 22.04. This is wrong because this value can't be used as is in image and container names. There's no image called quay.io/toolbx/ubuntu-toolbox:"22.04" and double quotes are not allowed in container names. Instead, use the same approach as profile.d/toolbox.sh and the old POSIX shell implementation that doesn't rely on the quoting of the os-release(5) values. Fallout from b27795a03ec8ae3139e2dad93b4efca13e96fb01 https://github.com/containers/toolbox/pull/1320 --- test/system/libs/helpers.bash | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 6012a62..6faf404 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -510,7 +510,7 @@ function get_system_id() ( # Returns the content of field VERSION_ID in os-release -function get_system_version() { +function get_system_version() ( local os_release os_release="$(find_os_release)" @@ -520,8 +520,9 @@ function get_system_version() { return fi - echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1) -} + . "$os_release" + echo "$VERSION_ID" +) # Set up the XDG_RUNTIME_DIR variable if not set