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

*-* auto-upgrade from rex to hamm



     I believe it is desirable for debian to provide a painless
upgrade route from rex to hamm, without first upgrading to bo.  Last
month I experimented with a manual upgrade of a rex filesysem to hamm,
following Scott Ellis's Mini-HOWTO.  There were problems (see my
testing report of 12/18/97), but I was able to achieve a working hamm
system.

     I have tested Craig Sanders' autoup script to upgrade from bo to
hamm, and it worked flawlessly. When I tried to use this script to
upgrade from rex, I encountered a number of problems that do not occur
in bo.  I have modified the script to solve these problems.  A copy of
this modified script, updated to reflect v.10 of the original, is
attached.

     The first problem encountered in running the original script on a
rex system is replacing timezone with timezones.  timezone 7.48-3 in
rex is tagged as "Essential: yes" and "Priority: required", while the
version in bo is "Priority: required", but not essential.  dpkg
refuses to remove timezone 7.48-3 in favor of timezones.  The solution
is to "dpkg --force-remove-essential -r timezone" before installing
PKGS_LIBC6. 

     Similarly, xmanpages 3.2-1 (in rex) depends on xlib6-dev, so
xlib6-dev can not be removed until xmanpages is removed.  (This should
never have _deoended_ on xlib6-dev.  xmanpages 3.3-4 (in bo) corrects
this by making xmanpages _recommend_ xlib6-dev.

     rex includes ldso 1.8.5-1, and the upgrade replaces it with
ldso_1.9.6-2.  libc6_2.0.6-2, which is installed in the upgrade,
pre-depends on ldso (>= 1.8.10-1), so dpkg refuses to upgrade libc6
until the new ldso is configured.  The solution is to install ldso in
one dpkg command line, and libc6 in another, thus ensuring that ldso
is configured before trying to install libc6.

     perl 5.003.07-6 in rex conflicts with perl-base, so when dpkg
starts to install the perl-base, it wants to remove the old perl.  In
order to do so it must de-configure anything that depends on perl.
After perl-base is set up, dpkg cannot reconfigure these packages
because perl is not present.  The next command installs perl, but does
not configure the previously de-configured packages.  The solution was
to remove the exit-on-error code from the perl-base and perl
installation commands, and add "dpkg --configure --pending" following
the perl installation.

     This left two packages, perl-debug and perl-suid unconfigured
because they depend on perl (= 5.003.07-6).  The solution was to
remove those packages early in the script.

     Until such time as perl_5.004.04-4.deb is included in hamm, this
will not work on my rex system without patching the perl.postinst, due
to Bug#15854.  In this bug file the maintainer has provided a patch
for this postinst, which will be included in perl_5.004.04-4.deb.  The
effect of this bug apparently depends upon the history of perl
installation in the file system.  The problem lines in the postinst
attempt to remove certain supposedly empty directories, and the script
fails if these directories are no empty.  These directories are not
empty in my rex system, but do not exist in my bo system.

     *         *    Script Follows      *         *

#! /bin/sh

#autoup-rex - Script to upgrade a rex machine to hamm
#             based on Craig Sanders' script to upgrade bo==>hamm
  
DPKG=$(which dpkg)
LDCONFIG=$(which ldconfig)

# uncomment for debugging
#set -x
#DPKG="echo dpkg"
#LDCONFIG="echo LDCONFIG"

# upgrade a libc5 (rex) 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 
#v0.6: 1998-01-11 (Craig Sanders)
#   - restructured code to avoid code duplication. 
#   - cleaned up a few things
#   - prints advisory notes telling user what's happening.
#   - added some more instructions on what to do about development packages.
#   - added code to guess some obvious locations for the mirror, otherwise
#     ask user.
#v0.7: 1998-01-11 (Craig Sanders)
#   - uh oh.  i hard-coded in binary-i386.  quick...better release another
#     version before James notices.
#v0.8: 1998-01-11 (Craig Sanders)
#   - added libpthread0 to the remove list.
#   - fixed PKGS_LIBGPP (i mistyped it as PKGS_GPP)
#   - some old version of perl's postrm didn't delete a .packlist file
#     from /usr/lib/perl5/i486-linux/5.003/auto/Mail/.packlist.  check for
#     it and delete if found before installing perl.
#v0.9: 1998-01-13 (Craig Sanders)
#   - added datadumper and libnet-perl to be installed/upgraded before
#     dpkg-ftp.  Thanks, Igor.
#   - changed ` ... ` backticks to $( ... ) for DPKG & LDCONFIG
#     variables at top of script.
#v0.9-rex: 1998-01-15 (Bob Hilliard) <hilliard@metrolink.net>
#   - modified to fix errors encountered when upgrading a rex filesystem:
#     - force removal of essential package timezone before installing 
#       timezones  
#     - remove xmanpages (if they are present before removing xlib6-dev.)
#     - remove perl-suid and perl-debug before upgrading perl-base and perl.)
#     - install ldso with a separate command from installing libc6 so ldso 
#       will be setup before libc6 is installed.
#     - remove exit-on-error from installation of perl-base and perl
#     - configure --pending after perl installation.
#v0.10-rex: 1998-01-16 (Bob Hilliard)
#     - upstream v.10 changes:
#       - added xslib, splay ,and boot-floppies to the remove list.
#       - added "../$ARCH" to $TRY.
#     - changed "$i" to "$DEFAULT" in message about mirror location.
#
# TODO: (probably by somebody else.  this script is mostly good enough imo)
#   - this script _still_ needs more error checking :-)

ARCH="binary-$(dpkg --print-installation-architecture)"

PKGS_LDSO="base/ldso_*.deb"
PKGS_LIBC6="base/libc5_*.deb base/libc6_*.deb base/timezones_*.deb \
admin/locales_*.deb"
PKGS_NCURSES="libs/ncurses3.0_*.deb base/ncurses3.4_*.deb"
PKGS_LIBRL="oldlibs/libreadline2_*.deb"
PKGS_LIBRLG="base/libreadlineg2_*.deb"
PKGS_BASH="base/bash_*.deb"
PKGS_LIBGPP="devel/libg++272_*.deb"
PKGS_DPKG="base/dpkg_*.deb utils/dpkg-dev_*.deb"
PKGS_LIBGDBM="base/libgdbm1_*.deb devel/libgdbmg1_*.deb"
PKGS_PERLBASE="base/perl-base_*.deb"
PKGS_PERL="interpreters/perl_*.deb"
PKGS_MOREDPKG="interpreters/data-dumper_*.deb interpreters/libnet-perl_*.deb \
               base/dpkg-ftp_*.deb admin/dpkg-mountable_*.deb"
echo $PKGS_PERL

cat <<__EOF__
This script will install the packages necessary to ensure a safe upgrade
to hamm.  

You need to either have a local or remote mirror mounted, or have the
latest versions of the following packages from hamm available in the
current directory:

    ldso, libc5, libc6, timezones, locales, ncurses3.0, ncurses3.4,
    libreadline2, libreadlineg2, bash, libg++272, dpkg, dpkg-dev,
    dpkg-ftp, dpkg-mountable, libgdbm1, libgdbmg1, perl-base, and perl.

If you are using a mirror, press 'm'.
__EOF__

echo -n "if you have the files in the current dir, press 'c': (m/c) "

read answer

case "$answer" in
    m|M)
        # local mirror available

        # ask where the mirror is (this could do with some error checking)
        echo 
        echo "enter the full path to your local mirror of debian: "
        echo "e.g. /debian/dists/unstable/main/$ARCH/"
        echo 

        TRY="/debian/dists/unstable/main/$ARCH ~ftp/debian/dists/unstable/main/$ARCH ../$ARCH"
        for i in $TRY ; do
            if [ -d $i ] ; then
                DEFAULT=$i
            fi
        done 

        [ -n "$DEFAULT" ] && echo or just hit enter to use "$DEFAULT".

        read DM

        [ -z "$DM" ] && DM=$DEFAULT

        SEDSCRIPT="s:\([^ /]*/\):$DM/\1:g"
        ;;

    c|C)
        # current directory
        SEDSCRIPT='s:[^ /]*/::g'
        ;;
esac

echo "building list of package filenames to install..."

# convert PKGS_ variables to correct directory location
PKGS_LDSO=$( echo $PKGS_LDSO | sed -e "$SEDSCRIPT" )
PKGS_LIBC6=$( echo $PKGS_LIBC6 | sed -e "$SEDSCRIPT" )
PKGS_NCURSES=$( echo $PKGS_NCURSES | sed -e "$SEDSCRIPT" )
PKGS_LIBRL=$( echo $PKGS_LIBRL | sed -e "$SEDSCRIPT" )
PKGS_LIBRLG=$( echo $PKGS_LIBRLG | sed -e "$SEDSCRIPT" )
PKGS_BASH=$( echo $PKGS_BASH | sed -e "$SEDSCRIPT" )
PKGS_LIBGPP=$( echo $PKGS_LIBGPP | sed -e "$SEDSCRIPT" )
PKGS_DPKG=$( echo $PKGS_DPKG | sed -e "$SEDSCRIPT" )
PKGS_LIBGDBM=$( echo $PKGS_LIBGDBM | sed -e "$SEDSCRIPT" )
PKGS_PERLBASE=$( echo $PKGS_PERLBASE | sed -e "$SEDSCRIPT" )
PKGS_PERL=$( echo $PKGS_PERL | sed -e "$SEDSCRIPT" )
PKGS_MOREDPKG=$( echo $PKGS_MOREDPKG | sed -e "$SEDSCRIPT" )

echo $PKGS_PERL

echo "checking that all needed files are available..."
# sanity check that we can find the packages

ALLPKGS="$PKGS_LDSO $PKGS_LIBC6 $PKGS_NCURSES $PKGS_LIBRL $PKGS_LIBRLG \
         $PKGS_BASH $PKGS_LIBGPP $PKGS_DPKG $PKGS_LIBGDBM $PKGS_PERLBASE \
         $PKGS_PERL $PKGS_MOREDPKG"

for i in $ALLPKGS ; do
    echo -n "$(basename $i) "
    if [ ! -f $i ] ; then
        echo 
        echo "Can't find $i!"
        echo aborting upgrade.
        exit 100
    fi
done

echo 
echo 
echo "all needed files found." 
echo
echo "removing incompatible packages before starting installation."

# First get rid of essential package timezone to permit installation of 
# replacement timezones.
# I don't like forcing dpkg, but I can see no alternative.  timezone
# is required, but shouldn't really be "essential", and this was
# corrected in bo.

echo
echo "removing package timezone to permit replacing it with timezones"
echo "if this script fails before it installs timezones, you should"
echo "reinstall timezone at the next opportunity."
echo

$DPKG --force-remove-essential -r timezone 

# Now get rid of incompatible packages if installed.
if [ -d /usr/X11R6/man/man3 ]; then
    echo "removing package xmanpages which prevents removal of xlib6-dev"
    $DPKG -r xmanpages
    PKGS_RM="xmanpages "
fi

if [ -e /usr/bin/suidperl ]; then
    echo "removing package perl-suid which is incompatible with the upgraded"
    echo "version of perl to be installed."
    $DPKG -r perl-suid
    PKGS_RM="$PKGS_RM  perl-suid "
fi

if [ -e /usr/bin/debugperl ]; then
    echo "removing package perl-debug which is incompatible with the upgraded"
    echo "version of perl to be installed."
    $DPKG -r perl-debug
    PKGS_RM="$PKGS_RM  perl-debug "
fi


# Now we start the install

# 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\|deinstall" | 
    cut -f1 |
    grep -- "-dev$\|-pic$\|-dbg$" )

OTHER="wg15-locale libpthread0 xslib splay boot-floppies"

echo 
echo "removing development packages."
$DPKG --remove -B $DEVPACKAGES $OTHER || 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.

echo 
echo "installing packages."

# libc
#
$DPKG -iBE $PKGS_LDSO || exit 2
$DPKG -iBE $PKGS_LIBC6 || exit 2

# libreadline, ncurses, and bash
#
$DPKG -iBE $PKGS_NCURSES || exit 3
$DPKG -iBE $PKGS_LIBRL || exit 4
$DPKG -iBE $PKGS_LIBRLG || 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 $PKGS_BASH || exit 6

# new dpkg
#
$DPKG -iBE $PKGS_LIBGPP || exit 7
$DPKG -iBE $PKGS_DPKG

# perl
#
$DPKG -iBE $PKGS_LIBGDBM || exit 8
# paranoia says "run ldconfig now".
$LDCONFIG

# Unlike a bo installation, in rex, dpkg removes perl when installing
# perl-base, and must de-configure many packages (9 on my system)
# first.  Since these packages can not be re-configured until perl is
# installed and configured, the following line will always cause an
# error, therefore the "|| exit 9" is commented out in this line.
# stdout and stderr are redirected to /dev/null for the next two 
# commands to hide the potentially alarming error messages from the user.

$DPKG -iBE $PKGS_PERLBASE &>/dev/null # || exit 9

[ -e /usr/lib/perl5/i486-linux/5.003/auto/Mail/.packlist ] && rm -f /usr/lib/perl5/i486-linux/5.003/auto/Mail/.packlist

$DPKG -iBE  $PKGS_PERL &>/dev/null # || exit 9

# When perl is setup, it should(?) configure the de-configured
# packages.  However, paranoia says to comment out the "|| exit 9"
# and run configure. 

$DPKG --configure --pending
cat<<EOF

    I have tried to remove any packages that would be broken by the
upgrade, but I may have missed some.  If any "Errors were encountered
while processing:" messages appear above, those packages must be
removed or replaced with their equivalent from hamm.  
EOF
if [ -n "$PKGS_RM" ]; then
echo "     The following incompatible packages have been removed, and should"
echo "be replaced with their equivalent from hamm:"
echo "$PKGS_RM"
fi
echo
echo "press [ENTER] to continue"
read

# strictly speaking, dpkg-ftp and dpkg-mountable are not essential to
# upgrade right now but they're both very useful.
$DPKG -iBE $PKGS_MOREDPKG


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

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


# FINISHED!

# 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.

All development packages (-dev, -dbg, and -pic) have been removed
during this upgrade procedure due to conflicts between libc5 and libc6
versions.  You will need to re-install any development packages you
need.  

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__


--
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: