#! /bin/sh
#
# file: install-to-zip       George Moody (george@hstbme.mit.edu)
#                            30 January 1998
#
# This script creates a Linux root partition on a Zip disk.  Please read it
# and make any changes needed for your setup before running it!

# Most of this script is entirely generic, but it was written to support
# bootstrapping the installation of Linux on a Toshiba Libretto.  If you
# are using it for some other purpose, skip to "Libretto--specific setup"
# near the end of this script and comment out any unneeded commands.

# Any other files that you wish to install in addition to those contained
# within the RPMs listed below should be left in the TMPZIP directory.  This
# script will copy the entire TMPZIP file tree onto the Zip disk after the
# RPMs have been installed.  (About 30 Mb of space will be available for these
# files on the Zip disk.)
TMPZIP=/tmp/libretto

# Run this script from the directory that contains the RPMs.
#       mount /cdrom
#       cd /cdrom/RedHat/RPMS
# If you don't have the Red Hat Linux 5.0 CD-ROMs, get the RPMs from
# Red Hat's FTP site or one of its mirrors, and collect them in the current
# directory.

# Prepare the Zip disk by creating partitions using fdisk, to obtain the
# following partition table:

# Disk /dev/sdc: 64 heads, 32 sectors, 96 cylinders
# Units = cylinders of 2048 * 512 bytes
#
#    Device Boot   Begin    Start      End   Blocks   Id  System
# /dev/sdc1            1        1       81    82928   83  Linux native
# /dev/sdc2           82       82       96    15360   82  Linux swap

# (Replace the 'c' in '/dev/sdc...' with whatever is appropriate -- use
# 'dmesg | more' to read the startup messages to figure out what that is.)

# Format the root and swap partitions thus:
#       mke2fs -c /dev/sdc1
#       mkswap -c /dev/sdc2 15360
 
# Mount the root partition on /zip:
#       if [ ! -d /zip ]; then mkdir /zip; fi
#       mount /dev/sdc1 /zip -t ext2        # edit this command!!

# If necessary, create an empty directory for rpm's use:
if [ ! -d /zip/var/lib/rpm ]; then mkdir -p /zip/var/lib/rpm; fi

rpm --root /zip -i -h -v --nodeps --noscripts rhs-hwdiag-*
rpm --root /zip -i -h -v --nodeps --noscripts basesystem-*
rpm --root /zip -i -h -v --nodeps --noscripts python-1*
rpm --root /zip -i -h -v --nodeps --noscripts pythonlib-*
rpm --root /zip -i -h -v --nodeps --noscripts cabaret-*
rpm --root /zip -i -h -v --nodeps --noscripts ldconfig-*
rpm --root /zip -i -h -v --nodeps --noscripts chkconfig-*
rpm --root /zip -i -h -v --nodeps --noscripts mktemp-*
rpm --root /zip -i -h -v --nodeps --noscripts setup-*
rpm --root /zip -i -h -v --nodeps --noscripts setuptool-*
rpm --root /zip -i -h -v --nodeps --noscripts pamconfig-*
rpm --root /zip -i -h -v --nodeps --noscripts filesystem-*
rpm --root /zip -i -h -v --nodeps --noscripts MAKEDEV-*
rpm --root /zip -i -h -v --nodeps --noscripts SysVinit-*
rpm --root /zip -i -h -v --nodeps --noscripts ash-*
rpm --root /zip -i -h -v --nodeps --noscripts at-*
rpm --root /zip -i -h -v --nodeps --noscripts bash-*
rpm --root /zip -i -h -v --nodeps --noscripts bc-*
rpm --root /zip -i -h -v --nodeps --noscripts bdflush-*
rpm --root /zip -i -h -v --nodeps --noscripts bootpc-*
rpm --root /zip -i -h -v --nodeps --noscripts binutils-*
rpm --root /zip -i -h -v --nodeps --noscripts cpio-*
rpm --root /zip -i -h -v --nodeps --noscripts cracklib-dicts-*
rpm --root /zip -i -h -v --nodeps --noscripts crontabs-*
rpm --root /zip -i -h -v --nodeps --noscripts dev-*
rpm --root /zip -i -h -v --nodeps --noscripts dhcpcd-*
rpm --root /zip -i -h -v --nodeps --noscripts diffutils-*
rpm --root /zip -i -h -v --nodeps --noscripts e2fsprogs-1*
rpm --root /zip -i -h -v --nodeps --noscripts ed-*
rpm --root /zip -i -h -v --nodeps --noscripts eject-*
rpm --root /zip -i -h -v --nodeps --noscripts etcskel-*
rpm --root /zip -i -h -v --nodeps --noscripts file-*
rpm --root /zip -i -h -v --nodeps --noscripts fileutils-*
rpm --root /zip -i -h -v --nodeps --noscripts findutils-*
rpm --root /zip -i -h -v --nodeps --noscripts gawk-*
rpm --root /zip -i -h -v --nodeps --noscripts gdbm-1*
rpm --root /zip -i -h -v --nodeps --noscripts getty_ps-*
rpm --root /zip -i -h -v --nodeps --noscripts gpm-1*
rpm --root /zip -i -h -v --nodeps --noscripts grep-*
rpm --root /zip -i -h -v --nodeps --noscripts groff-1*
rpm --root /zip -i -h -v --nodeps --noscripts gzip-*
rpm --root /zip -i -h -v --nodeps --noscripts hdparm-*
rpm --root /zip -i -h -v --nodeps --noscripts info-*
rpm --root /zip -i -h -v --nodeps --noscripts initscripts-*
rpm --root /zip -i -h -v --nodeps --noscripts isapnptools-*
rpm --root /zip -i -h -v --nodeps --noscripts kbd-*
rpm --root /zip -i -h -v --nodeps --noscripts kbdconfig-*
rpm --root /zip -i -h -v --nodeps --noscripts kernel-2*
rpm --root /zip -i -h -v --nodeps --noscripts kernel-modules-*
rpm --root /zip -i -h -v --nodeps --noscripts ld.so-*
rpm --root /zip -i -h -v --nodeps --noscripts less-*
rpm --root /zip -i -h -v --nodeps --noscripts libc-*
rpm --root /zip -i -h -v --nodeps --noscripts glibc-2*
rpm --root /zip -i -h -v --nodeps --noscripts libg++-2*
rpm --root /zip -i -h -v --nodeps --noscripts libtermcap-2*
rpm --root /zip -i -h -v --nodeps --noscripts lilo-*
rpm --root /zip -i -h -v --nodeps --noscripts logrotate-*
rpm --root /zip -i -h -v --nodeps --noscripts losetup-*
rpm --root /zip -i -h -v --nodeps --noscripts mailcap-*
rpm --root /zip -i -h -v --nodeps --noscripts mailx-*
rpm --root /zip -i -h -v --nodeps --noscripts man-1*
rpm --root /zip -i -h -v --nodeps --noscripts mkinitrd-*
rpm --root /zip -i -h -v --nodeps --noscripts mingetty-*
rpm --root /zip -i -h -v --nodeps --noscripts modutils-*
rpm --root /zip -i -h -v --nodeps --noscripts mount-*
rpm --root /zip -i -h -v --nodeps --noscripts mouseconfig-*
rpm --root /zip -i -h -v --nodeps --noscripts mt-st-*
rpm --root /zip -i -h -v --nodeps --noscripts ncompress-*
rpm --root /zip -i -h -v --nodeps --noscripts ncurses-1*
rpm --root /zip -i -h -v --nodeps --noscripts net-tools-*
rpm --root /zip -i -h -v --nodeps --noscripts newt-0*
rpm --root /zip -i -h -v --nodeps --noscripts passwd-*
rpm --root /zip -i -h -v --nodeps --noscripts pam-*
rpm --root /zip -i -h -v --nodeps --noscripts pcmcia-cs-*
rpm --root /zip -i -h -v --nodeps --noscripts procmail-*
rpm --root /zip -i -h -v --nodeps --noscripts procps-1*
rpm --root /zip -i -h -v --nodeps --noscripts psmisc-*
rpm --root /zip -i -h -v --nodeps --noscripts pwdb-*
rpm --root /zip -i -h -v --nodeps --noscripts quota-*
rpm --root /zip -i -h -v --nodeps --noscripts readline-2*
rpm --root /zip -i -h -v --nodeps --noscripts redhat-release-*
rpm --root /zip -i -h -v --nodeps --noscripts rootfiles-*
rpm --root /zip -i -h -v --nodeps --noscripts rpm-2*
rpm --root /zip -i -h -v --nodeps --noscripts sed-*
rpm --root /zip -i -h -v --nodeps --noscripts setconsole-*
rpm --root /zip -i -h -v --nodeps --noscripts setserial-*
rpm --root /zip -i -h -v --nodeps --noscripts sendmail-8*
rpm --root /zip -i -h -v --nodeps --noscripts shadow-utils-*
rpm --root /zip -i -h -v --nodeps --noscripts sh-utils-*
rpm --root /zip -i -h -v --nodeps --noscripts slang-0*
rpm --root /zip -i -h -v --nodeps --noscripts stat-*
rpm --root /zip -i -h -v --nodeps --noscripts sysklogd-*
rpm --root /zip -i -h -v --nodeps --noscripts tar-*
rpm --root /zip -i -h -v --nodeps --noscripts tcsh-*
rpm --root /zip -i -h -v --nodeps --noscripts termcap-*
rpm --root /zip -i -h -v --nodeps --noscripts textutils-*
rpm --root /zip -i -h -v --nodeps --noscripts time-*
rpm --root /zip -i -h -v --nodeps --noscripts timeconfig-*
rpm --root /zip -i -h -v --nodeps --noscripts tmpwatch-*
rpm --root /zip -i -h -v --nodeps --noscripts util-linux-*
rpm --root /zip -i -h -v --nodeps --noscripts vim-4*
rpm --root /zip -i -h -v --nodeps --noscripts vixie-cron-*
rpm --root /zip -i -h -v --nodeps --noscripts which-*
rpm --root /zip -i -h -v --nodeps --noscripts words-*
rpm --root /zip -i -h -v --nodeps --noscripts zlib-1*

# etc/ld.so.conf is messed up on the RHL 5.0 CDs, and as a result many older
# binaries will not run.  We can avoid these problems by creating a new
# etc/ld.so.conf:
cat >/zip/etc/ld.so.conf <<EOF 
/usr/i486-linuxaout/lib
/usr/X11R6/lib
/usr/i486-linux-libc5/lib
/usr/openwin/lib
/usr/local/lib
EOF

# We need to create etc/ld.so.cache on the Zip disk;  we can do so like this:
/usr/sbin/chroot /zip /sbin/ldconfig

# Make an initial etc/fstab:
cat >/zip/etc/fstab <<EOF
/dev/sda1	/	ext2	defaults	1	1
/dev/sda2	none	swap	sw
none		/proc	proc	defaults	1	1
/dev/scd0	/cdrom	iso9660	ro,noauto	0	0
/dev/hda1	/dos	vfat	ro,noauto	0	0
/dev/hda2	/linux	ext2	noauto		0	0
EOF

# Make another fstab, for use on the hard drive:
cat >/zip/etc/fstab-hd <<EOF
/dev/hda2	/	ext2	defaults	1	1
/dev/hda3	none	swap	sw
none		/proc	proc	defaults	1	1
/dev/scd0	/cdrom	iso9660	ro,noauto,user	0	0
/dev/hda1	/dos	vfat	defaults	0	0
/dev/sda1	/zip	ext2	noauto		0	0	
EOF

# Make a LILO configuration file, for use on the hard drive:
cat >/zip/etc/lilo.conf <<EOF
boot=/dev/hda2
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz
	label=linux
	root=/dev/hda2
	read-only
other=/dev/hda1
	label=win95
	loader=/boot/chain.b
	table=/dev/hda
EOF

# Make mount points for the Windows and Linux partitions on the internal disk,
# and for the CD-ROM.
mkdir /zip/cdrom /zip/dos /zip/linux

# Create a script to copy the contents of the Zip disk to the hard drive.
cat >/zip/tmp/install-from-zip <<EOF
cd /
if (mount | grep -q linux); then mount /linux; fi
tar cf - bin boot etc home lib root sbin usr var | (cd linux; tar xfv -)
cd /linux
mv etc/fstab etc/fstab-zip
mv etc/fstab-hd etc/fstab
mkdir cdrom dev dos mnt proc tmp zip
chmod 777 tmp
cp -p /dev/MAKEDEV dev
cd /linux/dev
./MAKEDEV generic
./MAKEDEV apm
ln -s psmouse mouse
ln -s psmouse psaux
cd /stage2
tar cf - . | (cd linux; tar xfv -)
EOF

# Copy the TMPZIP file tree to the Zip disk
if [ -d $TMPZIP ]
then
    (cd $TMPZIP; tar cf - . ) | (cd /zip; tar xfv - .)
fi

# Libretto-specific setup
#
# If you are using this script for something other than bootstrapping Linux
# on a Toshiba Libretto, you may want to comment out some or all of the
# commands below.

# Make a PCMCIA configuration file.  The PCIC line specifies the PCMCIA
# controller chip used by the Libretto.
cat >/zip/etc/sysconfig/pcmcia <<EOF
PCMCIA=yes
PCIC=i82365
PCIC_OPTS=
CORE_OPTS=
CARDMGR_OPTS=
EOF

# Make a link for the Libretto's pointing device:
cd /zip/dev
ln -s psaux mouse
