]> git.ozlabs.org Git - ppp.git/blobdiff - linux/kinstall.sh
Update from Steve Perkins
[ppp.git] / linux / kinstall.sh
index 06ea13ba997b12ed922b9f0918658a24dbd3bf68..1d76385a639d1c4236912f785c371dd34be8ff67 100755 (executable)
@@ -48,7 +48,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.
 #    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
 
   exit 1
 fi
 
@@ -62,28 +62,17 @@ KERNEL=$VERSION.$PATCHLEVEL.$SUBLEVEL
 
 #
 #  Pass judgement on the kernel version
 
 #
 #  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 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
     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
 
 fi
 
-echo
-echo Installing into kernel version $KERNEL in $LINUXSRC
-echo
-
 #
 # convenience function to exit if the last command failed
 
 #
 # 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"
   STATUS=$?
   if [ $STATUS -ne 0 ]; then
     echo "=== kinstall.sh exiting with failure status $STATUS"
@@ -95,40 +84,39 @@ function bombiffailed () {
 # convenience function to compare two files marked with ==FILEVERSION
 # version numbers; returns success if $1 is newer than $2
 
 # 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
   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
   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.
 
 }
 
 #
 #  Install the files.
 
-function installfile () {
+installfile () {
   BASE=`basename $1`
   if newer $1 $BASE; then
     echo $1 is newer than $BASE, skipping
   BASE=`basename $1`
   if newer $1 $BASE; then
     echo $1 is newer than $BASE, skipping
@@ -145,11 +133,41 @@ function installfile () {
   bombiffailed
   touch $1
   bombiffailed
   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
 }
 
   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
 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 +175,9 @@ if [ -f $LINUXSRC/drivers/net/ppp.h ]; then
 fi
 
 for FILE in $LINUXSRC/drivers/net/bsd_comp.c \
 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 \
             $LINUXSRC/include/linux/if_ppp.h \
             $LINUXSRC/include/linux/if_pppvar.h \
             $LINUXSRC/include/linux/ppp-comp.h \
@@ -167,57 +188,38 @@ done
 
 installfile $LINUXSRC/drivers/net/ppp.c yes
 
 
 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 '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) <patch-1.2
-      if [ ! "$?" = "0" ]; then
-         touch $NETMK.rej
-      fi
-   else
-      if [ "$VERSION.$PATCHLEVEL" = "1.3" ]; then
-         (cd $LINUXSRC; patch -p1 -f -F30 -s) <patch-1.3
-         if [ ! "$?" = "0" ]; then
-            touch $NETMK.rej
-         fi
-      else
-         touch $NETMK.rej
-      fi
-   fi
-#
-   if [ -e $NETMK.rej ]; then
-      rm -f $NETMK.rej
-      if [ -e $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
-   fi
-#
-   if [ -e $NETMK.orig ]; then
-      mv $NETMK.orig $NETMK.old
+   if [ -f $NETMK.orig ]; then
+      mv $NETMK.orig $NETMK
    fi
    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
 else
    echo -n '(already there--skipping)'
 fi
@@ -230,8 +232,6 @@ for FILE in if_ppp.h \
             if_pppvar.h \
             ppp-comp.h \
            if.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
             ppp_defs.h
   do
   if [ ! -f /usr/include/net/$FILE ]; then
@@ -247,24 +247,6 @@ for FILE in if_ppp.h \
   fi
 done
 
   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 <linux/$FILE>" > /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
-
 echo "Kernel driver files installation done."
 echo "Kernel driver files installation done."
+
 exit 0
 exit 0