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

Corrected Cheap*bytes autoup.sh script



Upon request, here's the updated script sent to me by Cheap*Bytes:

[For anyone reading this in the archives:

The original Official 2.0 CD-Rom distributed by Cheap*Bytes contained the
cd_autoup.sh file included by Debian with the distribution.  The script
was broken at the time the dist. was set--several libraries were not in
locations the script expected.  This updated script now properly locates
the needed libraries to do an out-of-the-box upgrade.  In addition, the
original cd_autoup.sh required the user to cd several layers down into the
CD before executing the script.  The modified script does not have this
requirment and merely requests the location of the cdrom's mount point.]

#! /bin/sh

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

# The cd version of this script is designed to run from from a top level
# directory of the Official Debian 2.0 CD without any input from the user
# execept as required by dpkg installation scripts.

# $Id: cd_autoup.sh,v 0.5 1998/07/01 21:46:13 bob Exp bob $
#
# derived from Craig Sanders' <cas@taz.net.au> autoup.sh script

# Original Author: Craig Sanders <cas@taz.net.au>
#         and many others.  see changelog for details.

# Modified for use on the Official CD by Bob Hilliard <hilliard@flinet.com>
# 
# Copyright Status: This script is hereby placed in the public domain
#
# Revision History:
#   see autoup.changelog

# 0.1 - 1988-06-29 02:53:18
#     - removed all ftp and most interactive stuff
#
# 0.2 - 1998/07/01 02:10:39
#     - Commented out debugging statments; typo in final message
#
# 0.3 - 1998/07/01 03:37:27
#     - minor changes in messages

# 0.4 - 1998/07/01 19:40
#     - added note about running from CD

# 0.5 - 1998/07/01 21:46:13
#     - updated changelog, minor changes in text
# misc tweakable variables

#     - 1998/08/15 19:15:00
#     - Changes done by CheapBytes to fix original problems in script

while [ 1 ]
do
	echo "Where is the CD-ROM mounted (i.e. /cdrom)"
	read mountpoint
 	break
done

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)"


# 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="oldlibs/libg++27_*.deb libs/libg++272_*.deb \
             base/libstdc++2.8_*.deb"
PKGS_DPKG="base/dpkg_*.deb utils/dpkg-dev_*.deb"
PKGS_SLANG="oldlibs/slang0.99.34_*.deb base/slang0.99.38_*.deb"
PKGS_LIBGDBM="oldlibs/libgdbm1_*.deb base/libgdbmg1_*.deb"
PKGS_PERLBASE="base/perl-base_*.deb"
PKGS_PERL="interpreters/perl_*.deb"
PKGS_MOREDPKG="interpreters/data-dumper_*.deb base/libnet-perl_*.deb \
               base/dpkg-ftp_*.deb admin/dpkg-mountable_*.deb"
PKGS_NETBASE="net/netbase_*.deb"
PKGS_NETSTD="net/netstd_*.deb"

ALLPKGS="$PKGS_LDSO $PKGS_LIBC5 $PKGS_LIBC6 $PKGS_NCURSES $PKGS_LIBRL
         $PKGS_LIBRLG $PKGS_BASH $PKGS_LIBGPP $PKGS_DPKG $PKGS_SLANG 
         $PKGS_LIBGDBM $PKGS_PERLBASE $PKGS_PERL $PKGS_MOREDPKG 
         $PKGS_NETBASE $PKGS_NETSTD"

        DM=$mountpoint/debian/main/$ARCH

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



# 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_SLANG=$( echo "$PKGS_SLANG" | 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" )
PKGS_NET=$( echo "$PKGS_NET" | sed -e "$SEDSCRIPT" )

# sanity check that we can find the packages

ALLPKGS=$( echo "$ALLPKGS" | sed -e "$SEDSCRIPT" )

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=./dpkg*
    echo "installing dpkg from bo."
    $DPKG $DPKG_ARGS $BO_DPKG  || exit 2
fi


RMFILE="/root/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="$DEVPACKAGES $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

# slang
$DPKG $DPKG_ARGS $PKGS_SLANG || exit 7

# 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.  Some "Errors were encountered
while processing:" messages were displayed earlier; they were
harmless.  If any such messages are visible now, make a note of the
package names, since they 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

# and now netbase and netstd
$DPKG $DPKG_ARGS $PKGS_NETBASE
$DPKG $DPKG_ARGS $PKGS_NETSTD

# 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.  It is recommended that you run the access, update, install,
and configure modules of dselect initially to just upgrade all
installed packages.  After that you may use the select and install
modules to install additional packages if necessary.

Keep in mind that when dpkg/dselect upgrades many packages (and almost
every package on your system will be upgraded in this step), it is
usually necessary to repeat the install and configure steps several
times (perhaps four or five times) before the whole system is
configured.  The apt access method for dselect improves this
considerably.

If you have apt installed (see discussion under "Upgrading using
apt"), the apt access method should be selected in dselect's Access
module.  Apt is much faster than any of the older dselect access
methods.  When that's done, reboot with "shutdown -r now" for the
utmp/wtmp wrapper functions in the upgraded libc5 to take effect.

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 the file "/root/removed-<today's date>".  You
will have to install the libc6 equivalents of any of these packages
that you need.  If you will be doing any libc5 development work, you
will also want to re-install (from the old-libs directory) any of these
libc5 packages you need.

Finally, remember to fix up wtmp and utmp, otherwise last and
who and sac, etc. won't 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

     You now have a Debian Gnu/Linux v2.0 system.  Have fun!

__EOF__





Reply to: