#!/bin/sh # GNU C library version detection shell script. # Copyright 1999 Branden Robinson. # Licensed under the GNU General Public License, version 2. See the file # /usr/share/common-licenses/GPL or . # This script probably makes about a billion too many assumptions, but it's # better than hardcoding the glibc version on a per-architecture basis. set -e usage () { echo "Usage: getglibcversion [option]" echo " Where [option] may be one of:" echo " --major return major version only" echo " --minor return minor version only" echo " --point return ittybitty version only" echo "With no option, returns major.minor.ittybitty ."; } case $# in 0) ;; 1) case $1 in --help) usage exit 0 ;; --major) RETURN=1 ;; --minor) RETURN=2 ;; --point) RETURN=3 ;; *) exec 1>&2 usage exit 1 ;; esac ;; *) exec 1>&2 usage exit 1 ;; esac LIBCLIST=$(cd /lib && ls libc-*.so) case $(echo $LIBCLIST | wc -l | awk '{print $1}') in 0) echo "No GNU C library found! Aborting." >&2 exit 1 ;; 1) ;; *) echo "Multiple versions of GNU C library found! Aborting." >&2 exit 1 ;; esac LIBCVERSION=$(echo $LIBCLIST | sed 's/libc-//;s/\.so//') if [ -z $RETURN ]; then echo $LIBCVERSION else echo $LIBCVERSION | cut -d. -f$RETURN fi exit 0