@@ -56,37 +56,72 @@ is_target_triple_gnu() {
5656 fi
5757}
5858
59- # checks that the system has atleast glibc 2.34
60- check_glibc_version () {
61- if [ -f /lib64/libc.so.6 ]; then
62- LIBC_PATH=/lib64/libc.so.6
63- elif [ -f /lib/libc.so.6 ]; then
64- LIBC_PATH=/lib/libc.so.6
65- elif [ -f /usr/lib/x86_64-linux-gnu/libc.so.6 ]; then
66- LIBC_PATH=/usr/lib/x86_64-linux-gnu/libc.so.6
59+ # Minimum required glibc version
60+ GLIBC_MIN_MAJOR=2
61+ GLIBC_MIN_MINOR=34
62+
63+ # Check if a glibc version meets the minimum requirement
64+ is_glibc_version_sufficient () {
65+ local version=" $1 "
66+ local major minor
67+
68+ IFS=' .' read -r major minor << EOF
69+ $version
70+ EOF
71+ if [ -z " $minor " ]; then
72+ minor=0
73+ fi
74+
75+ if [ " $major " -gt " $GLIBC_MIN_MAJOR " ] || { [ " $major " -eq " $GLIBC_MIN_MAJOR " ] && [ " $minor " -ge " $GLIBC_MIN_MINOR " ]; }; then
76+ return 0
6777 else
68- log_error " Could not find glibc."
6978 return 1
7079 fi
80+ }
7181
72- glibc_version=$( " $LIBC_PATH " | sed -n ' s/^GNU C Library (.*) stable release version \([0-9]*\)\.\([0-9]*\).*$/\1.\2/p' )
73-
74- if [ -z " $glibc_version " ]; then
75- log_error " Could not determine glibc version."
76- return 1
77- else
78- IFS=' .' read -r major minor << EOF
79- $glibc_version
80- EOF
81- if [ -z " $minor " ]; then
82- minor=0
82+ # checks that the system has at least glibc 2.34
83+ check_glibc_version () {
84+ # Method 1: Original approach - try common libc.so.6 locations
85+ for LIBC_PATH in /lib64/libc.so.6 /lib/libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so.6 \
86+ /lib/aarch64-linux-gnu/libc.so.6; do
87+ if [ -f " $LIBC_PATH " ]; then
88+ glibc_version=$( " $LIBC_PATH " | sed -n ' s/^GNU C Library (.*) stable release version \([0-9]*\)\.\([0-9]*\).*$/\1.\2/p' )
89+ if [ -n " $glibc_version " ]; then
90+ if is_glibc_version_sufficient " $glibc_version " ; then
91+ return 0
92+ else
93+ return 1
94+ fi
95+ fi
8396 fi
84- if [ " $major " -gt 2 ] || { [ " $major " -eq 2 ] && [ " $minor " -ge 34 ]; }; then
85- return 0
86- else
87- return 1
97+ done
98+
99+ # Method 2: Try ldd --version as a more reliable alternative
100+ if command -v ldd > /dev/null 2>&1 ; then
101+ glibc_version=$( ldd --version 2> /dev/null | head -n 1 | grep -o ' [0-9]\+\.[0-9]\+' | head -n 1)
102+ if [ -n " $glibc_version " ]; then
103+ if is_glibc_version_sufficient " $glibc_version " ; then
104+ return 0
105+ else
106+ return 1
107+ fi
88108 fi
89109 fi
110+
111+ # Method 3: Try getconf as a fallback
112+ if command -v getconf > /dev/null 2>&1 ; then
113+ glibc_version=$( getconf GNU_LIBC_VERSION 2> /dev/null | awk ' {print $2}' )
114+ if [ -n " $glibc_version " ]; then
115+ if is_glibc_version_sufficient " $glibc_version " ; then
116+ return 0
117+ else
118+ return 1
119+ fi
120+ fi
121+ fi
122+
123+ log_error " Could not determine glibc version. This CLI requires glibc $GLIBC_MIN_MAJOR .$GLIBC_MIN_MINOR or newer."
124+ return 1
90125}
91126
92127# checks that uname matches the target triple
@@ -96,7 +131,7 @@ if [ "$(uname)" != "$(target_triple_uname)" ]; then
96131fi
97132
98133if is_target_triple_gnu && ! check_glibc_version; then
99- log_error " This release built for a GNU system with glibc 2.34 or newer, try installing the musl version of the CLI."
134+ log_error " This release built for a GNU system with glibc $GLIBC_MIN_MAJOR . $GLIBC_MIN_MINOR or newer, try installing the musl version of the CLI."
100135 exit 1
101136fi
102137
@@ -105,12 +140,12 @@ if [ -n "${Q_INSTALL_GLOBAL:-}" ]; then
105140 install -m 755 " $SCRIPT_DIR /bin/qterm" /usr/local/bin/
106141
107142 /usr/local/bin/q integrations install dotfiles
108- /usr/local/bin/q setup --global
143+ /usr/local/bin/q setup --global " $@ "
109144else
110145 mkdir -p " $HOME /.local/bin"
111146
112147 install -m 755 " $SCRIPT_DIR /bin/q" " $HOME /.local/bin/"
113148 install -m 755 " $SCRIPT_DIR /bin/qterm" " $HOME /.local/bin/"
114149
115- " $HOME /.local/bin/q" setup
150+ " $HOME /.local/bin/q" setup " $@ "
116151fi
0 commit comments