#!/bin/sh # http://www.phys.ethz.ch/~franklin/Projects/dphys2/dphys2root # - build dphys2 replacement root floppy image for Debian woody (3.0) # copyright ETH Zuerich Physics Departement, # use under either BSD or GPL license # author Neil Franklin, last modification 2004.10.14 ### ------ configuration for this site # first CONF_* various site or subnet dependant user config variables # then DEBUG_* various debugging settings # last SYS_* various system internal values # some of these are overridable by command line options # --- CONF_* various site or subnet dependant user config variables # base URL from which all Debian stuff can be downloaded CONF_DEBSERVER=http://ftp.debian.org/debian # are we using an 2.2 or 2.4 style kernel # if Debian kernels, this selects whether standard 2.2.20 or bf24 2.4.18 # if own kernels, this determines which Debian .config to use as base # if no own config is provided in CONF_KERNEL_CONFIG # so set this allways, if using or making an 2.4 kernel, instead of 2.2 CONF_KERNEL_24=no # use this to select an own (2.2 or 2.4) kernel source, to self compile # only needed if making own kernel CONF_KERNEL_OWN="" # server where we upload our compiled floppy images and driver archives to CONF_INST_SERVER=not-configured-server # user as which we login to above server CONF_USER=not-configured-user # make sure multiple users (group of them) can install files on package server # if this is set, chgrp directories and files to this group and chmod g+w CONF_GROUP="" # base directory on server where we put our floppy images and driver archives # this is the base directory for adding dists/woody/local/
/*/*/*.deb # paralleling Debians use dists/woody/main/
/*/* on their servers # and so should appear in the http:// space of the server # dphys2root -u uploads everything relative to this CONF_INST_BASE=/not/configured/directory # base URL from which the dphys2 rescue root and drivers can be fetched # used for generating the URLs. to access our packages web server # the end result should parallel the scp login@server:/basedir above CONF_OWNSERVER=http://not-configured-server/not/configured/directory # this is the directory to use, within dists/woody/local/main/disks-i386 tree # vary this for multiple sets of rescue images and drivers archives # naming schemes maybe by subnets, or by kernel options, or by compiling user CONF_DISKSVERSION=custom # what net drivers we want included in our install root floppy drivers archive # net is needed to install from, to fetch files # this can be left empty if needed drivers are compiled into kernel CONF_MODULESNET="" # automagically run this script (or binary) at end of first install stage # use with script filename like this: CONF_ENDFIRSTRUN=endfirstrun # this may generate base-config scripts to run at end of second install stage # see example file for how to do this (installing dphys-admin package) # we use this to install our automatic package installer/updater/remover: # http://www.phys.ethz.ch/~franklin/Projects/dphys-admin/ CONF_ENDFIRSTRUN="" # install floppy drive, where our generated root image goes # this should be the drive on the install generating system, not on target(s) # most people can leave this as it is CONF_INST_FLOPPY=/dev/fd0 # --- DEBUG_*, various debugging settings # these can be set to "yes" by -D option, followed by name without DEBUG_ # such as like this: dphys2root -D PRINT_STEP -D LEAVE_TEMPFILES -g # set this to sleep after displaying each steps header, number is in seconds #DEBUG_SLEEP=2 # set this to output debug state info after each step #DEBUG_PRINT_STEP=yes # set this to wait after each debug state info #DEBUG_WAIT_STEP=yes # set this to not delete temporary files (workdir) after -g #DEBUG_LEAVE_TEMPFILES=yes # set this to leave temporary directories undeleted after -u #DEBUG_LEAVE_TEMPDIRS=yes # --- SYS_*, various system internal values # where we want to do all the root disk unpack/modify/pack stuff # this must be a directory that root can access (not a root-squash NFS mount) # and there should be about 50MByte free space in its filesystem SYS_WORKDIR=/var/tmp/dphys2root-$$-work # where we want to put together stuff for upload # not ./upload as this may collide with something user already has SYS_UPLOADDIR=/var/tmp/dphys2root-$$-upload # note: this program has only been designed for and tested with i386 # others at own risk, I expect them to fail badly SYS_ARCH=i386 # standard misc drivers we need to include in our archive on root image # these are only used for debians 2.2(.20) kernel, and lookalikes # not used on 2.4 based systems, as no misc modules dir # no clue why Debian modularised these anyway, as allways needed and loaded SYS_MODULESMISC="unix.o af_packet.o" # where we will place the drivers archive within root floppy SYS_DRIVERSTGZ_ON_FLOPPY=/drivers.tgz # where we will place our merged config file SYS_DPHYS2CONF_ON_FLOPPY=/dphys2 # where we will place our modifier for debconf for 2nd stage without dialogs SYS_PRELOAD_ON_FLOPPY=/debconf-preload # where we will place our user command to run SYS_ENDFIRSTRUN_ON_FLOPPY=/endfirstrun ### ------ actual implementation from here on # no user settings any more below this point # --- config file stuff # what we are NAME=dphys2root PNAME=dphys2 # check user config file(s), let user override settings # same config files used in dphys2[rescue|root|cd|pxe] and dbootstrap if [ -f /etc/${PNAME} ] ; then . /etc/${PNAME} fi if [ -f /etc/default/${PNAME} ] ; then . /etc/default/${PNAME} fi if [ -f ~/.${PNAME} ] ; then . ~/.${PNAME} fi if [ -f ./${PNAME} ] ; then . ./${PNAME} fi # --- parse command line # so long next parameter is a set of options (= begins with an - character) while [ x`/bin/echo $1 | /usr/bin/cut -c 1` = x- ] ; do # extract options from parameter (cut off the "-") OPTS=`/bin/echo $1 | /usr/bin/cut -c 2-` shift 1 # so long still unprocessed option characters while [ x${OPTS} != x ] ; do # first option to process OPT=`/bin/echo ${OPTS} | /usr/bin/cut -c 1` # and rest of options for later OPTS=`/bin/echo ${OPTS} | /usr/bin/cut -c 2-` case ${OPT} in d) # download: download orignal Debian files from server DO_DOWN=yes ;; g) # generate: generate dphys2 files DO_GEN=yes ;; w) # workdir: generate using this work directory SYS_WORKDIR=$1 shift 1 ;; u) # upload: upload generated files to local install server DO_UPLOAD=yes ;; b) # base: upload generated package files to base directory CONF_INST_BASE=$1 shift 1 ;; f) # fetch: fetch dphys2 files from local install server DO_FETCH=yes ;; i) # install: install original or dphys2 files onto floppy DO_INST=yes ;; r) # remove: remove dphys2 files, after installing DO_REMOVE=yes ;; D) # Debug: set an debug option to yes eval DEBUG_$1=yes shift 1 ;; h) # help: give out help how this script can be used /bin/cat << END-HELP-TEXT Usage is: $0 [options] options: -d download: download orignal Debian root image file from distribution server -g generate: generate dphys2 root image -w workdir workdir: generate using this work directory -u upload: upload generated files to local install server for usage by -f before install -b baseaddr base: upload generated package files to this base directory -f fetch: fetch dphys2 root image from local install server usefull if installing on different system than generating -i install: install original or dphys2 root image onto floppy -r remove: remove Debian and dphys2 files, after installing -D Debug: activate an debug option -h help: give out help how this script can be used If multiple of -d -g -u -f -i -r or -i are used, they are processed in the order they appear here in the help section, not the order they are typed on the command line. Other options modify behaviour. END-HELP-TEXT exit 0 ;; *) # not one of our recognized options /bin/echo "$0: ERROR: unknown option: ${OPT}" >&2 /bin/echo # call self with -h to display help $0 -h exit 1 ;; esac done done if [ "x${DO_DOWN}${DO_GEN}${DO_UPLOAD}${DO_FETCH}${DO_INST}${DO_REMOVE}" \ = x ] ; then /bin/echo "$0: WARNING: no option selected, doing nothing" >&2 fi if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/echo options are: DO_DOWN: ${DO_DOWN}, DO_GEN: ${DO_GEN}, \ DO_UPLOAD: ${DO_UPLOAD}, DO_FETCH: ${DO_FETCH}, \ DO_INST: ${DO_INST}, DO_REMOVE: ${DO_REMOVE} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi # --- test if we can work # this script is intended to be run as root, it will fail if run as user! if [ ! `/usr/bin/whoami` = root ] ; then /bin/echo "$0: sorry, you need to run this script as root - aborting ..." exit 1 fi # --- compute paths on disk image server # paths for Debian files we download from server DEBDISKS=dists/woody/main/disks-${SYS_ARCH}/current # for standard 2.2(.20) kernel DEBRESCUE=${DEBDISKS}/images-1.44/rescue.bin DEBROOT=${DEBDISKS}/images-1.44/root.bin DEBDRIVERS=${DEBDISKS}/drivers.tgz # for bf2.4 (2.4.18) kernel DEBRESCUE_BF24=${DEBDISKS}/images-1.44/bf2.4/rescue.bin DEBROOT_BF24=${DEBDISKS}/images-1.44/bf2.4/root.bin DEBDRIVERS_BF24=${DEBDISKS}/bf2.4/drivers.tgz # paths for dphys2 files we upload to and fetch from server OWNDISKS=dists/woody/local/main/disks-${SYS_ARCH}/${CONF_DISKSVERSION} OWNRESCUE=${OWNDISKS}/images-1.44/rescue-dphys.bin OWNROOT=${OWNDISKS}/images-1.44/root-dphys.bin OWNDRIVERS=${OWNDISKS}/drivers-dphys.tgz # --- download Debian root disk image to work on # determine the correct root floppy image file # used by -d and -g and others, so once here outside of -d if [ x${CONF_KERNEL_24} = xyes ] ; then ROOT_URL="${CONF_DEBSERVER}/${DEBROOT_BF24}" else ROOT_URL="${CONF_DEBSERVER}/${DEBROOT}" fi ROOT=`/usr/bin/basename ${ROOT_URL}` if [ x${DO_DOWN} != x ] ; then /bin/echo "------------------------------------------" /bin/echo "*** downloading Debian root disk image ***" if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # -N so only newer is fetched, save waisting bandwidth if already here # if user wants to force download, use an make clean before /usr/bin/wget -N ${ROOT_URL} if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${ROOT} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- download dphys2 or Debian drivers archive to work on # determine the correct full drivers archive if [ x${CONF_KERNEL_OWN} != x ] ; then DRV_URL="${CONF_OWNSERVER}/${OWNDRIVERS}" elif [ x${CONF_KERNEL_24} = xyes ] ; then DRV_URL="${CONF_DEBSERVER}/${DEBDRIVERS_BF24}" else DRV_URL="${CONF_DEBSERVER}/${DEBDRIVERS}" fi DRV=`/usr/bin/basename ${DRV_URL}` if [ x${DO_DOWN} != x ] ; then /bin/echo "---------------------------------------" /bin/echo "*** downloading drivers tar archive ***" if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # -N to only newer is fetched, save waisting bandwidth if already here # if user wants to force download, use an make clean before /usr/bin/wget -N ${DRV_URL} if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${DRV} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- space to work in if [ x${DO_GEN} != x ] ; then /bin/mkdir -p ${SYS_WORKDIR} fi # --- unpack it into an temporary filesystem if [ x${DO_GEN} != x ] ; then /bin/echo "------------------------------------------------------" /bin/echo "*** unpacking Debian stuff *** into ${SYS_WORKDIR} ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # place to work on root file system /bin/rm -rf ${SYS_WORKDIR}/root-dphys /bin/mkdir ${SYS_WORKDIR}/root-dphys # - unpack root file system from floppy image # correct Debians broken naming, this file is compressed, should be .gz # also we need the .gz-less name for the uncompressed file /bin/mv ${ROOT} ${ROOT}.gz # uncompress the root image so that it becomes (loopback) mountable /bin/gunzip -c ${ROOT}.gz > ${ROOT} # unpack root file system from floppy image ROOTFLOPPY=${SYS_WORKDIR}/floppy /bin/mkdir -p ${ROOTFLOPPY} /bin/mount -o loop ${ROOT} ${ROOTFLOPPY} /bin/tar cf - -C ${ROOTFLOPPY} . | \ /bin/tar xpf - -C ${SYS_WORKDIR}/root-dphys /bin/umount ${ROOTFLOPPY} /bin/rm -rf ${ROOTFLOPPY} # get rid of space waste of uncompressed root image /bin/rm ${ROOT} # un-correct correction of Debians broken naming, so that back to "normal" # else wget -N will fail to work, if user runs this program a second time /bin/mv ${ROOT}.gz ${ROOT} # - unpack drivers from large drivers archive file /bin/rm -rf ${SYS_WORKDIR}/drivers /bin/mkdir ${SYS_WORKDIR}/drivers /bin/tar zxf ${DRV} -C ${SYS_WORKDIR}/drivers # unpack modules from modules.tgz in drivers /bin/rm -rf ${SYS_WORKDIR}/modules /bin/mkdir ${SYS_WORKDIR}/modules /bin/tar zxf ${SYS_WORKDIR}/drivers/modules.tgz -C ${SYS_WORKDIR}/modules # unpack modconf from modconf.tgz in drivers /bin/rm -rf ${SYS_WORKDIR}/modconf-dphys /bin/mkdir ${SYS_WORKDIR}/modconf-dphys /bin/tar zxf ${SYS_WORKDIR}/drivers/modconf.tgz -C \ ${SYS_WORKDIR}/modconf-dphys if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${SYS_WORKDIR} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- delete some stuff we don't want, to get more free space if [ x${DO_GEN} != x ] ; then /bin/echo "----------------------------------------" /bin/echo "*** Deleting stuff we don't want *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # delete some unused text files /bin/mv ${SYS_WORKDIR}/root-dphys/etc/messages.en ${SYS_WORKDIR} /bin/rm ${SYS_WORKDIR}/root-dphys/etc/messages.* /bin/mv ${SYS_WORKDIR}/messages.en ${SYS_WORKDIR}/root-dphys/etc # delete unused USB keyboard modules, can't bother adding custom kernel ones # Debian does this as modules, because most people do not need this # if your systems need to use it, compile it into your custom kernel if [ x${CONF_KERNEL_OWN} != x ] ; then /bin/rm -rf ${SYS_WORKDIR}/root-dphys/lib/modules/* fi if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${SYS_WORKDIR} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- extract the stuff we still want if [ x${DO_GEN} != x ] ; then /bin/echo "---------------------------------------" /bin/echo "*** Extract stuff we still want *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # - 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 /bin/rm -rf ${SYS_WORKDIR}/drivers-dphys /bin/mkdir ${SYS_WORKDIR}/drivers-dphys for file in install.sh modcont type.txt; do /bin/cp -p ${SYS_WORKDIR}/drivers/$file ${SYS_WORKDIR}/drivers-dphys done # and modules.tgz: only copy the few drivers we need or want /bin/rm -rf ${SYS_WORKDIR}/modules-dphys /bin/mkdir ${SYS_WORKDIR}/modules-dphys # determine modules directory name/number KERNELVERS=`/usr/bin/basename ${SYS_WORKDIR}/modules/lib/modules/*` # standard Debian 2.2(.20) kernel needs these (what were they thinking?) # 2.4 kernels do not have these any more, so they are not needed/possible if [ `echo ${KERNELVERS} | cut -f 2 -d "."` = 2 ] ; then MODULEDIRMISC=lib/modules/${KERNELVERS}/misc # test if at least one module is wanted if [ x`/bin/echo ${SYS_MODULESMISC} | \ /usr/bin/cut -f 1 -d " "` != x ] ; then /bin/mkdir -p ${SYS_WORKDIR}/modules-dphys/${MODULEDIRMISC} for module in ${SYS_MODULESMISC}; do /bin/cp -a ${SYS_WORKDIR}/modules/${MODULEDIRMISC}/$module \ ${SYS_WORKDIR}/modules-dphys/${MODULEDIRMISC} done fi fi # our network hardware needs these # non-modular kernels (users may want to make such) may not want any # so test if at least one module is wanted if [ x`/bin/echo ${CONF_MODULESNET} | /usr/bin/cut -f 1 -d " "` != x ] ; then # determine where to place modules, as minor versions 2 and 4 are different if [ `echo ${KERNELVERS} | cut -f 2 -d "."` = 2 ] ; then # 2.2 flat structure MODULEDIRNET=lib/modules/${KERNELVERS}/net else # 2.4 tree structure MODULEDIRNET=lib/modules/${KERNELVERS}/kernel/drivers/net fi /bin/mkdir -p ${SYS_WORKDIR}/modules-dphys/${MODULEDIRNET} for module in ${CONF_MODULESNET}; do /bin/cp -a ${SYS_WORKDIR}/modules/${MODULEDIRNET}/${module} \ ${SYS_WORKDIR}/modules-dphys/${MODULEDIRNET} done fi # - and prune some unused stuff from modconf.tgz /bin/echo "* prune some unused stuff from modconf.tgz ..." /bin/mv ${SYS_WORKDIR}/modconf-dphys/usr/share/modconf/eval_C \ ${SYS_WORKDIR} /bin/mv ${SYS_WORKDIR}/modconf-dphys/usr/share/modconf/eval_C.utf-8 \ ${SYS_WORKDIR} /bin/rm ${SYS_WORKDIR}/modconf-dphys/usr/share/modconf/eval_* /bin/mv ${SYS_WORKDIR}/eval_C \ ${SYS_WORKDIR}/modconf-dphys/usr/share/modconf /bin/mv ${SYS_WORKDIR}/eval_C.utf-8 \ ${SYS_WORKDIR}/modconf-dphys/usr/share/modconf if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${SYS_WORKDIR} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- add various new stuff, to create the modified root disk if [ x${DO_GEN} != x ] ; then /bin/echo "-------------------------------------------------------------" /bin/echo "*** Packing various new stuff *** onto modified root disk ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # - pack up the new reduced drivers stuff /bin/echo "* packing in the drivers subset ..." # pack new modules into modules.tgz in drivers-dphys /bin/tar zcf ${SYS_WORKDIR}/drivers-dphys/modules.tgz \ -C ${SYS_WORKDIR}/modules-dphys . # pack new modconf into modconf.tgz in drivers-dphys /bin/tar zcf ${SYS_WORKDIR}/drivers-dphys/modconf.tgz \ -C ${SYS_WORKDIR}/modconf-dphys . # pack drivers archive subset file into root-dphys # this avoids need for separate drivers floppys /bin/tar zcf ${SYS_WORKDIR}/root-dphys/${SYS_DRIVERSTGZ_ON_FLOPPY} \ -C ${SYS_WORKDIR}/drivers-dphys . # - replace Debians dbootstrap with our automatic script and our/its setup /bin/echo "* packing in our replacement dbootstrap ..." if [ -f ./dbootstrap ] ; then /bin/cp -p ./dbootstrap ${SYS_WORKDIR}/root-dphys/sbin elif [ -f /usr/lib/${PNAME}/dbootstrap ] ; then /bin/cp -p /usr/lib/${PNAME}/dbootstrap ${SYS_WORKDIR}/root-dphys/sbin else /bin/echo "$0: ERROR: can not find replacement dbootstrap" >&2 exit 1 fi /bin/chown root.root ${SYS_WORKDIR}/root-dphys/sbin/dbootstrap /bin/chmod 755 ${SYS_WORKDIR}/root-dphys/sbin/dbootstrap # - and give our automatic script its configuration file DPHYS2CONF=${SYS_WORKDIR}/root-dphys/${SYS_DPHYS2CONF_ON_FLOPPY} /bin/echo "# ${SYS_DPHYS2CONF_ON_FLOPPY}" > ${DPHYS2CONF} /bin/echo "# generated by ${NAME}" >> ${DPHYS2CONF} if [ -f /etc/${PNAME} ] ; then /bin/echo >> ${DPHYS2CONF} /bin/echo "# ------ /etc/${PNAME}" >> ${DPHYS2CONF} /bin/echo >> ${DPHYS2CONF} /bin/cat /etc/${PNAME} >> ${DPHYS2CONF} fi if [ -f /etc/default/${PNAME} ] ; then /bin/echo >> ${DPHYS2CONF} /bin/echo "# ------ /etc/default/${PNAME}" >> ${DPHYS2CONF} /bin/echo >> ${DPHYS2CONF} /bin/cat /etc/default/${PNAME} >> ${DPHYS2CONF} fi if [ -f ~/.${PNAME} ] ; then /bin/echo >> ${DPHYS2CONF} /bin/echo "# ------ ~/.${PNAME}" >> ${DPHYS2CONF} /bin/echo >> ${DPHYS2CONF} /bin/cat ~/.${PNAME} >> ${DPHYS2CONF} fi if [ -f ./${PNAME} ] ; then /bin/echo >> ${DPHYS2CONF} /bin/echo "# ------ ./${PNAME}" >> ${DPHYS2CONF} /bin/echo >> ${DPHYS2CONF} /bin/cat ./${PNAME} >> ${DPHYS2CONF} fi /bin/chown root.root ${DPHYS2CONF} # *** WARNING *** # this file must be chmod 600 because of LILO and root passwords in it! /bin/chmod 600 ${DPHYS2CONF} # - and give our script the /sbin/sfdisk it needs /bin/echo "* packing in sfdisk, used by replacement dbootstrap ..." if [ -f ./sfdisk ] ; then /bin/cp -p ./sfdisk ${SYS_WORKDIR}/root-dphys/sbin elif [ -f ./sfdisk.gz ] ; then # allow this to be compressed, to evade lintian binary tests in "all" /bin/cp -p ./sfdisk.gz ${SYS_WORKDIR}/root-dphys/sbin /bin/gunzip ${SYS_WORKDIR}/root-dphys/sbin/sfdisk.gz elif [ -f /usr/lib/${PNAME}/sfdisk ] ; then /bin/cp -p /usr/lib/${PNAME}/sfdisk ${SYS_WORKDIR}/root-dphys/sbin elif [ -f /usr/lib/${PNAME}/sfdisk.gz ] ; then /bin/cp -p /usr/lib/${PNAME}/sfdisk.gz ${SYS_WORKDIR}/root-dphys/sbin /bin/gunzip ${SYS_WORKDIR}/root-dphys/sbin/sfdisk.gz else /bin/echo "$0: ERROR: can not find root floppy capable sfdisk" >&2 exit 1 fi /bin/chown root.root ${SYS_WORKDIR}/root-dphys/sbin/sfdisk /bin/chmod 755 ${SYS_WORKDIR}/root-dphys/sbin/sfdisk # - and give dbootstrap the lilo.conf template it needs /bin/echo "* packing in lilo.conf used by replacement dbootstrap ..." if [ -f ./lilo.conf ] ; then /bin/cp -p ./lilo.conf ${SYS_WORKDIR}/root-dphys/etc elif [ -f /usr/lib/${PNAME}/lilo.conf ] ; then /bin/cp -p /usr/lib/${PNAME}/lilo.conf ${SYS_WORKDIR}/root-dphys/etc else /bin/echo "$0: ERROR: can not find LILO config file" >&2 exit 1 fi /bin/chown root.root ${SYS_WORKDIR}/root-dphys/etc/lilo.conf /bin/chmod 644 ${SYS_WORKDIR}/root-dphys/etc/lilo.conf if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${SYS_WORKDIR}/root-dphys /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- fudge up debconf, so that we don't get base-config dialogs if [ x${DO_GEN} != x ] ; then /bin/echo "----------------------------------------------------------------" /bin/echo "*** Include debconf script, 2nd install stage no dialogs *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # for this we add an script that will be run by dbootstrap # after all the first stage install, but before reboot, chrooted to /target if [ -f ./debconf-preload ] ; then /bin/cp -p ./debconf-preload \ ${SYS_WORKDIR}/root-dphys/${SYS_PRELOAD_ON_FLOPPY} elif [ -f /usr/lib/${PNAME}/debconf-preload ] ; then /bin/cp -p /usr/lib/${PNAME}/debconf-preload \ ${SYS_WORKDIR}/root-dphys/${SYS_PRELOAD_ON_FLOPPY} else /bin/echo "$0: ERROR: can not find debconf preload script" >&2 exit 1 fi /bin/chown root.root ${SYS_WORKDIR}/root-dphys/${SYS_PRELOAD_ON_FLOPPY} /bin/chmod 755 ${SYS_WORKDIR}/root-dphys/${SYS_PRELOAD_ON_FLOPPY} if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${SYS_WORKDIR}/root-dphys/${SYS_PRELOAD_ON_FLOPPY} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- run user script (or binary) at end of first install stage, further autom if [ x${DO_GEN} != x -a x${CONF_ENDFIRSTRUN} != x ] ; then # give user chance to do further site specific automation /bin/echo "-----------------------------------------------------------------" /bin/echo "*** Include user script, user specific further automation *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # for this we add an script that will be run by dbootstrap # after all the first stage install, but before reboot, chrooted to /target if [ -f ${CONF_ENDFIRSTRUN} ] ; then /bin/cp -p ${CONF_ENDFIRSTRUN} \ ${SYS_WORKDIR}/root-dphys/${SYS_ENDFIRSTRUN_ON_FLOPPY} else /bin/echo "$0: ERROR: CONF_ENDFIRSTRUN feature enabled in setup," \ "but file ${CONF_ENDFIRSTRUN} is missing" >&2 exit 1 fi /bin/chown root.root ${SYS_WORKDIR}/root-dphys/${SYS_ENDFIRSTRUN_ON_FLOPPY} /bin/chmod 755 ${SYS_WORKDIR}/root-dphys/${SYS_ENDFIRSTRUN_ON_FLOPPY} if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${CONF_ENDFIRSTRUN} \ ${SYS_WORKDIR}/root-dphys/${SYS_ENDFIRSTRUN_ON_FLOPPY} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- make the dphys2 root disk image # name for new floppy image # used also in other places ROOT_DPHYS2=`/usr/bin/basename ${OWNROOT}` if [ x${DO_GEN} != x ] ; then /bin/echo "--------------------------------" /bin/echo "*** making new root disk *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # get pseudo disk ready for making floppy image # 8MByte will fit file system and compressed onto 1.44MByte disk /bin/dd if=/dev/zero of=${ROOT_DPHYS2} bs=1024 count=8192 # we need slightly over 3000 inodes, this gives us 8192*1024/2048=4096 inodes /sbin/mke2fs -i 2048 -F ${ROOT_DPHYS2} # pack root file system onto floppy image ROOTFLOPPY=${SYS_WORKDIR}/floppy /bin/mkdir -p ${ROOTFLOPPY} /bin/mount -o loop ${ROOT_DPHYS2} ${ROOTFLOPPY} /bin/tar cf - -C ${SYS_WORKDIR}/root-dphys . | \ /bin/tar xpf - -C ${ROOTFLOPPY} /bin/umount ${ROOTFLOPPY} /bin/rm -rf ${ROOTFLOPPY} # compress own root image so that it becomes kernel boot ramdisk mountable # compressed so that it fits on floppy # maximising space that will fit is more important than runtime, so -9 /bin/gzip -9 ${ROOT_DPHYS2} # break naming, no .gz, the way Debian wants to see it /bin/mv ${ROOT_DPHYS2}.gz ${ROOT_DPHYS2} if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${ROOT_DPHYS2} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- tidy up after working if [ x${DO_GEN} != x ] ; then /bin/echo "-----------------------------------" /bin/echo "*** tidying up from working *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${SYS_WORKDIR} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi # remove all temporary directories and their contents, to save space # must be after debug printout if [ x${DEBUG_LEAVE_TEMPFILES} != xyes ] ; then # but offer to leave them to investigate bugs /bin/rm -rf ${SYS_WORKDIR} fi fi # --- upload dphys2 root floppy image if [ x${DO_UPLOAD} != x ] ; then /bin/echo "-------------------------------------------------" /bin/echo "*** uploading root *** to ${CONF_INST_SERVER} ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # put together stuff to upload, needs an temp dir ROOT_DIR=${SYS_UPLOADDIR}/`/usr/bin/dirname ${OWNROOT}` /bin/mkdir -p ${ROOT_DIR} if [ x${CONF_GROUP} != x ] ; then /bin/chgrp -R ${CONF_GROUP} ${SYS_UPLOADDIR} /bin/chmod -R 2775 ${SYS_UPLOADDIR} fi if [ -f ${ROOT_DPHYS2} ] ; then /bin/cp -p ${ROOT_DPHYS2} ${ROOT_DIR} if [ x${CONF_GROUP} != x ] ; then /bin/chgrp ${CONF_GROUP} ${ROOT_DIR}/* /bin/chmod 664 ${ROOT_DIR}/* fi fi # include directory tree, duplicating tree to server, in case server has none # may be none if new package is in an previously unused section # this is a bit site dependant, you need ssh on your local package server # 2> needed to get rid of error message, because scp can not change dir modes # this loses us the progress bar, because scp tests also 2> for tty or not # if user has given us somewhere to upload to, else dphys2cp|pxe get screwed if [ x${CONF_INST_SERVER} != x ] ; then /usr/bin/scp -pr ${SYS_UPLOADDIR}/* \ ${CONF_USER}@${CONF_INST_SERVER}:${CONF_INST_BASE} 2> /dev/null else /bin/echo "$0: ERROR: no server to upload root floppy image to" >&2 exit 1 fi if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -alR ${SYS_UPLOADDIR}/* /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi # remove temporary directory and its contents, to save space # must be after debug printout if [ x${DEBUG_LEAVE_TEMPDIRS} != xyes ] ; then # but offer to leave this to investigate bugs /bin/rm -rf ${SYS_UPLOADDIR} fi fi # --- fetch dphys2 root disk image to install if [ x${DO_FETCH} != x ] ; then /bin/echo "---------------------------------------" /bin/echo "*** fetching dphys2 root disk image ***" if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # always dphys2 root image, never fetch Debian, use -d for that ROOT_DPHYS2_URL="${CONF_OWNSERVER}/${OWNROOT}" # usage see -d download /usr/bin/wget -N ${ROOT_DPHYS2_URL} if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${ROOT_DPHYS2} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- install root disk image onto an floppy if [ x${DO_INST} != x ] ; then /bin/echo "----------------------------------" /bin/echo "*** installing root disk image ***" if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # determine correct root floppy image file or generated/fetched if [ -f ${ROOT_DPHYS2} ] ; then ROOT_FLOPPY=${ROOT_DPHYS2} else ROOT_FLOPPY=${ROOT} fi /bin/dd if=${ROOT_FLOPPY} of=${CONF_INST_FLOPPY} bs=1024 if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${ROOT_FLOPPY} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi fi # --- remove root disk images and drivers tar archives if [ x${DO_REMOVE} != x ] ; then /bin/echo "----------------------------------------------------------" /bin/echo "*** removing root disk images and drivers tar archives ***" if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/echo "--- DEBUG: info ---" /bin/ls -al ${ROOT} ${DRV} ${ROOT_DPHYS2} /bin/echo "--- end info ---" fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then read -p "--- DEBUG: wait after step ---" dummy fi if [ -f ${ROOT} -o -f ${DRV} -o -f ${ROOT_DPHYS2} ] ; then /bin/rm -rf ${ROOT} ${DRV} ${ROOT_DPHYS2} fi fi