home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / etc / init.d / glibc.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-08-17  |  6.0 KB  |  185 lines

  1. #! /bin/sh -e
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides:          glibc
  5. # Required-Start:
  6. # Required-Stop:
  7. # Default-Start:     S
  8. # Default-Stop:
  9. ### END INIT INFO
  10. #
  11. # This script is existed for detecting depreciated kernel version to
  12. # check glibc incompatibility.
  13.  
  14. if [ "`uname -s`" = Linux ]; then
  15.     # glibc kernel version check: KERNEL_VERSION_CHECK
  16. kernel_compare_versions () {
  17.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  18.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  19.     
  20.     test $verA -$2 $verB
  21. }
  22.  
  23. exit_check () {
  24.     sleep 5
  25.     exit 1
  26. }
  27.  
  28.     # Test to make sure z < 255, in x.y.z-n form of kernel version
  29.     # Also make sure we don't trip on x.y.zFOO-n form
  30.     #kernel_rev=$(uname -r | tr -- - . | cut -d. -f3 | tr -d '[:alpha:]')
  31.     kernel_rev=$(uname -r | sed 's/\([0-9]*\.[0-9]*\.\)\([0-9]*\)\(.*\)/\2/')
  32.     if [ "$kernel_rev" -ge 255 ]
  33.     then
  34.         echo WARNING: Your kernel version indicates a revision number
  35.         echo of 255 or greater.  Glibc has a number of built in
  36.         echo assumptions that this revision number is less than 255.
  37.         echo If you\'ve built your own kernel, please make sure that any 
  38.         echo custom version numbers are appended to the upstream
  39.         echo kernel number with a dash or some other delimiter.
  40.  
  41.         exit_check
  42.     fi
  43.  
  44.     # sanity checking for the appropriate kernel on each architecture.
  45.     realarch=`uname -m`
  46.     kernel_ver=`uname -r`
  47.  
  48.     # convert "armv4l" and similar to just "arm", and "mips64" and similar
  49.     # to just "mips"
  50.     case $realarch in
  51.       arm*) realarch="arm";;
  52.       mips*) realarch="mips";;
  53.     esac
  54.     
  55.  
  56.     # intel i386 requires a recent kernel
  57.     if [ "$realarch" = i386 ]
  58.     then
  59.     # From glibc 2.3.5-7 and linux-2.6 2.6.12-1, real-i386 is dropped.
  60.     #if kernel_compare_versions "$kernel_ver" lt 2.4.24
  61.     #then
  62.         echo WARNING: This machine has real i386 class processor.
  63.         echo Debian etch and later does not support such old hardware
  64.         echo any longer.
  65.         echo The reason is that \"bswap\" instruction is not supported
  66.         echo on i386 class processors, and some core libraries have 
  67.         echo such instruction.  You\'ll see illegal instruction error
  68.         echo when you upgrade your Debian system.
  69.         exit_check
  70.     #fi
  71.     fi
  72.  
  73.     # The GNU libc is now built with --with-kernel= >= 2.4.1, except on m68k
  74.     if [ "$realarch" != m68k ]
  75.     then
  76.     if kernel_compare_versions "$kernel_ver" lt 2.4.1
  77.     then
  78.         echo WARNING: This version of glibc requires that you be running
  79.         echo kernel version 2.4.1 or later.  Earlier kernels contained
  80.         echo bugs that may render the system unusable if a modern version
  81.         echo of glibc is installed.
  82.         exit_check
  83.     fi
  84.     fi
  85.     # SPARC sun4m requires a recent kernel
  86.     if [ "$realarch" = sparc ]
  87.     then
  88.     cputype=`egrep '^type.*:.*sun4m' /proc/cpuinfo 2> /dev/null` || true
  89.  
  90.     if [ "$cputype" != "" ]
  91.     then
  92.         if kernel_compare_versions "$kernel_ver" lt 2.4.21
  93.         then
  94.         echo WARNING: You have a cpu which requires kernel 2.4.21
  95.         echo or greater in order to install this version of glibc.
  96.         echo Please upgrade the kernel before installing this package.
  97.         echo
  98.         echo You should be able to install the latest version of the
  99.         echo sparc kernel-image in order to satisfy this need. You
  100.         echo can also download and compile the latest kernel source
  101.         echo yourself from a kernel mirror \(see http://www.kernel.org/\).
  102.         exit_check
  103.         fi
  104.     fi
  105.     fi
  106.     # HPPA boxes require latest fixes in the kernel to function properly.
  107.     if [ "$realarch" = parisc ]
  108.     then
  109.     if kernel_compare_versions "$kernel_ver" lt 2.4.17
  110.     then
  111.         echo WARNING: This version of glibc requires that you be running
  112.         echo atleast a 2.4.17 kernel in order to work properly. Earlier
  113.         echo kernels did not provide the proper functionality in order 
  114.         echo for the system to be stable. 
  115.         exit_check
  116.     fi
  117.     fi
  118.     # parisc64 boxes require latest fixes in the kernel 2.4.19-pa17 or later
  119.     # (in 2.4.x), 2.5.53-pa3 or later (in 2.5.x), to function properly.
  120.     # Note that parisc64 kernel version scheme is "`uname -r`-64".
  121.     if [ "$realarch" = parisc64 ]
  122.     then
  123.     kernel_ver_pa=$(echo "$kernel_ver" | sed 's/pa//')
  124.     if [ "$kernel_ver" = "$kernel_ver_pa" ]
  125.     then
  126.         if kernel_compare_versions "$kernel_ver" lt 2.4.19-64
  127.         then
  128.         echo WARNING: This version of glibc requires that you be
  129.         echo running at least a 2.4.19-64 to work properly.
  130.         echo Earlier kernels did not provide the proper functionality
  131.         echo in order for the system to be stable. 
  132.         exit_check
  133.         fi
  134.     else
  135.         if kernel_compare_versions "$kernel_ver" lt 2.4.19-pa17
  136.         then
  137.         echo WARNING: This version of glibc requires that you be
  138.         echo running at least a 2.4.19-pa17 in \(2.4\) or 2.5.53-pa3 
  139.         echo \(in 2.5\) to work properly.
  140.         echo Earlier kernels did not provide the proper functionality
  141.         echo in order for the system to be stable. 
  142.         exit_check
  143.         fi
  144.     fi
  145.     fi
  146.  
  147.     if [ "$realarch" = mips ] \
  148.     && [ i386 = mips ]
  149.     then
  150.     # MIPS (but not mipsel) require a kernel update for the msq fixes.
  151.     if kernel_compare_versions "$kernel_ver" lt 2.4.22
  152.     then
  153.         echo WARNING: System V message queues require kernel 2.4.22 to
  154.         echo work correctly on this architecture.  Some programs
  155.         echo "(including perl) may not operate correctly."
  156.         exit_check
  157.     fi
  158.     fi
  159.  
  160.     # amd64 requires 2.6 kernel because we drop to support linuxthreads
  161.     if [ "$realarch" = x86_64 ] \
  162.     && [ i386 = amd64 ]
  163.     then
  164.     if kernel_compare_versions "$kernel_ver" lt 2.6.0
  165.     then
  166.         echo WARNING: POSIX threads library NPTL requires 2.6 and
  167.         echo later kernel on amd64.  If you use 2.4 kernel, please
  168.         echo upgrade your kernel before installing glibc.
  169.         exit_check
  170.     fi
  171.     fi
  172.  
  173.     # In Ubuntu, we have dropped LinuxThreads.  We require the 2.6 kernel.
  174.     if kernel_compare_versions "$kernel_ver" lt 2.6.0
  175.     then
  176.         echo WARNING: POSIX threads library NPTL requires 2.6 and
  177.         echo later kernel.  You are using a 2.4 kernel, please
  178.         echo upgrade your kernel before installing glibc.
  179.         exit_check
  180.     fi
  181.  
  182. fi
  183.  
  184. : exit 0
  185.