autoup.sh
I noticed that there is still an un-fixed version of autup.sh floating
around, especially on #debian.
Here is a new and improved version of autoup.sh, hopefully it does the
right thing with regards to selecting an ftp program. Apparently
there are some other issues as well, but I'm not sure about other things.
--------
#! /bin/sh
# upgrade a libc5 (bo) machine to libc6 (hamm).
#
# $Id: autoup.sh,v 0.21 1998/02/14 03:09:05 root Exp root $
#
# 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:
# see autoup.changelog
#
# The latest version of this script can always be found at:
# http://www.taz.net.au/autoup/autoup/
# and at:
# http://csanders.vicnet.net.au/autoup/
#
# please check that you have the latest version before running this
# script.
# misc tweakable variables
DPKG="$(which dpkg)"
LDCONFIG=$(which ldconfig)
# uncomment for debugging
#set -x
#DPKG="echo dpkg"
#LDCONFIG="echo ldconfig"
DPKG_ARGS="-iBE --force-overwrite"
DATE=$(date +%m%d-%T)
ARCH="binary-$(dpkg --print-installation-architecture)"
FTP_SITE="ftp.debian.org"
FTP_DIR="debian/hamm/hamm/$ARCH"
#FTP_SITE="ftp.infodrom.north.de"
#FTP_DIR="pub/debian/hamm/hamm/$ARCH"
# ftp functions
function ftpftp ()
{
for file in $ALLPKGS; do
mkdir -p `dirname $file`
done
ftp -n -i <<EOF
verbose
open $FTP_SITE
user anonymous libc5@libc6
hash
cd $FTP_DIR
pwd
mget $PKGS_LDSO
mget $PKGS_LIBC6
mget $PKGS_NCURSES
mget $PKGS_LIBRL
mget $PKGS_LIBRLG
mget $PKGS_BASH
mget $PKGS_LIBGPP
mget $PKGS_DPKG
mget $PKGS_LIBGDBM
mget $PKGS_PERLBASE
mget $PKGS_PERL
mget $PKGS_MOREDPKG
EOF
}
function ncftpftp ()
{
for file in $ALLPKGS; do
echo -n "Fetching file: /$FTP_DIR/$file... "
$FTP $FTP_SITE:/$FTP_DIR/$file
echo "done."
if [ -e `basename $file` ]; then
mkdir -p `dirname $file`
mv -f `basename $file` `dirname $file`
else
ERROR_FILES="$ERROR_FILES $file"
fi
done
}
# package variables
PKGS_LDSO="base/ldso_*.deb"
PKGS_LIBC5="oldlibs/libc5_*.deb"
PKGS_LIBC6="base/libc6_*.deb base/timezones_*.deb admin/locales_*.deb"
PKGS_NCURSES="oldlibs/ncurses3.0_*.deb base/ncurses3.4_*.deb"
PKGS_LIBRL="oldlibs/libreadline2_*.deb"
PKGS_LIBRLG="base/libreadlineg2_*.deb"
PKGS_BASH="base/bash_*.deb"
PKGS_LIBGPP="libs/libg++272_*.deb"
PKGS_DPKG="base/dpkg_*.deb utils/dpkg-dev_*.deb"
PKGS_LIBGDBM="oldlibs/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"
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"
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'.
If you need to download the files via FTP, press 'f'.
__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"
;;
f|F)
# Download the files via FTP
# go from best to worst here
FTP=`type -p ncftp`
# FTP=`type -p wget`
# FTP=`type -p lftp`
# It would be cool if someone wrote some functions for wget and lftp
FTP=`basename $FTP`
if [ -x "$FTP" ] ; then
FTPFUNC="$FTP"ftp
else
FTPFUNC=ftpftp
fi
echo "Using $FTP to download files"
# this meens that functions must be like such: lftpftp, ftpftp
# ncftpftp, etc..
# Find download directory
echo
echo "Where do you want the files to be stored? "
echo
TRY="/var/lib/dpkg/methods/ftp /tmp"
for i in $TRY ; do
if [ -d $i -a -z "$DEFAULT" ] ; 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"
ERROR_FILES=""
# Fetch files
cd $DM
echo "Fetching packages from: $FTP_SITE"
$FTPFUNC
# Fetch files not in FTP_DIR
# libc5_*.deb ncurses3.0_*.deb libg++272_*.deb
if [ -n "$ERROR_FILES" ]; then
echo
echo "Could not download the following files:"
echo $ERROR_FILES
echo
echo "you have to download these manually."
else
echo
echo "All needed files downloaded, starting install..."
echo
fi
;;
# ---------- end ftp area
c|C)
# current directory
SEDSCRIPT='s:[^ /]*/::g'
;;
esac
echo
echo
echo "building list of package filenames to install..."
# convert PKGS_ variables to correct directory location
PKGS_LDSO=$( echo "$PKGS_LDSO" | sed -e "$SEDSCRIPT" )
PKGS_LIBC5=$( echo "$PKGS_LIBC5" | 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 "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
#
# libc5
#
echo "installing libc5."
$DPKG $DPKG_ARGS $PKGS_LIBC5 || exit 2
#
# if this is a buzz system, then first upgrade dpkg to version 1.4.0.8
#
DPKG_VER=$(dpkg -s dpkg | grep Version: | awk '{print $2}')
DPKG_MINOR=$(echo $DPKG_VER | awk -F"." '{print $2}')
if [ $DPKG_MINOR -lt 4 ] ; then
BO_DPKG="base/dpkg_*.deb"
BO_SEDSCRIPT=$(echo "$SEDSCRIPT" | \
sed -e 's/unstable/stable/g' -e 's/hamm/bo/g')
BO_DPKG=$(echo $BO_DPKG | sed -e "$BO_SEDSCRIPT")
if [ ! -f $BO_DPKG ] ; then
echo "can't find $BO_DPKG, which is needed to upgrade your buzz system to hamm"
exit 2
fi
echo "installing dpkg from bo."
$DPKG $DPKG_ARGS $BO_DPKG || exit 2
fi
RMFILE="removed-$DATE"
# Now we start the install
# 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.
$DPKG -l timezone | grep -q "^ii" && TIMEZONE=1
if [ "$TIMEZONE" = "1" ] ; then
echo
echo "Removing package timezone to permit replacing it with timezones."
echo
$DPKG --force-remove-essential -r timezone
fi
# Now build list of incompatible packages to be removed if installed.
RMPKGS="xmanpages perl-suid perl-debug wg15-locale libpthread0 xslib
splay boot-floppies localebin"
RMGREP=$(echo "$RMPKGS" | xargs echo | sed -e 's/ /\\\|/g')
PKGS_RM=$(dpkg -l | grep "^ii" | grep -w "$RMGREP" | awk '{print $2}')
# build up a list of installed -dev packages so that we can remove them.
#
# 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$" )
# don't bother running 'dpkg -r' if there's nothing to remove.
RM_LIST="$DEV_PACKAGES $PKGS_RM"
if [ ! "$RM_LIST" = " " ] ; then
# log what gets removed.
echo "Packages Removed by autopup script on $DATE :" > $RMFILE
echo "Development packages: " >> $RMFILE
echo "$DEVPACKAGES" >> $RMFILE
echo "Other packages that were incompatible with the upgrade:" >> $RMFILE
echo -n "timezone " >> $RMFILE
echo $PKGS_RM >> $RMFILE
# and finally remove them.
echo
echo "removing incompatible and development packages."
$DPKG --remove -B $RM_LIST || exit 1
fi
# 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 $DPKG_ARGS $PKGS_LDSO || exit 2
$DPKG $DPKG_ARGS $PKGS_LIBC6 || exit 2
# libreadline, ncurses, and bash
#
$DPKG $DPKG_ARGS $PKGS_NCURSES || exit 3
$DPKG $DPKG_ARGS $PKGS_LIBRL || exit 4
$DPKG $DPKG_ARGS $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 $DPKG_ARGS $PKGS_BASH || exit 6
# new dpkg
#
$DPKG $DPKG_ARGS $PKGS_LIBGPP || exit 7
$DPKG $DPKG_ARGS $PKGS_DPKG
# perl
#
$DPKG $DPKG_ARGS $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.
$DPKG $DPKG_ARGS $PKGS_PERLBASE # || 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 $DPKG_ARGS $PKGS_PERL # || 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. exit at this point if there are packages which failed to
# configure.
$DPKG --configure --pending || exit 9
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.
press [ENTER] to continue"
EOF
read
# strictly speaking, dpkg-ftp and dpkg-mountable are not essential to
# upgrade right now but they're both very useful.
$DPKG $DPKG_ARGS $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) and a number of other
incompatible packages have been removed during this upgrade procedure
due to conflicts between libc5 and libc6 versions. A list of the
removed packages are in file $RMFILE in this directory.
You will have to re-install any of these 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__
--------------
--
David Welton http://www.efn.org/~davidw
Debian GNU/Linux - www.debian.org
--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: