#!/bin/sh # http://www.phys.ethz.ch/~franklin/Projects/dphys2/makeroot # - build our replacement root floppy image for Debian woody (3.0) # copyright ETH Zuerich Physics Deparement, use under either BSD or GPL license # author Neil Franklin, last modification 2002.12.18 # this script is intended to be run as root, it will fail if run as user! # ------ read in setup . ./setup-dphys2 # ------ from here on code to do the actual actions # --- test if we can work if [ ! ${USER} = root ] ; then echo "sorry, you need to run this script as root - aborting ..." exit 1 fi # --- get ready for work if [ ! -d ${WORKDIR} ] ; then mkdir -p ${WORKDIR} fi # --- fetch stuff to work on /bin/echo "--------------------------------------------------------------------------" /bin/echo "*** downloading root disk image and drivers *** from ${CONF_DEBSERVER} ..." /bin/sleep ${SLEEP} # correct back our correction of Debians broken naming, so wget -N works if [ -f ${WORKDIR}/root.bin.gz ] ; then mv ${WORKDIR}/root.bin.gz ${WORKDIR}/root.bin fi # -N to only newer is fetched, save waisting bandwidth if already here # if user wants to force download, use an make clean before wget -N -P ${WORKDIR} http://${CONF_DEBSERVER}/${CONF_DEBDIR}/${DEBROOT} wget -N -P ${WORKDIR} http://${CONF_DEBSERVER}/${CONF_DEBDIR}/${DEBDRIVERS} # rename Debians broken naming, this file is compressed, so it should be .gz mv ${WORKDIR}/root.bin ${WORKDIR}/root.bin.gz # get rid of any intermediate files left over from last run (cd ${WORKDIR}; rm -rf drivers drivers-dphys modconf-dphys modules \ modules-dphys root-dphys root-dphys.bin root-dphys.bin.gz root.bin) if [ ${DEBUG} = 1 ] ; then /bin/echo "--- debug info ---" /bin/ls -al ${WORKDIR} read dummy fi # --- unpack it into an temporary filesystem /bin/echo "--------------------------------------------------" /bin/echo "*** unpacking Debian stuff *** into ${WORKDIR} ..." /bin/sleep ${SLEEP} # uncompress root image so that it becomes mountable gunzip -c ${WORKDIR}/root.bin.gz > ${WORKDIR}/root.bin # root image mkdir ${WORKDIR}/root-dphys mount -o loop ${WORKDIR}/root.bin /mnt tar cf - -C /mnt . | tar xpf - -C ${WORKDIR}/root-dphys umount /mnt # drivers tgz mkdir ${WORKDIR}/drivers tar zxvf ${WORKDIR}/drivers.tgz -C ${WORKDIR}/drivers if [ ${DEBUG} = 1 ] ; then /bin/echo "--- debug info ---" /bin/ls -al ${WORKDIR} read dummy fi # --- extract the stuff we still want /bin/echo "---------------------------------------" /bin/echo "*** Extract stuff we still want *** ..." /bin/sleep ${SLEEP} # - we need to fit onto one floppy, including our drivers /bin/echo "* deleting some unused stuff, for space ..." # so delete some unused stuff mv ${WORKDIR}/root-dphys/etc/messages.en ${WORKDIR} rm ${WORKDIR}/root-dphys/etc/messages.* mv ${WORKDIR}/messages.en ${WORKDIR}/root-dphys/etc # - copy only the few drivers we need, to avoid needing driver disks /bin/echo "* copying only the few drivers we need/want ..." # and drivers disk only copy the auxillary files mkdir ${WORKDIR}/drivers-dphys for file in install.sh modcont type.txt; do cp -p ${WORKDIR}/drivers/$file ${WORKDIR}/drivers-dphys done # and from modules.tgz the few drivers we need or want mkdir ${WORKDIR}/modules tar zxf ${WORKDIR}/drivers/modules.tgz -C ${WORKDIR}/modules # standard install /etc/modules needs these mkdir -p ${WORKDIR}/modules-dphys/${MODULEDIRMISC} for module in ${MODULESMISC}; do cp -p ${WORKDIR}/modules/${MODULEDIRMISC}/$module \ ${WORKDIR}/modules-dphys/${MODULEDIRMISC} done # our hardware wants these mkdir -p ${WORKDIR}/modules-dphys/${MODULEDIRNET} for module in ${MODULESNET}; do cp -p ${WORKDIR}/modules/${MODULEDIRNET}/${module} \ ${WORKDIR}/modules-dphys/${MODULEDIRNET} done tar zcvf ${WORKDIR}/drivers-dphys/modules.tgz -C ${WORKDIR}/modules-dphys . # - and prune some unused stuff from modconf.tgz /bin/echo "* prune some unused stuff from modconf.tgz ..." mkdir ${WORKDIR}/modconf-dphys tar zxf ${WORKDIR}/drivers/modconf.tgz -C ${WORKDIR}/modconf-dphys mv ${WORKDIR}/modconf-dphys/usr/share/modconf/eval_C ${WORKDIR} mv ${WORKDIR}/modconf-dphys/usr/share/modconf/eval_C.utf-8 ${WORKDIR} rm ${WORKDIR}/modconf-dphys/usr/share/modconf/eval_* mv ${WORKDIR}/eval_C ${WORKDIR}/modconf-dphys/usr/share/modconf mv ${WORKDIR}/eval_C.utf-8 ${WORKDIR}/modconf-dphys/usr/share/modconf tar zcf ${WORKDIR}/drivers-dphys/modconf.tgz -C ${WORKDIR}/modconf-dphys . if [ ${DEBUG} = 1 ] ; then /bin/echo "--- debug info ---" /bin/ls -al ${WORKDIR} read dummy fi # --- add various new stuff, to create the modified root disk /bin/echo "-------------------------------------------------------------" /bin/echo "*** Packing various new stuff onto modified root disk *** ..." /bin/sleep ${SLEEP} # - pack new drivers.tgz into root-dphys, avoid separate drivers floppys /bin/echo "* packing in drivers subset ..." # the lack of an / between root-dphys and ${DRIVERS_TGZ} is deliberate, not bug tar zcvf ${WORKDIR}/root-dphys${DRIVERS_TGZ} -C ${WORKDIR}/drivers-dphys . # - replace Debians dbootstrap with our automatic script and our/its setup /bin/echo "* packing in our replacement dbootstrap ..." cp -p dbootstrap ${WORKDIR}/root-dphys/sbin chown root.root ${WORKDIR}/root-dphys/sbin/dbootstrap chmod 755 ${WORKDIR}/root-dphys/sbin/dbootstrap cp -p setup-dphys2 ${WORKDIR}/root-dphys/etc chown root.root ${WORKDIR}/root-dphys/etc/setup-dphys2 # *** WARNING *** # this file must be chmod 600 because of LILO and root passwords in it! chmod 600 ${WORKDIR}/root-dphys/etc/setup-dphys2 # - and give script the /sbin/sfdisk it needs /bin/echo "* packing in sfdisk, used by replacement dbootstrap ..." cp -p sfdisk ${WORKDIR}/root-dphys/sbin chown root.root ${WORKDIR}/root-dphys/sbin/sfdisk chmod 755 ${WORKDIR}/root-dphys/sbin/sfdisk # - and give dbootstrap the lilo.conf template it needs /bin/echo "* packing in lilo.conf used by replacement dbootstrap ..." cp -p lilo.conf ${WORKDIR}/root-dphys${LILO_CONF} chown root.root ${WORKDIR}/root-dphys${LILO_CONF} chmod 644 ${WORKDIR}/root-dphys${LILO_CONF} if [ ${DEBUG} = 1 ] ; then /bin/echo "--- debug info ---" /bin/ls -al ${WORKDIR}/root-dphys read dummy fi # --- and fudge up debconf, so that we don't get base-config dialogs /bin/echo "-------------------------------------------------------------" /bin/echo "*** Fudge up debconf, so 2nd install stage no dialogs *** ..." /bin/sleep ${SLEEP} # for this we add an script that will be run by dbootstrap # after all the first stage install, but before reboot, chrooted to /target cp -p debconf-preload ${WORKDIR}/root-dphys${PRELOAD_ON_FLOPPY} chown root.root ${WORKDIR}/root-dphys${PRELOAD_ON_FLOPPY} chmod 755 ${WORKDIR}/root-dphys${PRELOAD_ON_FLOPPY} if [ ${DEBUG} = 1 ] ; then /bin/echo "--- debug info ---" /bin/ls -al ${WORKDIR}/root-dphys read dummy fi # --- create root disk image /bin/echo "----------------------------------" /bin/echo "*** creating new root disk *** ..." /bin/sleep ${SLEEP} # - get our pseudo-disk ready /bin/echo "* making an container file, formatting, mounting ..." dd if=/dev/zero of=${WORKDIR}/root-dphys.bin bs=1024 count=8192 # we need slightly over 3000 inodes mke2fs -i 2048 -F ${WORKDIR}/root-dphys.bin mount -o loop ${WORKDIR}/root-dphys.bin /mnt # - copy root system disk on to pseudo-disk /bin/echo "* copying root file tree into container file ..." tar cf - -C ${WORKDIR}/root-dphys . | tar xpf - -C /mnt # - unmounting container file and gzipping it as image /bin/echo "* packing in lilo.conf, used by replacement dbootstrap ..." umount /mnt gzip -9 -c ${WORKDIR}/root-dphys.bin > ${WORKDIR}/root-dphys.bin.gz if [ ${DEBUG} = 1 ] ; then /bin/echo "--- debug info ---" /bin/ls -al ${WORKDIR} read dummy fi