[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re:libc5 to libc6 auto-upgrade script



This version should be close to good enough.  The major change since the last one that was posted is the ability to upgrade from files in the current dir instead of a local mirror requirement. 

This script still needs testing.

--cut here--
#! /bin/sh

# upgrade a libc5 (bo) machine to libc6 (hamm).

# based on Scott Ellis' excellent "Debian libc5 to libc6 Mini-HOWTO"
# document at http://www.gate.net/~storm/FAQ/libc5-libc6-Mini-HOWTO.html

# Author: Craig Sanders <cas@taz.net.au>
#
# Copyright Status: This script is hereby placed in the public domain
#
# Revision History:
# v0.0: 1998-01-08 (morning)
#	- a rough transcript of scott's doc and my own experiences
# v0.1: 1998-01-08 (night)
#   - a few bugfixes
#   - i got unlazy and put in the right subdirectories for each package. 
#     should run a lot faster.
# 	- now checks for failure at critical points and exits with a different
#     exit code for each failure.
#   - now uses 'binary-$(dpkg --print-installation-architecture)' instead 
#     of 'binary-i386'.
# v0.2: 1998-01-09 
#   - fixed the perl-base/perl install (thanks Lindsay!)
#   - improved the DEVPACKAGES=$(dpkg --get-selections...) and added -dbg
#     packages.
# v0.3: 1998-01-09 (p.m.)
#   - fixed some directories
#  -  changed "-iB" to "-iBE" so that if the script fails and is run again
#	it will not disturb things already in place.
#   - added a final "dpkg --configure --pending".
#   - sanity check that we are in the right place added
# v0.4: 1998-01-10 (Igor Grobman)
#    -made it possible to place all packages in current dir.
#    -added -pic packages to removal list.
#    -make sure dpkg-dev does not get selected for removal.
#    -moved dpkg-ftp and dpkg-mounted to the end.      
#v0.5: 1998-01-10 (Igor Grobman)
#    -added a note about upgrading libraries 
#
#
# TODO: (probably by somebody else.  this script is mostly good enough imo)
#   - error checking

echo "This script will install the packages necessary to ensure a safe"
echo "upgrade to hamm.  You need to either have a local or remote mirror"
echo "mounted, or have the following packages available in the current"
echo "directory: ldso, libc5, libc6, timezones, locales,              "
echo "ncurses3.0, ncurses3.4, libreadline2, libreadlineg2, bash, libg++272,"
echo "dpkg, dpkg-dev, dpkg-ftp, dpkg-mountable, libgdbm1, libgdbmg1, perl-base,"
echo "and perl.  If you are using a mirror, press 'm'.  If you have the files"
echo -n "if you have the files in the current dir, press 'c': (m/c) "
read answer


case $answer
in
m)  #local mirror available

# first, build up a list of installed -dev packages so that we can
# remove them.  remove wg-15-locale too.
#
# this is necessary even on machines which aren't doing libc6
# development because libc5 can't be upgraded to latest version without
# removal of libc5-dev which also necessitates removal of other -dev
# packages like libdb1-dev and libdl1-dev if they are installed.

DEVPACKAGES=$( dpkg --get-selections | 
    grep -v dpkg-dev |
    grep -v deinstall | 
    cut -f1 |
    grep -- "-dev$\|-pic$\|-dbg$" )

dpkg --remove -B $DEVPACKAGES wg15-locale || exit 1

# now install the new versions of things.  Just the bare minimum to let
# the user safely run dselect for the rest of the upgrade.

# change this to prompt the user for the location of the debian archive.
cd /debian/dists/unstable/main/binary-$(dpkg --print-installation-architecture)

# sanity check that we are in the right place
[ -f base/libc6_* ] || exit 9

# libc
#
dpkg -iBE base/ldso_*.deb base/libc5_*.deb base/libc6_*.deb \
    base/timezones_*.deb admin/locales_*.deb || exit 2

# libreadline, ncurses, and bash
#
dpkg -iBE libs/ncurses3.0_*.deb base/ncurses3.4_*.deb  || exit 3
dpkg -iBE oldlibs/libreadline2_*.deb  || exit 4
dpkg -iBE base/libreadlineg2_*.deb || exit 5

# paranoia says run ldconfig NOW. don't laugh, i've needed to do this on
# some libc5-libc6 upgrades. i know that the postinst scripts for the
# libs are supposed to do it but ....
ldconfig
dpkg -iBE base/bash_*.deb || exit 6

# new dpkg
#
dpkg -iBE devel/libg++272_*.deb || exit 7
dpkg -iBE base/dpkg_*.deb  utils/dpkg-dev_*.deb

# perl
#
dpkg -iBE base/libgdbm1_*.deb devel/libgdbmg1_*.deb || exit 8
# paranoia says "run ldconfig now".
ldconfig
dpkg -iBE base/perl-base_*.deb || exit 9
dpkg -iBE interpreters/perl_*.deb

# strictly speaking, dpkg-ftp and dpkg-mountable are not essential to
# upgrade right now but they're both very useful.
dpkg -iBE base/dpkg-ftp_*.deb admin/dpkg-mountable_*.deb


# paranoia says to run this at the end
dpkg --configure --pending

# paranoia says: "run sync", so lets do it :-)
sync ; sync ; sync 
;;

c) #all packages in current dir

# first, build up a list of installed -dev packages so that we can
# remove them.  remove wg-15-locale too.
#
# this is necessary even on machines which aren't doing libc6
# development because libc5 can't be upgraded to latest version without
# removal of libc5-dev which also necessitates removal of other -dev
# packages like libdb1-dev and libdl1-dev if they are installed.

DEVPACKAGES=$( dpkg --get-selections | 
    grep -v dpkg-dev|
    grep -v deinstall | 
    cut -f1 |
    grep -- "-dev$\|-pic$\|-dbg$" )

dpkg --remove -B $DEVPACKAGES wg15-locale || exit 1

# now install the new versions of things.  Just the bare minimum to let
# the user safely run dselect for the rest of the upgrade.


# libc
#
dpkg -iBE ldso_*.deb libc5_*.deb libc6_*.deb \
    timezones_*.deb locales_*.deb || exit 2

# libreadline, ncurses, and bash
#
dpkg -iBE ncurses3.0_*.deb ncurses3.4_*.deb  || exit 3
dpkg -iBE libreadline2_*.deb  || exit 4
dpkg -iBE libreadlineg2_*.deb || exit 5

# paranoia says run ldconfig NOW. don't laugh, i've needed to do this on
# some libc5-libc6 upgrades. i know that the postinst scripts for the
# libs are supposed to do it but ....
ldconfig
dpkg -iBE bash_*.deb || exit 6

# new dpkg
#
dpkg -iBE libg++272_*.deb || exit 7
dpkg -iBE dpkg_*.deb  dpkg-dev_*.deb

# perl
#
dpkg -iBE libgdbm1_*.deb libgdbmg1_*.deb || exit 8
# paranoia says "run ldconfig now".
ldconfig
dpkg -iBE perl-base_*.deb || exit 9
dpkg -iBE perl_*.deb

# strictly speaking, dpkg-ftp and dpkg-mountable are not essential to
# upgrade right now but they're both very useful.
dpkg -iBE dpkg-ftp_*.deb dpkg-mountable_*.deb

# paranoia says to run this at the end
dpkg --configure --pending

# paranoia says: "run sync", so lets do it :-)
sync ; sync ; sync 
;;
esac  

# the user can now run dselect and select any -dev packages they want
# (and other packages too, of course :-)

more <<__EOF__

libc6 is now installed.  Now run dselect to upgrade the rest of your
system.  When that's done, reboot with "shutdown -r now" for the
utmp/wtmp wrapper functions in the upgraded libc5 to take effect.

BTW, if you aren't using it already, check out dselect's "mountable"
access method.  It's much faster than the standard "mounted" method, and
it logs everything that happens in /var/log/dpkg-mountable.  You'll want
to set "Allow overwriting repeated files?" to yes, and for extra speed
set "Enable MD5 checksumming?" to no.

If you are installing manually using dpkg, remember that all libc6 (g) 
libraries conflict with all the versions of their libc5 (non-g) 
counterparts prior to a certain version which placed libc5 libs in 
/usr/lib/libc5-compat.  This means that they conflict with your bo versions
of libc5-linked libraries, but not the hamm versions.  For example, if you are 
installing xlib6g, you should install xlib6 from hamm first before installing
xlib6g unless you have nothing that depend on xlib6 in which case you can safelyremove it.
 

Finally, remember to fix up wtmp and utmp, otherwise last and
who and sac etc wont work. here's what Miquel van Smoorenburg
<miquels@cistron.nl> had to say about this recently in debian-user
mailing list:

    > 1. You need to update ALL your packages to hamm
    > 2. Reboot if you haven't done that already
    > 3. You need to move the wtmp file and truncate the utmp file:
    >    cd /var/log
    >    mv wtmp wtmp.libc5
    >    touch wtmp
    >    cd /var/run
    >    cp /dev/null utmp
    > 4. You might want to reboot again to make sure
    > 
    > This is because the "struct utmp" and thus the utmp and wtmp
    > "databases" are different between libc5 and libc6

__EOF__
--cut here--



-- 
Proudly running Debian Linux! Linux vs. Windows is a no-Win situation....
Igor Grobman           igor@debian.org                 igor@digicron.com 



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: