Skip to content

Commit

Permalink
test/system: Fix reading the os-release(5) VERSION_ID on Ubuntu
Browse files Browse the repository at this point in the history
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 b27795a

containers#1320
  • Loading branch information
debarshiray committed Jun 23, 2023
1 parent 62c31ca commit 4322824
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/system/libs/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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
Expand Down

0 comments on commit 4322824

Please sign in to comment.