home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / init.d / glibc.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2009-04-09  |  5.5 KB  |  152 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. # Short-Description: check for deprecated kernel versions
  10. # Description:       This script detects deprecated kernel versions incompatible with
  11. #                    the current version of the glibc
  12. ### END INIT INFO
  13. #
  14.  
  15. # glibc kernel version check: KERNEL_VERSION_CHECK
  16. linux_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. kfreebsd_compare_versions () {
  24.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \* 100 + \2/')))
  25.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \* 100 + \2/')))
  26.  
  27.     test $verA -$2 $verB
  28. }
  29.  
  30. kernel26_help() {
  31.     echo ""
  32.     echo "The installation of a 2.6 kernel _could_ ask you to install a new libc"
  33.     echo "first, this is NOT a bug, and should *NOT* be reported. In that case,"
  34.     echo "please add lenny sources to your /etc/apt/sources.list and run:"
  35.     echo "  apt-get install -t lenny linux-image-2.6"
  36.     echo "Then reboot into this new kernel, and proceed with your upgrade"
  37. }
  38.  
  39. exit_check () {
  40.     sleep 5
  41.     exit 1
  42. }
  43.  
  44.     system=`uname -s`
  45.     if [ "$system" = "Linux" ]
  46.     then
  47.         # Test to make sure z < 255, in x.y.z-n form of kernel version
  48.         # Also make sure we don't trip on x.y.zFOO-n form
  49.         #kernel_rev=$(uname -r | tr -- - . | cut -d. -f3 | tr -d '[:alpha:]')
  50.         kernel_rev=$(uname -r | sed 's/\([0-9]*\.[0-9]*\.\)\([0-9]*\)\(.*\)/\2/')
  51.         if [ "$kernel_rev" -ge 255 ]
  52.         then
  53.             echo "WARNING: Your kernel version indicates a revision number"
  54.             echo "of 255 or greater.  Glibc has a number of built in"
  55.             echo "assumptions that this revision number is less than 255."
  56.             echo "If you\'ve built your own kernel, please make sure that any"
  57.             echo "custom version numbers are appended to the upstream"
  58.             echo "kernel number with a dash or some other delimiter."
  59.  
  60.             exit_check
  61.         fi
  62.  
  63.         # sanity checking for the appropriate kernel on each architecture.
  64.         realarch=`uname -m`
  65.         kernel_ver=`uname -r`
  66.  
  67.         # convert "armv4l" and similar to just "arm", "mips64" and similar
  68.         # to just "mips", "ppc64" and similar to just "powerpc", and
  69.         # "sparc64" and similar to just "sparc"
  70.         case $realarch in
  71.           arm*) realarch="arm";;
  72.           mips*) realarch="mips";;
  73.           powerpc*|ppc*) realarch="powerpc";;
  74.           sparc*) realarch="sparc";;
  75.         esac
  76.  
  77.  
  78.         # From glibc 2.3.5-7 real-i386 is dropped.
  79.         if [ "$realarch" = i386 ]
  80.         then
  81.             echo "WARNING: This machine has real i386 class processor."
  82.             echo "Debian etch and later does not support such old hardware"
  83.             echo "any longer."
  84.             echo "The reason is that \"bswap\" instruction is not supported"
  85.             echo "on i386 class processors, and some core libraries have"
  86.             echo "such instruction.  You\'ll see illegal instruction error"
  87.             echo "when you upgrade your Debian system."
  88.             exit_check
  89.         fi
  90.  
  91.         # The GNU libc requires a >= 2.6.15 kernel
  92.         if [ "$realarch" != m68k ]
  93.         then
  94.             if linux_compare_versions "$kernel_ver" lt 2.6.15
  95.             then
  96.                 echo WARNING: this version of the GNU libc requires kernel version
  97.                 echo 2.6.15 or later.  Please upgrade your kernel before installing
  98.                 echo glibc.
  99.                 kernel26_help
  100.                 exit_check
  101.             fi
  102.         fi
  103.  
  104.         # The GNU libc is now built with --with-kernel= >= 2.4.1 on m68k
  105.         if [ "$realarch" = m68k ]
  106.         then
  107.             if linux_compare_versions "$kernel_ver" lt 2.4.1
  108.             then
  109.                 echo WARNING: This version of glibc requires that you be running
  110.                 echo kernel version 2.4.1 or later.  Earlier kernels contained
  111.                 echo bugs that may render the system unusable if a modern version
  112.                 echo of glibc is installed.
  113.                 kernel26_help
  114.                 exit_check
  115.             fi
  116.         fi
  117.  
  118.         # From glibc 2.6-3 SPARC V8 support is dropped.
  119.         if [ "$realarch" = sparc ]
  120.         then
  121.             # The process could be run using linux32, check for /proc.
  122.             if [ -f /proc/cpuinfo ]
  123.             then
  124.                case "$(sed '/^type/!d;s/^type.*: //g' /proc/cpuinfo)" in
  125.                    sun4u)
  126.                       # UltraSPARC CPU
  127.                       ;;
  128.                    sun4v)
  129.                       # Niagara CPU
  130.                       ;;
  131.                    *)
  132.                       echo "WARNING: This machine has a SPARC V8 or earlier class processor."
  133.                       echo "Debian lenny and later does not support such old hardware"
  134.                       echo "any longer."
  135.                       exit_check
  136.                       ;;
  137.                esac
  138.             fi
  139.         fi
  140.     elif [ $system = "GNU/kFreeBSD" ] ; then
  141.         kernel_ver=`uname -r`
  142.         if kfreebsd_compare_versions "$kernel_ver" lt 6.0
  143.         then
  144.             echo WARNING: This version of glibc uses UMTX_OP_WAIT and UMTX_OP_WAKE
  145.         echo syscalls that are not present in the current running kernel. They
  146.         echo have been added in kFreeBSD 6.0.  Your system should still work,
  147.         echo but it is recommended to upgrade to a more recent version.
  148.         fi
  149.     fi
  150.  
  151. : exit 0
  152.