3 # kinstall.sh -- install updated kernel PPP driver in Linux kernel source
4 # Michael Callahan callahan@maths.ox.ac.uk 17 May 1995
6 # This script is complicated because we want to avoid installing a driver
7 # in a kernel if it won't work in that kernel. This means two things:
8 # 1) we check the version of the kernel and refuse to install if the
10 # 2) we check that the files already in the kernel aren't more recent
11 # than the one we're about to install.
12 # If either 1) or 2) occurs then we exit with an error message and don't
15 # In addition, we have to edit the Makefile in the drivers/net
16 # directory to add support for the ppp-comp compression option.
18 LINUXSRC
=/usr
/src
/linux
21 echo usage
: $0 [linux-source-directory
]
30 # Make sure we can find the kernel source
32 LINUXMK
=$LINUXSRC/Makefile
34 if [ ! -r $LINUXMK -o ! -d $LINUXSRC/drivers
]; then
35 echo There appears to be no kernel
source distribution
in $LINUXSRC.
36 echo Give the top-level kernel
source directory as the argument to
38 echo usage
: $0 [linux-source-directory
]
43 # Check that the kernel source Makefile includes the
44 # VERSION, PATCHLEVEL, SUBLEVEL version-numbering scheme
46 if [ `egrep '^VERSION|^PATCHLEVEL|^SUBLEVEL' $LINUXMK | wc -l` -ne 3 ]; then
47 echo You appear to have a very old kernel. You must upgrade.
48 echo It is recommended that you upgrade to the most recent
2.0.x kernel.
53 # Set the VERSION, PATCHLEVEL, SUBLEVEL variables
54 VERSION
=`egrep '^VERSION' $LINUXMK | sed 's/[^0-9]//g'`
55 PATCHLEVEL
=`egrep '^PATCHLEVEL' $LINUXMK | sed 's/[^0-9]//g'`
56 SUBLEVEL
=`egrep '^SUBLEVEL' $LINUXMK | sed 's/[^0-9]//g'`
58 KERNEL
=$VERSION.
$PATCHLEVEL.
$SUBLEVEL
61 # Pass judgement on the kernel version
62 if [ $VERSION -lt 2 ]; then
63 echo You appear to be running
$KERNEL. There is no support
for
64 echo kernels predating
2.0.0. It is recommended that you upgrade
65 echo to the most recent
2.0.x kernel.
70 # convenience function to exit if the last command failed
74 if [ $STATUS -ne 0 ]; then
75 echo "=== kinstall.sh exiting with failure status $STATUS"
81 # convenience function to compare two files marked with ==FILEVERSION
82 # version numbers; returns success if $1 is not older than $2
87 pat
='==FILEVERSION[ \t]+[0-9]+[ \t]*=='
89 # Find the revision in the kernel
91 if [ -r $file1 ]; then
92 f1rev
=`egrep "$pat" $file1 | head -1 | sed 's/[^0-9]//g'`
95 # Find the revision of the local file
97 if [ -r $file2 ]; then
98 f2rev
=`egrep "$pat" $file2 | head -1 | sed 's/[^0-9]//g'`
101 # Make the strings the same length to avoid comparison problems
102 f1rev
=`echo "0000000000"$f1rev | tail -c 10`
103 f2rev
=`echo "0000000000"$f2rev | tail -c 10`
105 # Test the order of the two revisions
106 if [ $f1rev -ge $f2rev ]; then
118 if [ ! -e $BASE ]; then
119 if [ -e ..
/include
/linux
/$BASE ]; then
120 BASE
=..
/include
/linux
/$BASE
122 echo Could not
find source file $BASE !
126 if newer
$1 $BASE; then
127 echo $1 is not older than
$BASE, skipping
130 BACKUP
=`echo $1 | sed 's/.c$/.old.c/;s/.h$/.old.h/'`
131 if [ -f $1 -a $BACKUP != $1 ]; then
132 echo Saving old
$1 as
`basename $BACKUP`
136 echo Installing new
$1
144 # Check for the root user
148 if [ $my_uid -ne 0 ]; then
150 echo "********************************************************************"
151 echo "Hello, $my_name. Since you are not running as the root user, it"
152 echo "is possible that this script will fail to install the needed files."
153 echo "If this happens then please use the root account and re-execute the"
154 echo "'make kernel' command. (This script is paused for 10 seconds.)"
155 echo "********************************************************************"
164 echo "Notice to the user:"
166 echo "It is perfectly legal for this script to run without making any changes"
167 echo "to your system. This means that the system currently contains the"
168 echo "necessary changes to support this package. Please do not attempt to"
169 echo "force this script to replace any file nor make any patch. If you do so"
170 echo "then it is probable that you are actually putting older, buggier, code"
171 echo "over the newer, fixed, code. Thank you."
173 echo Installing into kernel version
$KERNEL in $LINUXSRC
176 if [ -f $LINUXSRC/drivers
/net
/ppp.h
]; then
177 echo Moving old
$LINUXSRC/drivers
/net
/ppp.h
file out of the way
178 mv $LINUXSRC/drivers
/net
/ppp.h
$LINUXSRC/drivers
/net
/ppp.old.h
182 for FILE
in $LINUXSRC/drivers
/net
/bsd_comp.c \
183 $LINUXSRC/drivers
/net
/ppp_deflate.c \
184 $LINUXSRC/drivers
/net
/zlib.c \
185 $LINUXSRC/drivers
/net
/zlib.h \
186 $LINUXSRC/include
/linux
/if_ppp.h \
187 $LINUXSRC/include
/linux
/if_pppvar.h \
188 $LINUXSRC/include
/linux
/ppp-comp.h \
189 $LINUXSRC/include
/linux
/ppp_defs.h
194 installfile
$LINUXSRC/drivers
/net
/ppp.c
yes
196 echo -n 'Adding BSD compression module to drivers makefile...'
197 NETMK
=$LINUXSRC/drivers
/net
/Makefile
198 fgrep bsd_comp.o
$NETMK >/dev
/null
199 if [ ! "$?" = "0" ]; then
200 if [ -f $NETMK.orig
]; then
201 mv $NETMK.orig
$NETMK
203 sed 's/ppp.o$/ppp.o bsd_comp.o/g' <$NETMK >$NETMK.temp
206 mv $NETMK $NETMK.orig
209 mv $NETMK.temp
$NETMK
212 echo -n '(already there--skipping)'
215 echo -n 'Adding Deflate compression module to drivers makefile...'
216 NETMK
=$LINUXSRC/drivers
/net
/Makefile
217 fgrep ppp_deflate.o
$NETMK >/dev
/null
218 if [ ! "$?" = "0" ]; then
220 sed 's/bsd_comp.o$/bsd_comp.o ppp_deflate.o/g' <$NETMK >$NETMK.temp
223 mv $NETMK $NETMK.orig
226 mv $NETMK.temp
$NETMK
229 echo -n '(already there--skipping)'
234 # # install header stub files in /usr/include/net
236 # for FILE in if_ppp.h \
242 # if [ ! -f /usr/include/net/$FILE ]; then
243 # echo Installing stub include file in /usr/include/net/$FILE
244 # echo "#include <linux/$FILE>" > /usr/include/net/$FILE
246 # chown 0:0 /usr/include/net/$FILE
248 # chmod 444 /usr/include/net/$FILE
250 # touch /usr/include/net/$FILE
255 echo "Kernel driver files installation done."