X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=linux%2Fkinstall.sh;h=e3858e30ff173ca7a9b4e497e965ba92666f6862;hp=06ea13ba997b12ed922b9f0918658a24dbd3bf68;hb=26a7a28f129d72feaa08ef589e9a49aafd16d984;hpb=0f61ac5460e89dd768f1fb56fbdd8fa6f8af79f1 diff --git a/linux/kinstall.sh b/linux/kinstall.sh index 06ea13b..e3858e3 100755 --- a/linux/kinstall.sh +++ b/linux/kinstall.sh @@ -62,28 +62,33 @@ KERNEL=$VERSION.$PATCHLEVEL.$SUBLEVEL # # Pass judgement on the kernel version -if [ $VERSION -eq 1 ]; then - if [ $PATCHLEVEL -eq 0 -o $PATCHLEVEL -eq 1 -a $SUBLEVEL -lt 14 ]; then +if [ $VERSION -lt 2 ]; then echo You appear to be running $KERNEL. There is no support for - echo kernels predating 1.1.14. It is recommended that you upgrade - echo to the most recent 1.2.X kernel. + echo kernels predating 2.0.0. It is recommended that you upgrade + echo to the most recent 2.0.x kernel. exit 1 - fi - if [ $PATCHLEVEL -eq 1 ]; then - echo You appear to be running $KERNEL. It is recommended that you - echo upgrade to the most recent 1.2.X kernel. - echo However, installation will proceed. - fi fi echo echo Installing into kernel version $KERNEL in $LINUXSRC echo +echo "Notice to the user:" +echo +echo "It is perfectly legal for this script to run without making any changes" +echo "to your system. This only means that the system currently contains the" +echo "necessary changes to support this package. Please do not attempt to" +echo "force this script to replace any file or make any patch. If you do so" +echo "then it is probable that you are actually putting older, buggier, code" +echo "over newer, fixed, code. Thank you." +echo +echo Installing into kernel version $KERNEL in $LINUXSRC +echo + # # convenience function to exit if the last command failed -function bombiffailed () { +bombiffailed () { STATUS=$? if [ $STATUS -ne 0 ]; then echo "=== kinstall.sh exiting with failure status $STATUS" @@ -95,40 +100,39 @@ function bombiffailed () { # convenience function to compare two files marked with ==FILEVERSION # version numbers; returns success if $1 is newer than $2 -function newer () { - if [ -r $1 ] && f1rev=`fgrep "==FILEVERSION " $1 | sed 's/[^0-9]//g'`; then - if [ -r $2 ] && f2rev=`fgrep "==FILEVERSION " $2 | sed 's/[^0-9]//g'`; then - if [ "$f1rev" != "" ]; then - # return true if f2rev is empty or f1rev => f2rev - [ "$f2rev" = "" ] || [ $f1rev -ge $f2rev ] - else - # f1rev is empty, so false - false - fi - else - true # no FILEVERSION in $2, so $1 is newer - fi - else - false # no FILEVERSION in $1, so not newer +newer () { + file1=$1 + file2=$2 + pat='==FILEVERSION[ \t]+[0-9]+[ \t]*==' + + # Find the revision in the kernel + f1rev="" + if [ -r $file1 ]; then + f1rev=`egrep "$pat" $file1 | head -1 | sed 's/[^0-9]//g'` fi -} -# -# Change the USE_SKB_PROTOCOL for correct operation on 1.3.x -function update_ppp () { - mv $LINUXSRC/drivers/net/ppp.c $LINUXSRC/drivers/net/ppp.c.in - if [ "$VERSION.$PATCHLEVEL" = "1.3" ]; then - sed 's/#define USE_SKB_PROTOCOL 0/#define USE_SKB_PROTOCOL 1/' <$LINUXSRC/drivers/net/ppp.c.in >$LINUXSRC/drivers/net/ppp.c - else - sed 's/#define USE_SKB_PROTOCOL 1/#define USE_SKB_PROTOCOL 0/' <$LINUXSRC/drivers/net/ppp.c.in >$LINUXSRC/drivers/net/ppp.c + # Find the revision of the local file + f2rev="" + if [ -r $file2 ]; then + f2rev=`egrep "$pat" $file2 | head -1 | sed 's/[^0-9]//g'` fi - rm $LINUXSRC/drivers/net/ppp.c.in + + # Make the strings the same length to avoid comparison problems + f1rev=`echo "0000000000"$f1rev | tail -c 10` + f2rev=`echo "0000000000"$f2rev | tail -c 10` + + # Test the order of the two revisions + if [ $f1rev -ge $f2rev ]; then + true ; return + fi + + false ; return } # # Install the files. -function installfile () { +installfile () { BASE=`basename $1` if newer $1 $BASE; then echo $1 is newer than $BASE, skipping @@ -145,11 +149,69 @@ function installfile () { bombiffailed touch $1 bombiffailed - if [ "$2" = "yes" ]; then - update_ppp +} + +# +# Patch the bad copies of the sys/types.h file +# +patch_include () { + echo -n "Ensuring that sys/types.h includes sys/bitypes.h" + fgrep "" /usr/include/sys/types.h >/dev/null + if [ ! "$?" = "0" ]; then + echo -n '.' + rm -f /usr/include/sys/types.h.rej + (cd /usr/include/sys; patch -p0 -f -F30 -s) after it includes the file." + echo -n "Please change it so that it does." + rm -f /usr/include/sys/types.h.rej + else + echo -n " -- completed" + fi + else + echo -n " -- skipping" fi + echo "" } +# +# Check for the root user +test_root() { + my_uid=`id -u` + my_name=`id -u -n` + if [ $my_uid -ne 0 ]; then + echo + echo "********************************************************************" + echo "Hello, $my_name. Since you are not running as the root user, it" + echo "is possible that this script will fail to install the needed files." + echo "If this happens then please use the root account and re-execute the" + echo "'make kernel' command. (This script is paused for 10 seconds.)" + echo "********************************************************************" + echo + sleep 10s + fi +} + +test_root + +echo +echo "Notice to the user:" +echo +echo "It is perfectly legal for this script to run without making any changes" +echo "to your system. This means that the system currently contains the" +echo "necessary changes to support this package. Please do not attempt to" +echo "force this script to replace any file nor make any patch. If you do so" +echo "then it is probable that you are actually putting older, buggier, code" +echo "over the newer, fixed, code. Thank you." +echo +echo Installing into kernel version $KERNEL in $LINUXSRC +echo + if [ -f $LINUXSRC/drivers/net/ppp.h ]; then echo Moving old $LINUXSRC/drivers/net/ppp.h file out of the way mv $LINUXSRC/drivers/net/ppp.h $LINUXSRC/drivers/net/ppp.old.h @@ -157,6 +219,9 @@ if [ -f $LINUXSRC/drivers/net/ppp.h ]; then fi for FILE in $LINUXSRC/drivers/net/bsd_comp.c \ + $LINUXSRC/drivers/net/ppp_deflate.c \ + $LINUXSRC/drivers/net/zlib.c \ + $LINUXSRC/drivers/net/zlib.h \ $LINUXSRC/include/linux/if_ppp.h \ $LINUXSRC/include/linux/if_pppvar.h \ $LINUXSRC/include/linux/ppp-comp.h \ @@ -182,42 +247,34 @@ echo -n 'Adding BSD compression module to drivers makefile...' NETMK=$LINUXSRC/drivers/net/Makefile fgrep bsd_comp.o $NETMK >/dev/null if [ ! "$?" = "0" ]; then - echo -n '.' - rm -f $NETMK.orig $NETMK.rej - if [ "$VERSION.$PATCHLEVEL" = "1.2" ]; then - (cd $LINUXSRC; patch -p1 -f -F30 -s) $NETMK.temp - bombiffailed - echo -n '.' - mv $NETMK $NETMK.orig - bombiffailed - echo -n '.' - mv $NETMK.temp $NETMK - bombiffailed - fi -# - if [ -e $NETMK.orig ]; then - mv $NETMK.orig $NETMK.old + if [ -f $NETMK.orig ]; then + mv $NETMK.orig $NETMK fi + sed 's/ppp.o$/ppp.o bsd_comp.o/g' <$NETMK >$NETMK.temp + bombiffailed + echo -n '.' + mv $NETMK $NETMK.orig + bombiffailed + echo -n '.' + mv $NETMK.temp $NETMK + bombiffailed +else + echo -n '(already there--skipping)' +fi +echo +echo -n 'Adding Deflate compression module to drivers makefile...' +NETMK=$LINUXSRC/drivers/net/Makefile +fgrep ppp_deflate.o $NETMK >/dev/null +if [ ! "$?" = "0" ]; then + echo -n '.' + sed 's/bsd_comp.o$/bsd_comp.o ppp_deflate.o/g' <$NETMK >$NETMK.temp + bombiffailed + echo -n '.' + mv $NETMK $NETMK.orig + bombiffailed + echo -n '.' + mv $NETMK.temp $NETMK + bombiffailed else echo -n '(already there--skipping)' fi @@ -266,5 +323,8 @@ for FILE in ip.h \ fi done +patch_include + echo "Kernel driver files installation done." + exit 0