#!/bin/sh
#
# Update squashfs -- assumes you start with a Hardy 8.04.1 desktop,
#   but it should work even if you have already updated it.
#

if [ ! -d sqfs ] ; then
  echo "Cannot find squashfs (sqfs directory)"
  exit 1
fi
chroot sqfs /bin/sh
mount -t proc none /proc/
mount -t sysfs non /sys/
export HOME=/root

# remove packages
apt-get remove --purge `dpkg-query -W --showformat '${Package}\n' | grep language-pack | egrep -v '\-en'`
apt-get remove --purge `dpkg-query -W --showformat '${Package}\n' | grep openoffice\.org-`
apt-get remove --purge amarok dictionaries-common

cat >/etc/resolv.conf <<EOF
search sibbald.com
nameserver 192.168.68.254
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF

cat >/etc/apt/sources.list <<EOF
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ hardy universe
deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
deb http://archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-security main restricted
deb http://archive.ubuntu.com/ubuntu/ hardy-security universe
deb http://archive.ubuntu.com/ubuntu/ hardy-security multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse
EOF
apt-get update
apt-get upgrade

# Add new packages
apt-get install openssh-server subversion kdetoys kicker-applets kgpg \
  gftp firefox sg3-utils
apt-get install flashplugin-nonfree aircrack-ng g++ nvidia-glx-new \
  gfxboot syslinux mtools
apt-get install sshfs kile kate lsscsi m4 mtx nfs-common \
  nfs-kernel-server patch \
  squashfs-tools strace sg3-utils screen scsiadd system-tools-backends \
  telnet dpkg traceroute usbutils whois apt-file autofs busybox \
  chkrootkit clamav dmidecode unrar

apt-get install linux-generic linux-headers-generic

# Add held back packages
apt-get install bind9-host dnsutils libbind9-30 libisccc30 libisccfg30 \
  linux-generic linux-headers-generic linux-image-generic \
  linux-restricted-modules-generic ssl-cert

# Remove old kernel
apt-get remove linux-headers-2.6.24-22 linux-headers-2.6.24-22-generic \
  linux-image-2.6.24-22-generic linux-restricted-modules-2.6.24-22-generic \
  linux-restricted-modules-2.6.24-22-generic linux-ubuntu-modules-2.6.24-22-generic

cd /
dpkg-query -W --showformat='${Package} ${Version}\n' >filesystem.manifest

apt-get clean
rm -rf /tmp/*
rm -f /etc/hosts /etc/resolv.conf
umount /proc/
umount /sys/
exit
cp sqfs/filesystem.manifest .
rm -f sqfs/filsystem.manifest

echo "Warning!!!! At this point, it may be better to reboot, since"
echo " upgrading packages may have restarted some daemons such as"
echo " cups, which uses sqfs/proc.  If you thn try to pack the sqfs"
echo " you will get lots of errors reference /proc.  Rebooting"
echo " resolves this problem."
echo " "
