X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=linux%2Fkinstall.sh;h=efb242087db5b54569bc8665f12408578e6c6a6f;hp=06ea13ba997b12ed922b9f0918658a24dbd3bf68;hb=f82d2043bd8c28fc9cc88916920aac4856651978;hpb=0f61ac5460e89dd768f1fb56fbdd8fa6f8af79f1 diff --git a/linux/kinstall.sh b/linux/kinstall.sh index 06ea13b..efb2420 100755 --- a/linux/kinstall.sh +++ b/linux/kinstall.sh @@ -14,9 +14,6 @@ # # In addition, we have to edit the Makefile in the drivers/net # directory to add support for the ppp-comp compression option. -# -# Finally, we have to check that certain include file stubs in -# /usr/include/net exist, or else pppd won't compile. Phew! LINUXSRC=/usr/src/linux @@ -48,7 +45,7 @@ fi # introduced in 1.0.1 if [ `egrep '^VERSION|^PATCHLEVEL|^SUBLEVEL' $LINUXMK | wc -l` -ne 3 ]; then echo You appear to have a very old kernel. You must upgrade. - echo It is recommended that you upgrade to the most recent 1.2.X kernel. + echo It is recommended that you upgrade to the most recent 2.0.x kernel. exit 1 fi @@ -62,28 +59,17 @@ 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 - # # 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" @@ -93,45 +79,44 @@ 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 +# version numbers; returns success if $1 is not older than $2 + +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 + + # 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 - rm $LINUXSRC/drivers/net/ppp.c.in + + false ; return } # # Install the files. -function installfile () { +installfile () { BASE=`basename $1` if newer $1 $BASE; then - echo $1 is newer than $BASE, skipping + echo $1 is not older than $BASE, skipping return 0 fi BACKUP=`echo $1 | sed 's/.c$/.old.c/;s/.h$/.old.h/'` @@ -145,11 +130,41 @@ function installfile () { bombiffailed touch $1 bombiffailed - if [ "$2" = "yes" ]; then - update_ppp +} + +# +# 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 +172,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 \ @@ -167,104 +185,65 @@ done installfile $LINUXSRC/drivers/net/ppp.c yes -for FILE in if.h if_arp.h route.h - do - if [ ! -f $LINUXSRC/include/linux/$FILE ]; then - echo Installing new $1 - cp $FILE $LINUXSRC/include/linux/$FILE - bombiffailed - touch $LINUXSRC/include/linux/$FILE - bombiffailed - fi -done - 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 echo -# -# install header stub files in /usr/include/net - -for FILE in if_ppp.h \ - if_pppvar.h \ - ppp-comp.h \ - if.h \ - if_arp.h \ - route.h \ - ppp_defs.h - do - if [ ! -f /usr/include/net/$FILE ]; then - echo Installing stub include file in /usr/include/net/$FILE - echo "#include " > /usr/include/net/$FILE - bombiffailed - chown 0:0 /usr/include/net/$FILE - bombiffailed - chmod 444 /usr/include/net/$FILE - bombiffailed - touch /usr/include/net/$FILE - bombiffailed - fi -done - -for FILE in ip.h \ - tcp.h - do - if [ ! -f /usr/include/netinet/$FILE ]; then - echo Installing stub include file in /usr/include/netinet/$FILE - if [ ! -f $LINUXSRC/include/linux/$FILE ]; then - echo "#include \"$LINUXSRC/net/inet/$FILE\"" >/usr/include/netinet/$FILE - else - echo "#include " > /usr/include/netinet/$FILE - fi - chown 0:0 /usr/include/netinet/$FILE - bombiffailed - chmod 444 /usr/include/netinet/$FILE - bombiffailed - touch /usr/include/netinet/$FILE - bombiffailed - fi -done +# # +# # install header stub files in /usr/include/net + +# for FILE in if_ppp.h \ +# if_pppvar.h \ +# ppp-comp.h \ +# if.h \ +# ppp_defs.h +# do +# if [ ! -f /usr/include/net/$FILE ]; then +# echo Installing stub include file in /usr/include/net/$FILE +# echo "#include " > /usr/include/net/$FILE +# bombiffailed +# chown 0:0 /usr/include/net/$FILE +# bombiffailed +# chmod 444 /usr/include/net/$FILE +# bombiffailed +# touch /usr/include/net/$FILE +# bombiffailed +# fi +# done echo "Kernel driver files installation done." + exit 0