From 2f8add854046c010d2185292b5b2c4daaa226f73 Mon Sep 17 00:00:00 2001 From: Brad House Date: Sat, 17 Jan 2004 18:37:25 +0000 Subject: [PATCH] runscript additions git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@167 d1e1f19c-881f-0410-ab34-b69fee027534 --- .../livecd/runscript/default-runscript.sh | 100 +++++++++++++----- examples/livecd/runscript/x86-runscript.sh | 20 +++- 2 files changed, 88 insertions(+), 32 deletions(-) diff --git a/examples/livecd/runscript/default-runscript.sh b/examples/livecd/runscript/default-runscript.sh index 2df2b8ba..cf878a62 100644 --- a/examples/livecd/runscript/default-runscript.sh +++ b/examples/livecd/runscript/default-runscript.sh @@ -1,6 +1,6 @@ # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/examples/livecd/runscript/Attic/default-runscript.sh,v 1.4 2004/01/17 03:55:42 brad_mssw Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/examples/livecd/runscript/Attic/default-runscript.sh,v 1.5 2004/01/17 18:37:24 brad_mssw Exp $ # Section has been handled, do not execute additional scripts RETURN_GOOD=0 @@ -9,6 +9,14 @@ RETURN_BAD=1 # Should continue RETURN_CONTINUE=2 +# Set default looptype to zisofs +if [ "${LOOPTYPE}" == "" ] +then + LOOPTYPE="zisofs" +fi + +export LOOPTYPE + die() { echo "$1" exit $RETURN_BAD @@ -58,6 +66,53 @@ else echo "${ARCH_RUNSCRIPT} finished successfully, running default commands" fi +create_normal_loop() +{ + #We get genkernel-built kernels and initrds in place, create the loopback fs on + #$clst_cdroot_path, mount it, copy our bootable filesystem over, umount it, and + #we then have a ready-to-burn ISO tree at $clst_cdroot_path. + + echo "Calculating size of loopback filesystem..." + loopsize=`du -ks $clst_chroot_path | cut -f1` + [ "$loopsize" = "0" ] && loopsize=1 + #increase the size by 1/3, then divide by 4 to get 4k blocks + loopsize=$(( ( $loopsize + ( $loopsize / 2 ) ) / 4 )) + echo "Creating loopback file..." + dd if=/dev/zero of=$clst_cdroot_path/livecd.loop bs=4k count=$loopsize || die "livecd.loop creation failure" + #echo "Calculating number of inodes required for ext2 filesystem..." + #numnodes=`find $clst_chroot_path | wc -l` + #numnodes=$(( $numnodes + 200 )) + mke2fs -m 0 -F -b 4096 -q $clst_cdroot_path/livecd.loop || die "Couldn't create ext2 filesystem" + install -d $clst_cdroot_path/loopmount + sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug + mount -t ext2 -o loop $clst_cdroot_path/livecd.loop $clst_cdroot_path/loopmount || die "Couldn't mount loopback ext2 filesystem" + sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug + echo "cp -a $clst_chroot_path/* $clst_cdroot_path/loopmount" + cp -a $clst_chroot_path/* $clst_cdroot_path/loopmount + + [ $? -ne 0 ] && { umount $clst_cdroot_path/loopmount; die "Couldn't copy files to loopback ext2 filesystem"; } + umount $clst_cdroot_path/loopmount || die "Couldn't unmount loopback ext2 filesystem" + rm -rf $clst_cdroot_path/loopmount + #now, $clst_cdroot_path should contain a proper bootable image for our iso, including + #boot loader and loopback filesystem. + return $RETURN_GOOD +} + +create_zisofs() +{ + rm -rf ${clst_cdroot_path}/zisofs > /dev/null 2>&1 + echo "Creating zisofs..." + mkzftree -z 9 -p2 ${clst_chroot_path} ${clst_cdroot_path}/zisofs || die "Could not run mkzftree, did you emerge zisofs" + return $RETURN_GOOD +} + +create_noloop() +{ + echo "Copying files for image (no loop)..." + cp -a $clst_chroot_path/* $clst_cdroot_path || die "Could not copy files to image (no loop)" + return $RETURN_GOOD +} + case $1 in kernbuild) shift @@ -149,34 +204,21 @@ EOF ;; loop) - #We get genkernel-built kernels and initrds in place, create the loopback fs on - #$clst_cdroot_path, mount it, copy our bootable filesystem over, umount it, and - #we then have a ready-to-burn ISO tree at $clst_cdroot_path. - - echo "Calculating size of loopback filesystem..." - loopsize=`du -ks $clst_chroot_path | cut -f1` - [ "$loopsize" = "0" ] && loopsize=1 - #increase the size by 1/3, then divide by 4 to get 4k blocks - loopsize=$(( ( $loopsize + ( $loopsize / 2 ) ) / 4 )) - echo "Creating loopback file..." - dd if=/dev/zero of=$clst_cdroot_path/livecd.loop bs=4k count=$loopsize || die "livecd.loop creation failure" - #echo "Calculating number of inodes required for ext2 filesystem..." - #numnodes=`find $clst_chroot_path | wc -l` - #numnodes=$(( $numnodes + 200 )) - mke2fs -m 0 -F -b 4096 -q $clst_cdroot_path/livecd.loop || die "Couldn't create ext2 filesystem" - install -d $clst_cdroot_path/loopmount - sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug - mount -t ext2 -o loop $clst_cdroot_path/livecd.loop $clst_cdroot_path/loopmount || die "Couldn't mount loopback ext2 filesystem" - sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug - echo "cp -a $clst_chroot_path/* $clst_cdroot_path/loopmount" - cp -a $clst_chroot_path/* $clst_cdroot_path/loopmount - - [ $? -ne 0 ] && { umount $clst_cdroot_path/loopmount; die "Couldn't copy files to loopback ext2 filesystem"; } - umount $clst_cdroot_path/loopmount || die "Couldn't unmount loopback ext2 filesystem" - rm -rf $clst_cdroot_path/loopmount - #now, $clst_cdroot_path should contain a proper bootable image for our iso, including - #boot loader and loopback filesystem. - exit $RETURN_GOOD + loopret=1 + if [ "${LOOPTYPE}" = "normal" ] + then + create_normal_loop + loopret=$? + elif [ "${LOOPTYPE}" = "zisofs" ] + then + create_zisofs + loopret=$? + elif [ "${LOOPTYPE}" = "noloop" ] + then + create_noloop + loopret=$? + fi + exit $loopret ;; iso_create) diff --git a/examples/livecd/runscript/x86-runscript.sh b/examples/livecd/runscript/x86-runscript.sh index afc7cdd9..1bc90c8c 100644 --- a/examples/livecd/runscript/x86-runscript.sh +++ b/examples/livecd/runscript/x86-runscript.sh @@ -1,6 +1,6 @@ # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/examples/livecd/runscript/Attic/x86-runscript.sh,v 1.5 2004/01/17 03:55:42 brad_mssw Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/examples/livecd/runscript/Attic/x86-runscript.sh,v 1.6 2004/01/17 18:37:25 brad_mssw Exp $ # Section has been handled, do not execute additional scripts RETURN_GOOD=0 @@ -36,6 +36,20 @@ case $1 in ;; setup_bootloader) + # LOOPTYPE should be exported from default runscript, we use it to + # determine kernel args + if [ "${LOOPTYPE}" = "zisofs" ] + then + loop_opts="looptype=zisofs loop=/zisofs" + elif [ "${LOOPTYPE}" = "normal" ] + then + loop_opts="looptype=normal loop=/livecd.loop" + elif [ "${LOOPTYPE}" = "noloop" ] + then + # no loop at all wanted, just a raw copy on a cd + loop_opts="looptype=noloop" + fi + #Time to create a filesystem tree for the ISO at $clst_cdroot_path. #We extract the "cdtar" to this directory, which will normally contains a pre-built #binary boot-loader/filesystem skeleton for the ISO. @@ -85,12 +99,12 @@ case $1 in echo >> $icfg echo "label $x" >> $icfg echo " kernel $x" >> $icfg - echo " append initrd=$x.igz root=/dev/ram0 init=/linuxrc loop=/livecd.loop cdroot vga=0x317 splash=silent" >> $icfg + echo " append initrd=$x.igz root=/dev/ram0 init=/linuxrc ${loop_opts} cdroot vga=0x317 splash=silent" >> $icfg echo >> $icfg echo " $x" >> $kmsg echo "label $x-nofb" >> $icfg echo " kernel $x" >> $icfg - echo " append initrd=$x.igz root=/dev/ram0 init=/linuxrc loop=/livecd.loop cdroot" >> $icfg + echo " append initrd=$x.igz root=/dev/ram0 init=/linuxrc ${loop_opts} cdroot" >> $icfg echo >> $icfg echo " ${x}-nofb" >> $kmsg done -- 2.26.2