1 # Copyright 1999-2004 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo/src/catalyst/examples/livecd/runscript/Attic/default-runscript.sh,v 1.18 2004/02/26 04:35:07 brad_mssw Exp $
5 #return codes to be used by archscript
12 case $clst_livecd_cdfstype in
14 cmdline_opts="looptype=zisofs loop=/zisofs"
17 cmdline_opts="looptype=normal loop=/livecd.loop"
20 cmdline_opts="looptype=noloop"
23 cmdline_opts="looptype=squashfs loop=/livecd.squashfs"
26 cmdline_opts="looptype=gcloop loop=/livecd.gcloop"
30 source ${clst_livecd_archscript}
34 #We get genkernel-built kernels and initrds in place, create the loopback fs on
35 #$clst_cdroot_path, mount it, copy our bootable filesystem over, umount it, and
36 #we then have a ready-to-burn ISO tree at $clst_cdroot_path.
38 echo "Calculating size of loopback filesystem..."
39 loopsize=`du -ks $clst_chroot_path | cut -f1`
40 [ "$loopsize" = "0" ] && loopsize=1
41 #increase the size by 1/3, then divide by 4 to get 4k blocks
42 # loopsize=$(( ( $loopsize + ( $loopsize / 2 ) ) / 4 ))
43 # Add 4MB for filesystem slop
44 loopsize=`expr $loopsize + 4096`
45 echo "Creating loopback file..."
46 dd if=/dev/zero of=$clst_cdroot_path/livecd.loop bs=1k count=$loopsize || die "livecd.loop creation failure"
47 #echo "Calculating number of inodes required for ext2 filesystem..."
48 #numnodes=`find $clst_chroot_path | wc -l`
49 #numnodes=$(( $numnodes + 200 ))
50 mke2fs -m 0 -F -q $clst_cdroot_path/livecd.loop || die "Couldn't create ext2 filesystem"
51 # mke2fs -m 0 -F -b 4096 -q $clst_cdroot_path/livecd.loop || die "Couldn't create ext2 filesystem"
52 install -d $clst_cdroot_path/loopmount
53 sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug
54 mount -t ext2 -o loop $clst_cdroot_path/livecd.loop $clst_cdroot_path/loopmount || die "Couldn't mount loopback ext2 filesystem"
55 sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug
56 echo "cp -a $clst_chroot_path/* $clst_cdroot_path/loopmount"
57 cp -a $clst_chroot_path/* $clst_cdroot_path/loopmount
59 [ $? -ne 0 ] && { umount $clst_cdroot_path/loopmount; die "Couldn't copy files to loopback ext2 filesystem"; }
60 umount $clst_cdroot_path/loopmount || die "Couldn't unmount loopback ext2 filesystem"
61 rm -rf $clst_cdroot_path/loopmount
62 #now, $clst_cdroot_path should contain a proper bootable image for our iso, including
63 #boot loader and loopback filesystem.
68 rm -rf "${clst_cdroot_path}/zisofs" > /dev/null 2>&1
69 echo "Creating zisofs..."
70 mkzftree -z 9 -p2 "${clst_chroot_path}" "${clst_cdroot_path}/zisofs" || die "Could not run mkzftree, did you emerge zisofs"
75 echo "Copying files for image (no loop)..."
76 cp -a "${clst_chroot_path}/*" "${clst_cdroot_path}" || die "Could not copy files to image (no loop)"
82 compress_gcloop_ucl -b 131072 -c 10 "${clst_cdroot_path}/livecd.loop" "${clst_cdroot_path}/livecd.gcloop" || die "compress_gcloop_ucl failed, did you emerge gcloop?"
83 rm -f "${clst_cdroot_path}/livecd.loop"
84 # only a gcloop image should exist in cdroot path
89 echo "Creating squashfs..."
90 mksquashfs -noappend "${clst_chroot_path}" "${clst_cdroot_path}/livecd.squashfs" || die "mksquashfs failed, did you emerge squashfs?"
98 $clst_CHROOT $clst_chroot_path /bin/bash << EOF
101 export CONFIG_PROTECT="-*"
102 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
104 install -d /tmp/binaries
106 [ $? -ne 0 ] && exit 1
108 while [ $count -lt $numkernels ]
114 clst_kextversion="$1"
116 $clst_CHROOT $clst_chroot_path /bin/bash << EOF
121 # Script to build each kernel, kernel-related packages
123 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
125 [ -e /var/tmp/$clst_kname.use ] && export USE="\$( cat /var/tmp/$clst_kname.use )" || unset USE
126 # Don't use pkgcache here, as the kernel source may get emerge with different USE variables
127 # (and thus different patches enabled/disabled.) Also, there's no real benefit in using the
128 # pkgcache for kernel source ebuilds.
129 emerge $clst_ksource || exit 1
130 [ ! -e /usr/src/linux ] && die "Can't find required directory /usr/src/linux"
131 #if catalyst has set NULL_VALUE, extraversion wasn't specified so we skip this part
132 if [ "$clst_kextversion" != "NULL_VALUE" ]
134 # Append Extraversion
135 sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextversion}:" /usr/src/linux/Makefile
137 if [ -n "${clst_CCACHE}" ]
139 #enable ccache for genkernel
140 export PATH="/usr/lib/ccache/bin:\${PATH}"
142 genkernel ${genkernel_args} --kerneldir=/usr/src/linux --kernel-config=/var/tmp/$clst_kname.config --minkernpackage=/tmp/binaries/$clst_kname.tar.bz2 all || exit 1
143 #now we merge any kernel-dependent packages
144 if [ -e /var/tmp/$clst_kname.packages ]
146 for x in \$( cat /var/tmp/$clst_kname.packages )
148 # we don't want to use the pkgcache for these since the results
149 # are kernel-dependent.
150 echo DEBUG emerge "\$x"
156 #now the unmerge... (wipe db entry)
157 emerge -C $clst_ksource
160 [ $? -ne 0 ] && exit 1
161 count=$(( $count + 1 ))
163 $clst_CHROOT $clst_chroot_path /bin/bash << EOF
168 find /lib/modules -name modules.dep -exec touch {} \;
170 [ $? -ne 0 ] && exit 1
174 $clst_CHROOT $clst_chroot_path /bin/bash << EOF
175 # SCRIPT TO UPDATE FILESYSTEM SPECIFIC FOR LIVECD. THIS GETS EXECUTED IN CHROOT
178 rc-update del iptables default
179 rc-update del netmount default
180 # rc-update add hotplug default
181 # rc-update add kudzu default
182 rc-update add autoconfig default
183 rc-update del keymaps
184 rc-update del consolefont
185 rc-update add metalog default
186 rc-update add modules default
187 [ -e /etc/init.d/bootsplash ] && rc-update add bootsplash default
188 rm -rf /etc/localtime
189 cp /usr/share/zoneinfo/GMT /etc/localtime
190 echo "livecd" > /etc/hostname
191 sed -i -e '/\/dev\/[RBS]*/ s/^/#/' /etc/fstab
192 echo "tmpfs / tmpfs defaults 0 0" >> /etc/fstab
193 sed -i -e '/dev-state/ s/^/#/' /etc/devfsd.conf
194 # END OF SCRIPT TO UPDATE FILESYSTEM
196 [ $? -ne 0 ] && exit 1
200 find $clst_chroot_path/usr/lib -iname "*.pyc" -exec rm -f {} \;
208 if [ "${clst_livecd_cdfstype}" = "normal" ]
212 elif [ "${clst_livecd_cdfstype}" = "zisofs" ]
216 elif [ "${clst_livecd_cdfstype}" = "noloop" ]
220 elif [ "${clst_livecd_cdfstype}" = "gcloop" ]
224 elif [ "${clst_livecd_cdfstype}" = "squashfs" ]