Skip to content

Commit e2ce367

Browse files
authored
fix: update server requirements check for alpine distro (microsoft#203790)
1 parent c481f95 commit e2ce367

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

resources/server/bin/helpers/check-requirements-linux.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,27 @@
55

66
set -e
77

8+
# Do not remove this check.
9+
# Provides a way to skip the server requirements check from
10+
# outside the install flow. A system process can create this
11+
# file before the server is downloaded and installed.
12+
#
13+
# This check is duplicated between code-server-linux.sh and here
14+
# since remote container calls into this script directly quite early
15+
# before the usual server startup flow.
16+
if [ -f "/tmp/vscode-skip-server-requirements-check" ]; then
17+
echo "!!! WARNING: Skipping server pre-requisite check !!!"
18+
echo "!!! Server stability is not guaranteed. Proceed at your own risk. !!!"
19+
exit 0
20+
fi
21+
822
BITNESS=$(getconf LONG_BIT)
923
ARCH=$(uname -m)
1024
found_required_glibc=0
1125
found_required_glibcxx=0
1226

1327
# Extract the ID value from /etc/os-release
14-
OS_ID="$(cat /etc/os-release | grep -Eo 'ID=([^"]+)' | sed 's/ID=//')"
28+
OS_ID="$(cat /etc/os-release | grep -Eo 'ID=([^"]+)' | sed -n '1s/ID=//p')"
1529
if [ "$OS_ID" = "nixos" ]; then
1630
echo "Warning: NixOS detected, skipping GLIBC check"
1731
exit 0
@@ -64,7 +78,7 @@ if [ -n "$libstdcpp_path" ]; then
6478
fi
6579
fi
6680

67-
if [ -n "$(ldd --version | grep -v musl)" ]; then
81+
if [ -z "$(ldd --version 2>&1 | grep 'musl libc')" ]; then
6882
if [ -f /usr/lib64/libc.so.6 ]; then
6983
# Typical path
7084
libc_path='/usr/lib64/libc.so.6'
@@ -96,7 +110,16 @@ if [ -n "$(ldd --version | grep -v musl)" ]; then
96110
fi
97111
fi
98112
else
99-
echo "Warning: musl detected, skipping GLIBC check"
113+
if [ "$OS_ID" = "alpine" ]; then
114+
musl_version=$(ldd --version 2>&1 | grep "Version" | awk '{print $NF}')
115+
if [ "$(printf '%s\n' "1.2.3" "$musl_version" | sort -V | head -n1)" != "1.2.3" ]; then
116+
echo "Error: Unsupported alpine distribution. Please refer to our supported distro section https://aka.ms/vscode-remote/linux for additional information."
117+
exit 99
118+
fi
119+
else
120+
echo "Warning: musl detected, skipping GLIBC check"
121+
fi
122+
100123
found_required_glibc=1
101124
fi
102125

0 commit comments

Comments
 (0)