1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#!/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 <http://www.gnu.org/copyleft/gpl.txt>.
# 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
|