From 40cd44a45f13733c8acc09f050c53c04e940c19c Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 14 Dec 2020 16:49:52 -0600 Subject: [PATCH 1/2] cmd/vendor-install.sh: fail for old Glibc --- Library/Homebrew/cmd/vendor-install.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index 42e1b69d29..df2783810e 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -32,6 +32,24 @@ then esac fi +if [[ -n "$HOMEBREW_LINUX" ]] +then + LDD_VERSION_OUTPUT=$(/usr/bin/ldd --version) + if [[ $LDD_VERSION_OUTPUT =~ \ [0-9]\.[0-9]+ ]] + then + LDD_VERSION=${BASH_REMATCH[0]} + LDD_VERSION_MAJOR=${LDD_VERSION%.*} + LDD_VERSION_MINOR=${LDD_VERSION#*.} + if (( LDD_VERSION_MAJOR < 2 || LDD_VERSION_MINOR < 13 )) + then + odie "Vendored tools require system Glibc 2.13 or later" + fi + else + odie "Failed to detect system Glibc version" + fi + unset LDD_VERSION_OUTPUT LDD_VERSION LDD_VERSION_MAJOR LDD_VERSION_MINOR +fi + # Execute the specified command, and suppress stderr unless HOMEBREW_STDERR is set. quiet_stderr() { if [[ -z "$HOMEBREW_STDERR" ]]; then From e6c08bd9a59d9e2b47341e939561a6d84d8f4c12 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Tue, 15 Dec 2020 06:43:11 -0600 Subject: [PATCH 2/2] vendor-install: wrap ldd-checking code in a function and call it in `homebrew-vendor-install()` on Linux. --- Library/Homebrew/cmd/vendor-install.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index df2783810e..18e98e51a1 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -32,23 +32,24 @@ then esac fi -if [[ -n "$HOMEBREW_LINUX" ]] -then - LDD_VERSION_OUTPUT=$(/usr/bin/ldd --version) - if [[ $LDD_VERSION_OUTPUT =~ \ [0-9]\.[0-9]+ ]] +check_ldd_version() { + local ldd_version + local ldd_version_major + local ldd_version_minor + + if [[ $(/usr/bin/ldd --version) =~ \ [0-9]\.[0-9]+ ]] then - LDD_VERSION=${BASH_REMATCH[0]} - LDD_VERSION_MAJOR=${LDD_VERSION%.*} - LDD_VERSION_MINOR=${LDD_VERSION#*.} - if (( LDD_VERSION_MAJOR < 2 || LDD_VERSION_MINOR < 13 )) + ldd_version=${BASH_REMATCH[0]// /} + ldd_version_major=${ldd_version%.*} + ldd_version_minor=${ldd_version#*.} + if (( ldd_version_major < 2 || ldd_version_minor < 13 )) then - odie "Vendored tools require system Glibc 2.13 or later" + odie "Vendored tools require system Glibc 2.13 or later." fi else - odie "Failed to detect system Glibc version" + odie "Failed to detect system Glibc version." fi - unset LDD_VERSION_OUTPUT LDD_VERSION LDD_VERSION_MAJOR LDD_VERSION_MINOR -fi +} # Execute the specified command, and suppress stderr unless HOMEBREW_STDERR is set. quiet_stderr() { @@ -238,6 +239,7 @@ homebrew-vendor-install() { [[ -z "$VENDOR_NAME" ]] && odie "This command requires a vendor target!" [[ -n "$HOMEBREW_DEBUG" ]] && set -x + [[ -n "$HOMEBREW_LINUX" ]] && check_ldd_version url_var="${VENDOR_NAME}_URL" url2_var="${VENDOR_NAME}_URL2"