home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libc6.postinst < prev    next >
Encoding:
Text File  |  2009-08-31  |  11.6 KB  |  400 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. type=$1
  6. preversion=$2
  7.  
  8. if [ "x$type" = xtriggered ]
  9. then
  10.     LDCONFIG_NOTRIGGER=y
  11.     export LDCONFIG_NOTRIGGER
  12.     echo ldconfig deferred processing now taking place
  13.     ldconfig
  14.     exit 0
  15. fi
  16.  
  17. package_name()
  18. {
  19.     echo libc6
  20. }
  21.  
  22. # Borrowed from sysvinit's postinst.
  23. #    Function like update-rc.d but simpler & faster.
  24. #    Usage: updatercd basename start|stop NN runlevel .
  25. #
  26. #    Now we use the real update-rc.d, so now this function should
  27. #    be equivalent to /usr/sbin/update-rc.d.
  28. #
  29. updatercd() {
  30.  
  31.     if [ ! -f /etc/init.d/$1 ]
  32.     then
  33.         return
  34.     fi
  35.  
  36.     if [ -x /usr/sbin/update-rc.d ]
  37.     then
  38.         update-rc.d "$@" > /dev/null
  39.         return $?
  40.     fi
  41.  
  42.     base=$1
  43.     shift
  44.     while [ "$1" != "" ]
  45.     do
  46.         if [ "$1" = stop ]
  47.         then
  48.             tlet=K
  49.         else
  50.             tlet=S
  51.         fi
  52.         lev=$2
  53.         shift 2
  54.         while [ "$1" != "." ]
  55.         do
  56.             cd /etc/rc$1.d
  57.             tmp="`echo $tlet??$base`"
  58.             case "$tmp" in
  59.                 "$tlet??$base")
  60.                     # Not present yet.
  61.                     ln -s ../init.d/$base $tlet$lev$base
  62.                     ;;
  63.                 *)
  64.                     # Already present.
  65.                     ;;
  66.             esac
  67.             shift
  68.         done
  69.         shift
  70.     done
  71. }
  72.  
  73. # element() is a helper function for file-rc:
  74. element() {
  75.     local element list IFS
  76.  
  77.     element="$1"
  78.  
  79.     [ "$2" = "in" ] && shift
  80.     list="$2"
  81.     [ "$list" = "-" ] && return 1
  82.     [ "$list" = "*" ] && return 0
  83.  
  84.     IFS=","
  85.     set -- $list
  86.     case $element in
  87.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  88.         return 0
  89.     esac
  90.     return 1
  91. }
  92.  
  93. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  94. # running in $runlevel:
  95. filerc() {
  96.     local runlevel basename
  97.     runlevel=$1
  98.     basename=$2
  99.     while read LINE
  100.     do
  101.     case $LINE in
  102.         \#*|"") continue
  103.     esac
  104.  
  105.     set -- $LINE
  106.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  107.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  108.  
  109.     if element "$runlevel" in "$START" || element "S" in "$START"
  110.     then
  111.         echo "/etc/init.d/$basename"
  112.         return 0
  113.     fi
  114.     done < /etc/runlevel.conf
  115.     echo ""
  116. }
  117.  
  118. checkpkgver () {
  119.     local status pkg
  120.     pkg=$1
  121.     status=$(dpkg -s $pkg 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  122.     if [ -n "$status" ] && [ "$status" != "not-installed" ] && [ "$status" != "config-files" ]; then
  123.     echo $(dpkg -s $pkg 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//');
  124.     fi
  125. }
  126.  
  127. if [ "$type" = "configure" ]
  128. then
  129.     # Add support for /etc/ld.so.conf.d
  130.     if [ -e /etc/ld.so.conf ]; then
  131.         [ -z "$(tail -n 1 /etc/ld.so.conf)" ] || echo >> /etc/ld.so.conf
  132.     else
  133.         touch /etc/ld.so.conf
  134.     fi
  135.     if ! grep -q '^include /etc/ld.so.conf.d/.*\.conf$' /etc/ld.so.conf ; then
  136.         echo 'include /etc/ld.so.conf.d/*.conf' >> /etc/ld.so.conf
  137.     fi
  138.  
  139.     # We don't use a registry anymore, remove the old file
  140.     rm -f /etc/ld.so.hwcappkgs
  141.  
  142.     # /etc/ld.so.nohwcap code: NOHWCAP
  143.     # Handle upgrades when libc-opt package has been installed.
  144.     # When a /etc/ld.so.nohwcap file exists, ld.so only use libraries
  145.     # from /lib, and ignore all optimised libraries. This file is
  146.     # inconditionaly created in the preinst script of libc.
  147.  
  148.     # Get the list of optimized packages for a given architecture
  149.     # Before removing a package from this list, make sure it appears
  150.     # in the Conflicts: line of libc.
  151.     case $(dpkg --print-architecture) in
  152.         alpha)
  153.             hwcappkgs="libc6-alphaev67"
  154.             ;;
  155.         armel)
  156.             hwcappkgs="libc6-vfp"
  157.             ;;
  158.         i386)
  159.             hwcappkgs="libc6-i686 libc6-xen"
  160.             ;;
  161.         kfreebsd-i386)
  162.             hwcappkgs="libc0.1-i686"
  163.             ;;
  164.         sparc)
  165.             hwcappkgs="libc6-sparcv9 libc6-sparcv9b libc6-sparcv9v libc6-sparcv9v2 libc6-sparc64b libc6-sparc64v libc6-sparc64v2"
  166.             ;;
  167.     esac
  168.  
  169.     # We check the version between the current installed libc and
  170.     # all optimized packages (on architectures where such packages
  171.     # exists).
  172.     all_upgraded=yes
  173.     if [ -n "$hwcappkgs" ]; then
  174.         for pkg in $hwcappkgs ; do
  175.             ver=$(dpkg -l $pkg 2>/dev/null | sed -e '/^i/!d;' -e "s/^i.\s\+$pkg\s\+//;s/\s.*//g")
  176.             if [ -n "$ver" ] && [ "$ver" != "2.9-4ubuntu6.1" ]; then
  177.                 all_upgraded=no
  178.             fi
  179.         done
  180.     fi
  181.  
  182.     # If the versions of all optimized packages are the same as the libc
  183.     # one, we could remove /etc/ld.so.nohwcap. Otherwise, it will be removed
  184.     # when all optimized packages are upgraded or removed.
  185.     if [ "$all_upgraded" = yes ] ; then
  186.         rm -f /etc/ld.so.nohwcap
  187.     fi
  188.  
  189.     # Load debconf module if available
  190.     if [ -f /usr/share/debconf/confmodule ] ; then
  191.     . /usr/share/debconf/confmodule
  192.     fi
  193.  
  194.     if [ -n "$preversion" ]; then
  195.     if [ ! -d /var/mail ] && [ ! -L /var/mail ]; then
  196.         ln -sf spool/mail /var/mail
  197.     fi
  198.     if dpkg --compare-versions "$preversion" lt 2.9-1; then
  199.         check="apache2-common apache apache-ssl apache-perl autofs at"
  200.         check="$check boa cucipop courier-authdaemon cron cupsys exim"
  201.         check="$check exim4-base dovecot-common cucipop lprng lpr"
  202.         check="$check lpr-ppd mysql-server nis openbsd-inetd"
  203.         check="$check openldapd postfix postfix-tls rsync samba"
  204.         check="$check sasl2-bin slapd smail sendmail snmpd ssh"
  205.         check="$check spamassassin vsftpd wu-ftpd wu-ftpd-academ wwwoffle"
  206.         check="$check webmin dropbear"
  207.         # NSS services check: NSS_CHECK
  208.         echo -n "Checking for services that may need to be restarted..."
  209.         # Only get the ones that are installed, and configured
  210.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  211.         # some init scripts don't match the package names
  212.         check=$(echo $check | \
  213.                 sed -e's/\bapache2-common\b/apache2/g' \
  214.                     -e's/\bat\b/atd/g' \
  215.                     -e's/\bdovecot-common\b/dovecot/g' \
  216.                     -e's/\bexim4-base\b/exim4/g' \
  217.                     -e's/\blpr\b/lpd/g' \
  218.                     -e's/\blpr-ppd\b/lpd-ppd/g' \
  219.                     -e's/\bsasl2-bin\b/saslauthd/g' \
  220.         )
  221.         echo
  222.         echo "Checking init scripts..."
  223.         rl=$(runlevel | sed 's/.*\ //')
  224.         for service in $check; do
  225.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  226.                 idl=$(ls /etc/init.d/${service} 2> /dev/null | head -n 1)
  227.                 if [ -n "$idl" ] && [ -x $idl ]; then
  228.                     services="$service $services"
  229.                 else
  230.                     echo "WARNING: init script for $service not found."
  231.                 fi
  232.             else
  233.                 if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  234.                     idl=$(filerc $rl $service)
  235.                 else
  236.                     idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  237.                 fi
  238.                 if [ -n "$idl" ] && [ -x $idl ]; then
  239.                     services="$service $services"
  240.                 fi
  241.             fi
  242.         done
  243.         if [ -n "$services" ]; then
  244.  
  245.             if [ -f /usr/share/debconf/confmodule ] ; then
  246.             db_version 2.0
  247.             db_reset glibc/restart-services
  248.             db_set glibc/restart-services "$services"
  249.             if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  250.             db_input medium glibc/restart-services || true
  251.             else
  252.             db_input critical glibc/restart-services || true
  253.             fi
  254.             db_go || true
  255.             db_get glibc/restart-services
  256.             if [ "x$RET" != "x" ]
  257.             then
  258.                 services="$RET"
  259.             else
  260.                 services=""
  261.             fi
  262.         else
  263.             echo
  264.             echo "Name Service Switch update in the C Library: post-installation question."
  265.             echo
  266.             echo "Running services and programs that are using NSS need to be restarted,"
  267.             echo "otherwise they might not be able to do lookup or authentication any more"
  268.             echo "(for services such as ssh, this can affect your ability to login)."
  269.             echo "Note: restarting sshd/telnetd should not affect any existing connections."
  270.             echo
  271.             echo "The services detected are: "
  272.             echo "        $services"
  273.             echo
  274.             echo "If other services have begun to fail mysteriously after this upgrade, it is"
  275.             echo "probably necessary to restart them too.  We recommend that you reboot your"
  276.             echo "machine after the upgrade to avoid NSS-related troubles."
  277.             echo
  278.             frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  279.             if [ "$frontend" = noninteractive ]; then
  280.                 echo "Non-interactive mode, restarting services"
  281.                 answer=yes
  282.             else
  283.                 echo -n "Do you wish to restart services? [Y/n] "
  284.                 read answer
  285.                 case $answer in
  286.                 N*|n*) services="" ;;
  287.                 *) ;;
  288.                 esac
  289.             fi
  290.         fi
  291.         echo
  292.         if [ "$services" != "" ]; then
  293.             echo "Restarting services possibly affected by the upgrade:"
  294.             failed=""
  295.             for service in $services; do
  296.                 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  297.                 idl="invoke-rc.d ${service}"
  298.             elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  299.                 idl=$(filerc $rl $service)
  300.             else
  301.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  302.             fi
  303.             echo -n "  $service: stopping..."
  304.             $idl stop > /dev/null 2>&1 || true
  305.             sleep 2
  306.             echo -n "starting..."
  307.             if $idl start > /dev/null 2>&1; then
  308.                 echo "done."
  309.             else
  310.                 echo "FAILED! ($?)"
  311.                 failed="$service $failed"
  312.             fi
  313.             done
  314.             echo
  315.             if [ -n "$failed" ]; then
  316.                 if [ -f /usr/share/debconf/confmodule ] ; then
  317.                     db_fset glibc/restart-failed seen false
  318.                 db_subst glibc/restart-failed services "$failed"
  319.                 if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  320.                 db_input medium glibc/restart-failed || true
  321.                 else
  322.                 db_input critical glibc/restart-failed || true
  323.                 fi
  324.                 db_go || true
  325.             else
  326.                 echo "The following services failed to start: $failed"
  327.                 echo
  328.                 echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
  329.                 echo "If the service still fails to start, you may need to file a bug on"
  330.                 echo "$(package_name) or the service involved."
  331.                 frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  332.                 if [ "$frontend" != noninteractive ]; then
  333.                     echo
  334.                     echo -n "Press ENTER to continue: "
  335.                     read foo
  336.                 fi
  337.             fi
  338.             else
  339.             echo "Services restarted successfully."
  340.                     fi
  341.         fi
  342.                 # Shut down the frontend, to make sure none of the
  343.         # restarted services keep a connection open to it
  344.             if [ -f /usr/share/debconf/confmodule ] ; then
  345.             db_stop
  346.         fi
  347.         else
  348.         echo "Nothing to restart."
  349.         fi
  350.     fi # end upgrading and $preversion lt 2.6-1
  351.     fi # Upgrading
  352.  
  353.     # Generate cache file /usr/lib/gconv/gconv-modules.cache
  354.     iconvconfig || true
  355.  
  356.     # Ubuntu change.  Do not do kernel version detection at startup.
  357.     update-rc.d -f glibc.sh remove >/dev/null 2>&1
  358.  
  359. fi
  360.  
  361. if [ "`uname -s`" = Linux ]; then
  362. #
  363. #       Upgrade init if possible. There was a bug in all versions
  364. #       up to and including 2.75-4, which didn't affect i386 but
  365. #       did affect most other architectures.
  366. #
  367. sysvinitver="`dpkg -s sysvinit 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//'`"
  368. case "`uname -m`" in
  369.         i?86)
  370.                 badsysvinitver="2.[0-6]*|2.7[0-3]*"
  371.                 ;;
  372.         *)
  373.                 badsysvinitver="2.[0-6]*|2.7[0-4]*|2.75-*"
  374.                 ;;
  375. esac
  376. # Black magic. If we are in a chroot, then /proc/1/exe will not resolve to
  377. # a file (will return EPERM). This keeps us from breaking things in
  378. # debootstrap, and the like.
  379. case "$sysvinitver" in
  380.         $badsysvinitver)
  381.                 ;;
  382.         *)
  383.         if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
  384.             # the devicenumber/inode pair of / is the same as that of /sbin/init's
  385.             # root, so we're *not* in a chroot
  386.             (init u ; sleep 1)
  387.         fi
  388.         ;;
  389. esac
  390. fi
  391.  
  392. # Automatically added by dh_makeshlibs
  393. if [ "$1" = "configure" ]; then
  394.     ldconfig
  395. fi
  396. # End automatically added section
  397.  
  398.  
  399. exit 0
  400.