Incorrect kernels & unpatching kernel

Pavel Machek (pavel@atrey.karlin.mff.cuni.cz)
Wed, 28 May 1997 22:24:07 +0200


Hi!

1st:

I noticed that unpatching kernel is pretty hard thing to do. Due to
strange behaviour of patch (which sometimes abort in the middle if you
give bad answer to Apply anyway?), it is pretty needed. Well, it is
not hard any more!

Put this to scripts/unpatch-kernel

#!/bin/bash
find . -name "*.orig" -exec sh -c 'mv {} `echo {} | sed s/\.orig//`' \;

2nd:

Building incorrect kernels is a pretty bad thing, and it just
sometimes happens with old gcc | old binutils. Also, checking versions
of required programs is pretty hard to do as Documentation/Changes.txt
contains info spread all around it. I would like to see this in
kernel: [btw to whom should I send such things?]

put this into scripts/chkver

#!/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 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";
if [ .$HALT = .y ]; then
echo "***"
echo "*** Using old gcc and/or old binutils, you can build"
echo "*** nicely looking, partly-running kernels crashing"
echo "*** after 30minutes after boot (happend to me)."
echo "***"
exit 1
fi
fi
done
echo ok.
}

echo Checking versions of some utilities...
if [ ".$1" = ".s" ]; then HALT=y; fi
cmp gcc 'gcc --version' 2.7.2
cmp binutils "ld --version" 2.7.0.9
if [ ".$1" != ".s" ]
then
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
cmp "modules" "/sbin/insmod -V 2>&1 | grep -i version" 2.1.34
fi
# New Changes no longer mention rpm
#if which rpm > /dev/null
# then
# cmp "rpm" 'rpm --version | getnum'
# else
# echo rpm - not present here
# fi

And apply this to the top Makefile:

--- clean/Makefile Wed May 28 22:11:31 1997
+++ linux/Makefile Wed May 28 22:01:53 1997
@@ -213,6 +221,9 @@
$(TOPDIR)/include/linux/version.h: include/linux/version.h
$(TOPDIR)/include/linux/compile.h: include/linux/compile.h

+ksymoops:
+ $(MAKE) -C scripts ksymoops
+
newversion:
@if [ ! -f .version ]; then \
echo 1 > .version; \
@@ -221,6 +232,7 @@
fi

include/linux/compile.h: $(CONFIGURATION) include/linux/version.h newversion
+ scripts/chkver s
@if [ -f .name ]; then \
echo \#define UTS_VERSION \"\#`cat .version`-`cat .name` `date`\"; \
else \

Pavel

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