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 9bf0fb6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/system/libs/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ function get_system_version() {
return
fi

echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1)
. "$os_release"
echo "$VERSION_ID"
}


Expand Down

0 comments on commit 9bf0fb6

Please sign in to comment.