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/livecd/runscript/Attic/default-runscript.sh,v 1.1 2004/03/04 23:29:45 zhen 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
126 #set the timezone for the kernel build
128 ln -s /usr/share/zoneinfo/UTC /etc/localtime
130 [ -e /var/tmp/$clst_kname.use ] && export USE="\$( cat /var/tmp/$clst_kname.use )" || unset USE
131 # Don't use pkgcache here, as the kernel source may get emerge with different USE variables
132 # (and thus different patches enabled/disabled.) Also, there's no real benefit in using the
133 # pkgcache for kernel source ebuilds.
134 emerge $clst_ksource || exit 1
135 [ ! -e /usr/src/linux ] && die "Can't find required directory /usr/src/linux"
136 #if catalyst has set NULL_VALUE, extraversion wasn't specified so we skip this part
137 if [ "$clst_kextversion" != "NULL_VALUE" ]
139 # Append Extraversion
140 sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextversion}:" /usr/src/linux/Makefile
142 if [ -n "${clst_CCACHE}" ]
144 #enable ccache for genkernel
145 export PATH="/usr/lib/ccache/bin:\${PATH}"
147 genkernel ${genkernel_args} --kerneldir=/usr/src/linux --kernel-config=/var/tmp/$clst_kname.config --minkernpackage=/tmp/binaries/$clst_kname.tar.bz2 all || exit 1
148 #now we merge any kernel-dependent packages
149 if [ -e /var/tmp/$clst_kname.packages ]
151 for x in \$( cat /var/tmp/$clst_kname.packages )
153 # we don't want to use the pkgcache for these since the results
154 # are kernel-dependent.
155 echo DEBUG emerge "\$x"
161 #now the unmerge... (wipe db entry)
162 emerge -C $clst_ksource
165 [ $? -ne 0 ] && exit 1
166 count=$(( $count + 1 ))
168 $clst_CHROOT $clst_chroot_path /bin/bash << EOF
173 find /lib/modules -name modules.dep -exec touch {} \;
175 [ $? -ne 0 ] && exit 1
179 cat > $clst_chroot_path/etc/init.d/local << EOF
181 # Copyright 1999-2003 Gentoo Technologies, Inc.
182 # Distributed under the terms of the GNU General Public License v2
183 # $Header: /var/cvsroot/gentoo/src/catalyst/livecd/runscript/Attic/default-runscript.sh,v 1.1 2004/03/04 23:29:45 zhen Exp $
190 ebegin "Auto-scrambling root password for security"
191 echo root:`pwgen -s 16` | chpasswd > /dev/null 2>&1
192 eend $? "Failed to start local."
196 ebegin "Stopping local"
197 eend $? "Failed to stop local."
201 $clst_CHROOT $clst_chroot_path /bin/bash << EOF
202 # SCRIPT TO UPDATE FILESYSTEM SPECIFIC FOR LIVECD. THIS GETS EXECUTED IN CHROOT
205 if [ -e /etc/sshd/sshd_config ]
207 #allow root logins to the livecd by default
208 sed -e "s/^#PermitRootLogin\ yes/PermitRootLogin\ yes/" /etc/ssh/sshd_config > /etc/ssh/sshd_config1
209 mv /etc/ssh/sshd_config1 /etc/ssh/sshd_config
212 rc-update del iptables default
213 rc-update del netmount default
214 # rc-update add hotplug default
215 # rc-update add kudzu default
216 rc-update add autoconfig default
217 rc-update del keymaps
218 rc-update del consolefont
219 rc-update add metalog default
220 rc-update add modules default
221 [ -e /etc/init.d/bootsplash ] && rc-update add bootsplash default
222 rm -rf /etc/localtime
223 cp /usr/share/zoneinfo/GMT /etc/localtime
224 echo "livecd" > /etc/hostname
225 sed -i -e '/\/dev\/[RBS]*/ s/^/#/' /etc/fstab
226 echo "tmpfs / tmpfs defaults 0 0" >> /etc/fstab
227 sed -i -e '/dev-state/ s/^/#/' /etc/devfsd.conf
228 # END OF SCRIPT TO UPDATE FILESYSTEM
230 [ $? -ne 0 ] && exit 1
234 find $clst_chroot_path/usr/lib -iname "*.pyc" -exec rm -f {} \;
242 if [ "${clst_livecd_cdfstype}" = "normal" ]
246 elif [ "${clst_livecd_cdfstype}" = "zisofs" ]
250 elif [ "${clst_livecd_cdfstype}" = "noloop" ]
254 elif [ "${clst_livecd_cdfstype}" = "gcloop" ]
258 elif [ "${clst_livecd_cdfstype}" = "squashfs" ]