@@ -19,23 +19,25 @@ if [ -f "/tmp/vscode-skip-server-requirements-check" ]; then
1919 exit 0
2020fi
2121
22- BITNESS=$( getconf LONG_BIT)
2322ARCH=$( uname -m)
2423found_required_glibc=0
2524found_required_glibcxx=0
2625
2726# Extract the ID value from /etc/os-release
28- OS_ID=" $( cat /etc/os-release | grep -Eo ' ID=([^"]+)' | sed -n ' 1s/ID=//p' ) "
29- if [ " $OS_ID " = " nixos" ]; then
30- echo " Warning: NixOS detected, skipping GLIBC check"
31- exit 0
27+ if [ -f /etc/os-release ]; then
28+ OS_ID=" $( cat /etc/os-release | grep -Eo ' ID=([^"]+)' | sed -n ' 1s/ID=//p' ) "
29+ if [ " $OS_ID " = " nixos" ]; then
30+ echo " Warning: NixOS detected, skipping GLIBC check"
31+ exit 0
32+ fi
3233fi
3334
3435# Based on https://github.com/bminor/glibc/blob/520b1df08de68a3de328b65a25b86300a7ddf512/elf/cache.c#L162-L245
3536case $ARCH in
3637 x86_64) LDCONFIG_ARCH=" x86-64" ;;
3738 armv7l | armv8l) LDCONFIG_ARCH=" hard-float" ;;
3839 arm64 | aarch64)
40+ BITNESS=$( getconf LONG_BIT)
3941 if [ " $BITNESS " = " 32" ]; then
4042 # Can have 32-bit userland on 64-bit kernel
4143 LDCONFIG_ARCH=" hard-float"
@@ -45,23 +47,29 @@ case $ARCH in
4547 ;;
4648esac
4749
48- if [ -f /usr/lib64/libstdc++.so.6 ]; then
49- # Typical path
50- libstdcpp_path=' /usr/lib64/libstdc++.so.6'
51- elif [ -f /usr/lib/libstdc++.so.6 ]; then
52- # Typical path
53- libstdcpp_path=' /usr/lib/libstdc++.so.6'
54- elif [ -f /sbin/ldconfig ]; then
55- # Look up path
56- libstdcpp_paths=$( /sbin/ldconfig -p | grep ' libstdc++.so.6' )
50+ if [ " $OS_ID " != " alpine" ]; then
51+ if [ -f /sbin/ldconfig ]; then
52+ # Look up path
53+ libstdcpp_paths=$( /sbin/ldconfig -p | grep ' libstdc++.so.6' )
54+
55+ if [ " $( echo " $libstdcpp_paths " | wc -l) " -gt 1 ]; then
56+ libstdcpp_path=$( echo " $libstdcpp_paths " | grep " $LDCONFIG_ARCH " | awk ' {print $NF}' | head -n1)
57+ else
58+ libstdcpp_path=$( echo " $libstdcpp_paths " | awk ' {print $NF}' )
59+ fi
60+ fi
61+ fi
5762
58- if [ " $( echo " $libstdcpp_paths " | wc -l) " -gt 1 ]; then
59- libstdcpp_path=$( echo " $libstdcpp_paths " | grep " $LDCONFIG_ARCH " | awk ' {print $NF}' | head -n1)
63+ if [ -z " $libstdcpp_path " ]; then
64+ if [ -f /usr/lib/libstdc++.so.6 ]; then
65+ # Typical path
66+ libstdcpp_path=' /usr/lib/libstdc++.so.6'
67+ elif [ -f /usr/lib64/libstdc++.so.6 ]; then
68+ # Typical path
69+ libstdcpp_path=' /usr/lib64/libstdc++.so.6'
6070 else
61- libstdcpp_path= $( echo " $libstdcpp_paths " | awk ' {print $NF} ' )
71+ echo " Warning: Can't find libstdc++.so or ldconfig, can't verify libstdc++ version "
6272 fi
63- else
64- echo " Warning: Can't find libstdc++.so or ldconfig, can't verify libstdc++ version"
6573fi
6674
6775if [ -n " $libstdcpp_path " ]; then
@@ -78,14 +86,21 @@ if [ -n "$libstdcpp_path" ]; then
7886 fi
7987fi
8088
81- if [ -z " $( ldd --version 2>&1 | grep ' musl libc' ) " ]; then
82- if [ -f /usr/lib64/libc.so.6 ]; then
83- # Typical path
84- libc_path=' /usr/lib64/libc.so.6'
85- elif [ -f /usr/lib/libc.so.6 ]; then
86- # Typical path
87- libc_path=' /usr/lib/libc.so.6'
88- elif [ -f /sbin/ldconfig ]; then
89+ if [ " $OS_ID " = " alpine" ]; then
90+ MUSL_RTLDLIST=" /lib/ld-musl-aarch64.so.1 /lib/ld-musl-x86_64.so.1"
91+ for rtld in ${MUSL_RTLDLIST} ; do
92+ if [ -x $rtld ]; then
93+ musl_version=$( " $rtld " --version 2>&1 | grep " Version" | awk ' {print $NF}' )
94+ break
95+ fi
96+ done
97+ if [ " $( printf ' %s\n' " 1.2.3" " $musl_version " | sort -V | head -n1) " != " 1.2.3" ]; then
98+ echo " Error: Unsupported alpine distribution. Please refer to our supported distro section https://aka.ms/vscode-remote/linux for additional information."
99+ exit 99
100+ fi
101+ found_required_glibc=1
102+ elif [ -z " $( ldd --version 2>&1 | grep ' musl libc' ) " ]; then
103+ if [ -f /sbin/ldconfig ]; then
89104 # Look up path
90105 libc_paths=$( /sbin/ldconfig -p | grep ' libc.so.6' )
91106
@@ -94,6 +109,12 @@ if [ -z "$(ldd --version 2>&1 | grep 'musl libc')" ]; then
94109 else
95110 libc_path=$( echo " $libc_paths " | awk ' {print $NF}' )
96111 fi
112+ elif [ -f /usr/lib/libc.so.6 ]; then
113+ # Typical path
114+ libc_path=' /usr/lib/libc.so.6'
115+ elif [ -f /usr/lib64/libc.so.6 ]; then
116+ # Typical path
117+ libc_path=' /usr/lib64/libc.so.6'
97118 else
98119 echo " Warning: Can't find libc.so or ldconfig, can't verify libc version"
99120 fi
@@ -110,16 +131,7 @@ if [ -z "$(ldd --version 2>&1 | grep 'musl libc')" ]; then
110131 fi
111132 fi
112133else
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-
134+ echo " Warning: musl detected, skipping GLIBC check"
123135 found_required_glibc=1
124136fi
125137
0 commit comments