home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / var / lib / dpkg / info / libc6.preinst < prev    next >
Encoding:
Text File  |  2006-08-17  |  11.9 KB  |  371 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. if [ "$1" = upgrade ]
  6. then
  7.     if dpkg --compare-versions "$2" le 2.2.2-4 && test -e /lib/libdb.so.3; then
  8.     # Make upgrades to newer libdb.so.3 easier
  9.     cat /lib/libdb.so.3 > /lib/libdb.so.3.old
  10.     fi
  11.     if dpkg --compare-versions "$2" le 2.1.1-0.1; then
  12.     if [ -f /var/run/utmpd.pid ]; then
  13.         if kill -s TERM `cat /var/run/utmpd.pid` > /dev/null 2>&1
  14.         then
  15.         if [ -f /var/run/utmp ]; then
  16.             cp /dev/null /var/run/utmp
  17.             if grep '^utmp:' /etc/group; then
  18.             chown root:utmp /var/run/utmp
  19.             chmod 664 /var/run/utmp
  20.             else
  21.             chown root:root /var/run/utmp
  22.             chmod 644 /var/run/utmp
  23.             fi
  24.         fi
  25.         if [ -f /var/log/wtmp ]; then
  26.             savelog /var/log/wtmp
  27.             touch /var/log/wtmp
  28.             if grep '^utmp:' /etc/group; then
  29.             chown root:utmp /var/log/wtmp
  30.             chmod 664 /var/log/wtmp
  31.             else
  32.             chown root:root /var/log/wtmp
  33.             chmod 644 /var/log/wtmp
  34.             fi
  35.         fi
  36.         rm -f /etc/init.d/utmpd
  37.         update-rc.d utmpd remove > /dev/null
  38.         fi
  39.     fi
  40.     if [ -f /var/run/utmpx ]; then rm -f /var/run/utmpx; fi
  41.     if [ -f /var/log/wtmpx ]; then rm -f /var/log/wtmpx*; fi
  42.     if [ -e /var/run/utmpd.ro ]; then rm -f /var/run/utmpd.ro; fi
  43.     if [ -e /var/run/utmpd.rw ]; then rm -f /var/run/utmpd.rw; fi
  44.     fi
  45.  
  46.     # NSS authentication trouble guard
  47.     if dpkg --compare-versions $2 lt 2.3.5-1; then
  48.     check="xdm kdm gdm postgresql xscreensaver"
  49.     # Only get the ones that are installed, and configured
  50.     service=$(dpkg -s $check 2> /dev/null | awk 'BEGIN{RS="\n\n";FS="\n"}{if ( $2 ~ /Status: .* installed$/ ) { print $1 } }' | cut -f 2 -d ' ')
  51.  
  52.     echo
  53.     echo "Name Service Switch update in the C Library: pre-installation question."
  54.     echo
  55.     echo "Running services and programs that are using NSS need to be restarted,"
  56.     echo "otherwise they might not be able to do lookup or authentication any more."
  57.     echo "The installation process is able to restart some services (such as ssh or"
  58.     echo "telnetd), but other programs cannot be restarted automatically.  One such"
  59.     echo "program that needs manual stopping and restart after the glibc upgrade by"
  60.     echo "yourself is xdm - because automatic restart might disconnect your active"
  61.     echo "X11 sessions."
  62.     echo
  63.     echo "Known packages that need to be stopped before the glibc upgrade are:"
  64.     echo "        $check"
  65.     echo
  66.  
  67.     if [ -n "$service" ]; then 
  68.         echo "This script detected the following installed services which must be"
  69.         echo "stopped before the upgrade:"
  70.         echo "        $service"
  71.     else
  72.         echo "This script did not detect any installed services which need to be"
  73.         echo "stopped."
  74.     fi
  75.     echo
  76.     echo "If you want to interrupt the upgrade now and continue later, please"
  77.     echo "answer No to the question below."
  78.     echo 
  79.     frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  80.     if [ "$frontend" = noninteractive ]; then
  81.         echo "Non-interactive mode, upgrade glibc forcibly"
  82.         answer=yes
  83.     else
  84.         echo -n "Do you want to upgrade glibc now? [Y/n] "
  85.         read answer
  86.         case $answer in
  87.         Y*|y*) answer=yes ;;
  88.         N*|n*) answer=no ;;
  89.         *) answer=yes ;;
  90.         esac
  91.     fi
  92.     echo
  93.     if [ "$answer" = no ]; then
  94.         echo "Stopped glibc upgrade.  Please retry the upgrade after you have"
  95.         echo "checked or stopped services by hand."
  96.         exit 1
  97.     fi
  98.     fi
  99.  
  100.     # This will keep us from using hwcap libs (optimized) during an
  101.     # upgrade.
  102.     touch /etc/ld.so.nohwcap
  103.     echo glibc >> /etc/ld.so.nohwcap
  104. fi
  105.  
  106. # Sanity check.
  107. # If there are versions of glibc outside of the normal installation
  108. # location (/lib, /lib64, etc.) then things may break very badly
  109. # as soon as ld.so is replaced by a new version.  This check is not
  110. # foolproof, but it's pretty accurate.  This script ignores old
  111. # libc4 or libc5, and libraries incompatible with the to-be-installed
  112. # ld.so.
  113.  
  114. check_dirs () {
  115.   for dir in $*; do
  116.     # Follow symlinks
  117.     dirlink=$(readlink -f $dir)
  118.     [ -n "$dirlink" ] && dir=$dirlink 
  119.     
  120.     # Handle /lib in LD_LIBRARY_PATH.
  121.     if expr $dir : "/lib.*" > /dev/null; then
  122.       continue
  123.     fi
  124.     # Skip ia32-libs package on ia64, and similar libraries
  125.     # (not sure why these get added to /etc/ld.so.conf)
  126.     if expr $dir : "/emul/.*" > /dev/null; then
  127.       continue
  128.     fi
  129.     if test -d $dir; then
  130.       output=$(ls $dir | egrep '^lib(c|m|pthread|rt|dl)\.so\.[^/]*$' |\
  131.            egrep -v '^lib[cm]\.so\.[45].*$' 2>/dev/null)
  132.  
  133.       if test -n "$output"; then
  134.     # See if the found libraries are compatible with the system ld.so;
  135.     # if they aren't, they'll be ignored.  Check e_ident, e_type (which
  136.     # will just be ET_DYN), and e_machine.  If a match is found, there
  137.     # is a risk of breakage.
  138.     for lib in $output
  139.     do
  140.       if test -f "$dir/$lib"; then
  141.         libbytes=`head -c 20 $dir/$lib | od -c`
  142.         for ld_so in $ld_so_list
  143.         do
  144.           if test -f "$ld_so"; then
  145.             ldbytes=`head -c 20 $ld_so | od -c`
  146.             if test "$ldbytes" = "$libbytes"; then
  147.               echo "Matching libraries: $dir/$lib $ld_so"
  148.               return 0
  149.             fi
  150.           fi
  151.         done
  152.       fi
  153.     done
  154.       fi
  155.     fi
  156.   done
  157.   return 1
  158. }
  159.  
  160. if [ "$1" != abort-upgrade ]
  161. then
  162.   ld_so_list="/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2"
  163.   dirs="/usr/local/lib /usr/local/lib32 /usr/local/lib64"
  164.   if ! test -L /usr; then
  165.     dirs="$dirs /usr/lib /usr/lib32 /usr/lib64"
  166.   fi
  167.   if check_dirs $dirs; then
  168.     echo
  169.     echo "A copy of glibc was found in an unexpected directory."
  170.     echo "It is not safe to upgrade the C library in this situation;"
  171.     echo "please remove that copy of the C library and try again."
  172.     exit 1
  173.   fi
  174.  
  175.   if test -n "$LD_LIBRARY_PATH"; then
  176.     dirs=$(echo $LD_LIBRARY_PATH | sed 's/:/ /')
  177.     if check_dirs $dirs; then
  178.       echo
  179.       echo "Another copy of the C library was found via LD_LIBRARY_PATH."
  180.       echo "It is not safe to upgrade the C library in this situation;"
  181.       echo "please remove the directory from LD_LIBRARY_PATH and try again."
  182.       exit 1
  183.     fi
  184.   fi
  185.   if test -e /etc/ld.so.conf; then
  186.     dirs=$(echo $(cat /etc/ld.so.conf))
  187.     if check_dirs $dirs; then
  188.       echo
  189.       echo "Another copy of the C library was found via /etc/ld.so.conf."
  190.       echo "It is not safe to upgrade the C library in this situation;"
  191.       echo "please remove the directory from /etc/ld.so.conf and try again."
  192.       exit 1
  193.     fi
  194.   fi
  195. fi
  196.  
  197. if [ "$1" != abort-upgrade ] && [ "`uname -s`" = Linux ]
  198. then
  199.     # glibc kernel version check: KERNEL_VERSION_CHECK
  200. kernel_compare_versions () {
  201.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  202.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  203.     
  204.     test $verA -$2 $verB
  205. }
  206.  
  207. exit_check () {
  208.     
  209.     exit 1
  210. }
  211.  
  212.     # Test to make sure z < 255, in x.y.z-n form of kernel version
  213.     # Also make sure we don't trip on x.y.zFOO-n form
  214.     #kernel_rev=$(uname -r | tr -- - . | cut -d. -f3 | tr -d '[:alpha:]')
  215.     kernel_rev=$(uname -r | sed 's/\([0-9]*\.[0-9]*\.\)\([0-9]*\)\(.*\)/\2/')
  216.     if [ "$kernel_rev" -ge 255 ]
  217.     then
  218.         echo WARNING: Your kernel version indicates a revision number
  219.         echo of 255 or greater.  Glibc has a number of built in
  220.         echo assumptions that this revision number is less than 255.
  221.         echo If you\'ve built your own kernel, please make sure that any 
  222.         echo custom version numbers are appended to the upstream
  223.         echo kernel number with a dash or some other delimiter.
  224.  
  225.         exit_check
  226.     fi
  227.  
  228.     # sanity checking for the appropriate kernel on each architecture.
  229.     realarch=`uname -m`
  230.     kernel_ver=`uname -r`
  231.  
  232.     # convert "armv4l" and similar to just "arm", and "mips64" and similar
  233.     # to just "mips"
  234.     case $realarch in
  235.       arm*) realarch="arm";;
  236.       mips*) realarch="mips";;
  237.     esac
  238.     
  239.  
  240.     # intel i386 requires a recent kernel
  241.     if [ "$realarch" = i386 ]
  242.     then
  243.     # From glibc 2.3.5-7 and linux-2.6 2.6.12-1, real-i386 is dropped.
  244.     #if kernel_compare_versions "$kernel_ver" lt 2.4.24
  245.     #then
  246.         echo WARNING: This machine has real i386 class processor.
  247.         echo Debian etch and later does not support such old hardware
  248.         echo any longer.
  249.         echo The reason is that \"bswap\" instruction is not supported
  250.         echo on i386 class processors, and some core libraries have 
  251.         echo such instruction.  You\'ll see illegal instruction error
  252.         echo when you upgrade your Debian system.
  253.         exit_check
  254.     #fi
  255.     fi
  256.  
  257.     # The GNU libc is now built with --with-kernel= >= 2.4.1, except on m68k
  258.     if [ "$realarch" != m68k ]
  259.     then
  260.     if kernel_compare_versions "$kernel_ver" lt 2.4.1
  261.     then
  262.         echo WARNING: This version of glibc requires that you be running
  263.         echo kernel version 2.4.1 or later.  Earlier kernels contained
  264.         echo bugs that may render the system unusable if a modern version
  265.         echo of glibc is installed.
  266.         exit_check
  267.     fi
  268.     fi
  269.     # SPARC sun4m requires a recent kernel
  270.     if [ "$realarch" = sparc ]
  271.     then
  272.     cputype=`egrep '^type.*:.*sun4m' /proc/cpuinfo 2> /dev/null` || true
  273.  
  274.     if [ "$cputype" != "" ]
  275.     then
  276.         if kernel_compare_versions "$kernel_ver" lt 2.4.21
  277.         then
  278.         echo WARNING: You have a cpu which requires kernel 2.4.21
  279.         echo or greater in order to install this version of glibc.
  280.         echo Please upgrade the kernel before installing this package.
  281.         echo
  282.         echo You should be able to install the latest version of the
  283.         echo sparc kernel-image in order to satisfy this need. You
  284.         echo can also download and compile the latest kernel source
  285.         echo yourself from a kernel mirror \(see http://www.kernel.org/\).
  286.         exit_check
  287.         fi
  288.     fi
  289.     fi
  290.     # HPPA boxes require latest fixes in the kernel to function properly.
  291.     if [ "$realarch" = parisc ]
  292.     then
  293.     if kernel_compare_versions "$kernel_ver" lt 2.4.17
  294.     then
  295.         echo WARNING: This version of glibc requires that you be running
  296.         echo atleast a 2.4.17 kernel in order to work properly. Earlier
  297.         echo kernels did not provide the proper functionality in order 
  298.         echo for the system to be stable. 
  299.         exit_check
  300.     fi
  301.     fi
  302.     # parisc64 boxes require latest fixes in the kernel 2.4.19-pa17 or later
  303.     # (in 2.4.x), 2.5.53-pa3 or later (in 2.5.x), to function properly.
  304.     # Note that parisc64 kernel version scheme is "`uname -r`-64".
  305.     if [ "$realarch" = parisc64 ]
  306.     then
  307.     kernel_ver_pa=$(echo "$kernel_ver" | sed 's/pa//')
  308.     if [ "$kernel_ver" = "$kernel_ver_pa" ]
  309.     then
  310.         if kernel_compare_versions "$kernel_ver" lt 2.4.19-64
  311.         then
  312.         echo WARNING: This version of glibc requires that you be
  313.         echo running at least a 2.4.19-64 to work properly.
  314.         echo Earlier kernels did not provide the proper functionality
  315.         echo in order for the system to be stable. 
  316.         exit_check
  317.         fi
  318.     else
  319.         if kernel_compare_versions "$kernel_ver" lt 2.4.19-pa17
  320.         then
  321.         echo WARNING: This version of glibc requires that you be
  322.         echo running at least a 2.4.19-pa17 in \(2.4\) or 2.5.53-pa3 
  323.         echo \(in 2.5\) to work properly.
  324.         echo Earlier kernels did not provide the proper functionality
  325.         echo in order for the system to be stable. 
  326.         exit_check
  327.         fi
  328.     fi
  329.     fi
  330.  
  331.     if [ "$realarch" = mips ] \
  332.     && [ i386 = mips ]
  333.     then
  334.     # MIPS (but not mipsel) require a kernel update for the msq fixes.
  335.     if kernel_compare_versions "$kernel_ver" lt 2.4.22
  336.     then
  337.         echo WARNING: System V message queues require kernel 2.4.22 to
  338.         echo work correctly on this architecture.  Some programs
  339.         echo "(including perl) may not operate correctly."
  340.         exit_check
  341.     fi
  342.     fi
  343.  
  344.     # amd64 requires 2.6 kernel because we drop to support linuxthreads
  345.     if [ "$realarch" = x86_64 ] \
  346.     && [ i386 = amd64 ]
  347.     then
  348.     if kernel_compare_versions "$kernel_ver" lt 2.6.0
  349.     then
  350.         echo WARNING: POSIX threads library NPTL requires 2.6 and
  351.         echo later kernel on amd64.  If you use 2.4 kernel, please
  352.         echo upgrade your kernel before installing glibc.
  353.         exit_check
  354.     fi
  355.     fi
  356.  
  357.     # In Ubuntu, we have dropped LinuxThreads.  We require the 2.6 kernel.
  358.     if kernel_compare_versions "$kernel_ver" lt 2.6.0
  359.     then
  360.         echo WARNING: POSIX threads library NPTL requires 2.6 and
  361.         echo later kernel.  You are using a 2.4 kernel, please
  362.         echo upgrade your kernel before installing glibc.
  363.         exit_check
  364.     fi
  365.  
  366. fi
  367.  
  368.  
  369.  
  370. exit 0
  371.