fix(docker/rootless): parse slirp4netns version cleanly
slirp4netns --version prints multiple lines (version, commit, libslirp,
SLIRP_CONFIG_VERSION_MAX). The old 'awk {print $2}' ran on every line and
also picked the literal word 'version' from line 1, producing a multi-line
blob that leaked into the 'is outdated' notice. Read only the first line and
take field 3 (the actual number), strip the leading v from the GitHub tag so
the comparison is meaningful, and skip the check if the tag fetch fails.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
parent
8fdbe1ea08
commit
0f844783a3
@ -35,9 +35,12 @@ installDockerRootless()
|
||||
checkSuccess "Installing slirp4netns"
|
||||
else
|
||||
isNotice "slirp4netns is already installed"
|
||||
installed_version=$(slirp4netns --version | awk '{print $2}')
|
||||
# `slirp4netns --version` prints several lines (version, commit, libslirp,
|
||||
# SLIRP_CONFIG_VERSION_MAX); read only the first line and take the version field.
|
||||
installed_version=$(slirp4netns --version | head -n1 | awk '{print $3}')
|
||||
latest_version=$(curl -s https://api.github.com/repos/rootless-containers/slirp4netns/releases/latest | grep tag_name | cut -d '"' -f 4)
|
||||
if [[ "$installed_version" != "$latest_version" ]]; then
|
||||
latest_version=${latest_version#v} # GitHub tags are vX.Y.Z; strip the v to compare
|
||||
if [[ -n "$latest_version" && "$installed_version" != "$latest_version" ]]; then
|
||||
isNotice "slirp4netns version $installed_version is outdated."
|
||||
isNotice "Installing version $latest_version..."
|
||||
local result; result=$(runSystem apt-get update)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user