Checking versions of required programs

Pavel Machek (pavel@atrey.karlin.mff.cuni.cz)
Sat, 10 May 1997 17:56:31 +0200


Hi!

Some time ago, I had problems with my compile tools being too
old. Then I decided to check ALL programs on my systems (according to
Documentation/Changes), and found it to be pretty hard to check. So I
created simple script to do that task. What about placing this instead
of (or in addition to) Documentation/Changes?

Pavel

[recommended place is /usr/src/linux/scripts/chver]

#!/bin/bash
#
# This script was created by Pavel Machek <machek@atrey.karlin.mff.cuni.cz>
# to check versions of critical pieces of software (mostly for compatibility
# with new and new kernel versions). I decided to write this after I hunted
# bug in linux memory managment, which was not there. It was too old linker
# causing problems.
#
# I would like someone with rpm installed to replace line "INCOMPLETE" with
# something more suitable.
#
# I would like linus to include this to kernel distribution ;-)
#
# Imagine how nice & simple this program could be if every other program
# responded to <name> --version with exactly one line containing version
# in form AA.BB.CC... The dirtiest piece here is getting version out of
# sysvinit...
#

function getnum
{
head -1 | sed 's/.*[^0-9.]\([0-9][0-9]*\.[0-9][0-9.]*\)[^0-9.].*/\1/g'
}

function cmp
{
echo -n $1 " "
VER=start`eval $2`end
VER=`echo $VER | getnum`
T1=${VER}.
T2=${3}.
echo -n "... "
# echo "($T1), ($T2)"
while [ "x$T1" != "x" -a "x$T2" != "x" ]
do
H1=${T1%%.*}
H2=${T2%%.*}
T1=${T1#*.}
T2=${T2#*.}
if [ $H1 -gt $H2 ]; then echo ok.; return; fi
if [ $H1 -lt $H2 ]; then echo "OLD: $VER present, $3 required"; return; fi
done
echo ok.
}

echo Checking versions of some utilities...
cmp gcc 'gcc --version' 2.7.2.1
cmp binutils "ld --version" 2.7.0.9
cmp libc 'ls -l /lib/libc.so.* | sed s/.*libc.so.// | sort -r | head -1' 5.4.23
if [ -e /usr/lib/libg++.so ]
then
cmp libc++ 'ls -l /usr/lib/libg++.so.* | sed s/.*libg++.so.// | sort -r | head -1' 2.7.2.1
else
echo libc++ - not present here
fi
cmp 'dynamic linker' "ldd -v | getnum" 1.8.5
cmp procps "ps --version | getnum" 1.01
if [ "$USER" = root ]
then
cmp sysvinit 'strings `egrep -li INIT_VERSION=sysvinit- /proc/*/environ | head -1` | egrep -i INIT_VERSION=sysvinit-' 2.69
else
echo "sysvinit - must be root"
fi
cmp mount 'mount --version 2>&1' 2.6
cmp loadkeys 'loadkeys -h 2>&1' 0.91
# insmod version probably set incorrectly
cmp "modules" "/sbin/insmod -V 2>&1 | grep Version" 2.1.34
if which rpm > /dev/null
then
echo "INCOMPLETE: Please fill in this space, I do not have rpm installed."
else
echo rpm - not present here
fi

--
I'm really pavel@atrey.karlin.mff.cuni.cz. 	   Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel ;-).