From bfd4fb9ca14e1a892ad5042a84779a054aee510e Mon Sep 17 00:00:00 2001 From: Yifei Yang Date: Thu, 8 Feb 2024 00:23:36 +0800 Subject: [PATCH 1/6] Fix: Fixed glibc version detection bug in check-requirements-linux.sh - Existing detection scripts simply use the `awk` command to record the version number in the `libstdc++.so` filename, - but in some specific versions of glibc++, the detailed version number is not indicated in the filename, - so we need to use a script to read the current version of GLIBCXX in the environment to see if it meets the expectations. Co-authored-by: chengy-sysu <939416532@qq.com> --- .../server/bin/helpers/check-requirements-linux.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/resources/server/bin/helpers/check-requirements-linux.sh b/resources/server/bin/helpers/check-requirements-linux.sh index 1b9199fd03930..429a730200332 100644 --- a/resources/server/bin/helpers/check-requirements-linux.sh +++ b/resources/server/bin/helpers/check-requirements-linux.sh @@ -65,13 +65,14 @@ else fi if [ -n "$libstdcpp_path" ]; then - # Extracts the version number from the path, e.g. libstdc++.so.6.0.22 -> 6.0.22 - # which is then compared based on the fact that release versioning and symbol versioning - # are aligned for libstdc++. Refs https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html - # (i-e) GLIBCXX_3.4. is provided by libstdc++.so.6.y. + # Extracts the version number from the path, e.g. libstdc++.so.6.0.22 -> 6.0.22 + # which is then compared based on the fact that release versioning and symbol versioning + # are aligned for libstdc++. Refs https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html + # (i-e) GLIBCXX_3.4. is provided by libstdc++.so.6.y. libstdcpp_real_path=$(readlink -f "$libstdcpp_path") - libstdcpp_version=$(echo "$libstdcpp_real_path" | awk -F'\\.so\\.' '{print $NF}') - if [ "$(printf '%s\n' "6.0.25" "$libstdcpp_version" | sort -V | head -n1)" = "6.0.25" ]; then + libstdcpp_version=$(strings "$libstdcpp_real_path" | grep -o 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' | sort -V | tail -1) + libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') + if [ "$(printf '%s\n' "3.4.25" "$libstdcpp_version_number" | sort -V | head -n1)" = "3.4.25" ]; then found_required_glibcxx=1 else echo "Warning: Missing GLIBCXX >= 3.4.25! from $libstdcpp_real_path" From d6850cef0122a6dfad3cf66a55bb9299d9476827 Mon Sep 17 00:00:00 2001 From: Yifei Yang Date: Thu, 8 Feb 2024 00:43:06 +0800 Subject: [PATCH 2/6] Update check-requirements-linux.sh fix Indent --- resources/server/bin/helpers/check-requirements-linux.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/server/bin/helpers/check-requirements-linux.sh b/resources/server/bin/helpers/check-requirements-linux.sh index 429a730200332..10a575653a97f 100644 --- a/resources/server/bin/helpers/check-requirements-linux.sh +++ b/resources/server/bin/helpers/check-requirements-linux.sh @@ -65,10 +65,10 @@ else fi if [ -n "$libstdcpp_path" ]; then - # Extracts the version number from the path, e.g. libstdc++.so.6.0.22 -> 6.0.22 - # which is then compared based on the fact that release versioning and symbol versioning - # are aligned for libstdc++. Refs https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html - # (i-e) GLIBCXX_3.4. is provided by libstdc++.so.6.y. +# Extracts the version number from the path, e.g. libstdc++.so.6.0.22 -> 6.0.22 +# which is then compared based on the fact that release versioning and symbol versioning +# are aligned for libstdc++. Refs https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html +# (i-e) GLIBCXX_3.4. is provided by libstdc++.so.6.y. libstdcpp_real_path=$(readlink -f "$libstdcpp_path") libstdcpp_version=$(strings "$libstdcpp_real_path" | grep -o 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' | sort -V | tail -1) libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') From 297634d0d8e197d771b6f4474477fe44e7d37641 Mon Sep 17 00:00:00 2001 From: Yifei Yang Date: Thu, 8 Feb 2024 13:52:10 +0800 Subject: [PATCH 3/6] fix: Using grep and sed to replace strings command Since some Linux distributions do not come with GNU binutils pre-installed, the `strings` command does not fit on all platforms, so we use `grep` and `sed` instead of `strings`. Co-authored-by: chengy-sysu <939416532@qq.com> --- resources/server/bin/helpers/check-requirements-linux.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/resources/server/bin/helpers/check-requirements-linux.sh b/resources/server/bin/helpers/check-requirements-linux.sh index 10a575653a97f..16c608018fcaa 100644 --- a/resources/server/bin/helpers/check-requirements-linux.sh +++ b/resources/server/bin/helpers/check-requirements-linux.sh @@ -65,10 +65,6 @@ else fi if [ -n "$libstdcpp_path" ]; then -# Extracts the version number from the path, e.g. libstdc++.so.6.0.22 -> 6.0.22 -# which is then compared based on the fact that release versioning and symbol versioning -# are aligned for libstdc++. Refs https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html -# (i-e) GLIBCXX_3.4. is provided by libstdc++.so.6.y. libstdcpp_real_path=$(readlink -f "$libstdcpp_path") libstdcpp_version=$(strings "$libstdcpp_real_path" | grep -o 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' | sort -V | tail -1) libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') From 0adf8752890dd96b258ee24c4c810e5e9759a6da Mon Sep 17 00:00:00 2001 From: Yifei Yang Date: Thu, 8 Feb 2024 14:03:49 +0800 Subject: [PATCH 4/6] fix: boundary case of check-requirements-linux.sh Co-authored-by: chengy-sysu <939416532@qq.com> --- resources/server/bin/helpers/check-requirements-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/server/bin/helpers/check-requirements-linux.sh b/resources/server/bin/helpers/check-requirements-linux.sh index 16c608018fcaa..0d9543ab381b4 100644 --- a/resources/server/bin/helpers/check-requirements-linux.sh +++ b/resources/server/bin/helpers/check-requirements-linux.sh @@ -68,7 +68,7 @@ if [ -n "$libstdcpp_path" ]; then libstdcpp_real_path=$(readlink -f "$libstdcpp_path") libstdcpp_version=$(strings "$libstdcpp_real_path" | grep -o 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' | sort -V | tail -1) libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') - if [ "$(printf '%s\n' "3.4.25" "$libstdcpp_version_number" | sort -V | head -n1)" = "3.4.25" ]; then + if [ "$(printf '%s\n' "3.4.24" "$libstdcpp_version_number" | sort -V | head -n1)" = "3.4.24" ]; then found_required_glibcxx=1 else echo "Warning: Missing GLIBCXX >= 3.4.25! from $libstdcpp_real_path" From 53c85aff488e6240e2d39a4b4d45091d4948d2db Mon Sep 17 00:00:00 2001 From: Yifei Yang Date: Thu, 8 Feb 2024 16:31:50 +0800 Subject: [PATCH 5/6] fix: Using grep and sed to replace strings command Since some Linux distributions do not come with GNU binutils pre-installed, the `strings` command does not fit on all platforms, so we use `grep` and `sed` instead of `strings`. Co-authored-by: chengy-sysu <939416532@qq.com> --- resources/server/bin/helpers/check-requirements-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/server/bin/helpers/check-requirements-linux.sh b/resources/server/bin/helpers/check-requirements-linux.sh index 0d9543ab381b4..a4a6bbaedb80c 100644 --- a/resources/server/bin/helpers/check-requirements-linux.sh +++ b/resources/server/bin/helpers/check-requirements-linux.sh @@ -66,7 +66,7 @@ fi if [ -n "$libstdcpp_path" ]; then libstdcpp_real_path=$(readlink -f "$libstdcpp_path") - libstdcpp_version=$(strings "$libstdcpp_real_path" | grep -o 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' | sort -V | tail -1) + libstdcpp_version=$(grep -ao 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' "$libstdcpp_real_path" | sort -V | tail -1) libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') if [ "$(printf '%s\n' "3.4.24" "$libstdcpp_version_number" | sort -V | head -n1)" = "3.4.24" ]; then found_required_glibcxx=1 From 843fcb0bf22bba85192a11b1bd9851d837e92d48 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 8 Feb 2024 19:51:15 +0900 Subject: [PATCH 6/6] fix: skip glibcxx check on alpine --- .../bin/helpers/check-requirements-linux.sh | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/resources/server/bin/helpers/check-requirements-linux.sh b/resources/server/bin/helpers/check-requirements-linux.sh index 849ce6fae6ff4..be5207c2f0517 100644 --- a/resources/server/bin/helpers/check-requirements-linux.sh +++ b/resources/server/bin/helpers/check-requirements-linux.sh @@ -57,11 +57,7 @@ if [ "$OS_ID" != "alpine" ]; then else libstdcpp_path=$(echo "$libstdcpp_paths" | awk '{print $NF}') fi - fi -fi - -if [ -z "$libstdcpp_path" ]; then - if [ -f /usr/lib/libstdc++.so.6 ]; then + elif [ -f /usr/lib/libstdc++.so.6 ]; then # Typical path libstdcpp_path='/usr/lib/libstdc++.so.6' elif [ -f /usr/lib64/libstdc++.so.6 ]; then @@ -70,19 +66,26 @@ if [ -z "$libstdcpp_path" ]; then else echo "Warning: Can't find libstdc++.so or ldconfig, can't verify libstdc++ version" fi -fi -while [ -n "$libstdcpp_path" ]; do - libstdcpp_path_line=$(echo "$libstdcpp_path" | head -n1) - libstdcpp_real_path=$(readlink -f "$libstdcpp_path_line") - libstdcpp_version=$(grep -ao 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' "$libstdcpp_real_path" | sort -V | tail -1) - libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') - if [ "$(printf '%s\n' "3.4.24" "$libstdcpp_version_number" | sort -V | head -n1)" = "3.4.24" ]; then - found_required_glibcxx=1 - break - fi - libstdcpp_path=$(echo "$libstdcpp_path" | tail -n +2) # remove first line -done + while [ -n "$libstdcpp_path" ]; do + # Extracts the version number from the path, e.g. libstdc++.so.6.0.22 -> 6.0.22 + # which is then compared based on the fact that release versioning and symbol versioning + # are aligned for libstdc++. Refs https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html + # (i-e) GLIBCXX_3.4. is provided by libstdc++.so.6.y. + libstdcpp_path_line=$(echo "$libstdcpp_path" | head -n1) + libstdcpp_real_path=$(readlink -f "$libstdcpp_path_line") + libstdcpp_version=$(grep -ao 'GLIBCXX_[0-9]*\.[0-9]*\.[0-9]*' "$libstdcpp_real_path" | sort -V | tail -1) + libstdcpp_version_number=$(echo "$libstdcpp_version" | sed 's/GLIBCXX_//') + if [ "$(printf '%s\n' "3.4.24" "$libstdcpp_version_number" | sort -V | head -n1)" = "3.4.24" ]; then + found_required_glibcxx=1 + break + fi + libstdcpp_path=$(echo "$libstdcpp_path" | tail -n +2) # remove first line + done +else + echo "Warning: alpine distro detected, skipping GLIBCXX check" + found_required_glibcxx=1 +fi if [ "$found_required_glibcxx" = "0" ]; then echo "Warning: Missing GLIBCXX >= 3.4.25! from $libstdcpp_real_path" fi