1 # Copyright 1999-2004 Gentoo Foundation
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.25 2005/03/29 18:53:32 wolf31o2 Exp $
5 #return codes to be used by archscript
11 case ${clst_livecd_cdfstype} in
13 cmdline_opts="looptype=zisofs loop=/zisofs"
16 cmdline_opts="looptype=normal loop=/livecd.loop"
19 cmdline_opts="looptype=noloop"
22 cmdline_opts="looptype=squashfs loop=/livecd.squashfs"
25 cmdline_opts="looptype=gcloop loop=/livecd.gcloop"
29 source ${clst_livecd_archscript}
31 create_normal_loop() {
33 #We get genkernel-built kernels and initrds in place, create the loopback fs on
34 #$clst_cdroot_path, mount it, copy our bootable filesystem over, umount it, and
35 #we then have a ready-to-burn ISO tree at $clst_cdroot_path.
37 echo "Calculating size of loopback filesystem..."
38 loopsize=`du -ks ${clst_chroot_path} | cut -f1`
39 [ "${loopsize}" = "0" ] && loopsize=1
40 # Add 4MB for filesystem slop
41 loopsize=`expr ${loopsize} + 4096`
42 echo "Creating loopback file..."
43 dd if=/dev/zero of=${clst_cdroot_path}/livecd.loop bs=1k count=${loopsize} || die "livecd.loop creation failure"
44 mke2fs -m 0 -F -q ${clst_cdroot_path}/livecd.loop || die "Couldn't create ext2 filesystem"
45 install -d ${clst_cdroot_path}/loopmount
46 sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug
47 mount -t ext2 -o loop ${clst_cdroot_path}/livecd.loop ${clst_cdroot_path}/loopmount || die "Couldn't mount loopback ext2 filesystem"
48 sync; sync; sleep 3 #try to work around 2.6.0+ loopback bug
49 echo "cp -a ${clst_chroot_path}/* ${clst_cdroot_path}/loopmount"
50 cp -a ${clst_chroot_path}/* ${clst_cdroot_path}/loopmount
52 [ $? -ne 0 ] && { umount ${clst_cdroot_path}/loopmount; die "Couldn't copy files to loopback ext2 filesystem"; }
53 umount ${clst_cdroot_path}/loopmount || die "Couldn't unmount loopback ext2 filesystem"
54 rm -rf ${clst_cdroot_path}/loopmount
55 #now, $clst_cdroot_path should contain a proper bootable image for our iso, including
56 #boot loader and loopback filesystem.
61 rm -rf "${clst_cdroot_path}/zisofs" > /dev/null 2>&1
62 echo "Creating zisofs..."
63 mkzftree -z 9 -p2 "${clst_chroot_path}" "${clst_cdroot_path}/zisofs" || die "Could not run mkzftree, did you emerge zisofs"
69 echo "Copying files for image (no loop)..."
70 cp -a "${clst_chroot_path}"/* "${clst_cdroot_path}" || die "Could not copy files to image (no loop)"
76 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?"
77 rm -f "${clst_cdroot_path}/livecd.loop"
78 # only a gcloop image should exist in cdroot path
83 echo "Creating squashfs..."
84 mksquashfs "${clst_chroot_path}" "${clst_cdroot_path}/livecd.squashfs" -noappend || die "mksquashfs failed, did you emerge squashfs-tools?"
96 # setup genkernel and do any pre-kernel merge opts
97 cp -a ${clst_sharedir}/livecd/runscript-support/pre-kmerge.sh ${clst_chroot_path}/tmp
98 ${clst_CHROOT} ${clst_chroot_path} /tmp/pre-kmerge.sh || exit 1
99 rm -f ${clst_chroot_path}/tmp/pre-kmerge.sh
101 # the kernel merge process is done in a chroot
102 cp -a ${clst_sharedir}/livecd/runscript-support/kmerge.sh ${clst_chroot_path}/tmp
104 while [ ${count} -lt ${numkernels} ]
106 export clst_kname="$1"
108 export clst_ksource="$1"
110 export clst_kextversion="$1"
112 ${clst_CHROOT} ${clst_chroot_path} /tmp/kmerge.sh || exit 1
113 count=$(( ${count} + 1 ))
115 rm -f ${clst_chroot_path}/tmp/kmerge.sh
117 # clean up genkernel and do any post-kernel merge opts
118 cp -a ${clst_sharedir}/livecd/runscript-support/post-kmerge.sh ${clst_chroot_path}/tmp
119 ${clst_CHROOT} ${clst_chroot_path} /tmp/post-kmerge.sh || exit 1
120 rm -f ${clst_chroot_path}/tmp/post-kmerge.sh
124 # move over the motd (if applicable)
125 if [ -n "${clst_livecd_motd}" ]
127 cp -a ${clst_livecd_motd} ${clst_chroot_path}/etc/motd
129 cp -a ${clst_sharedir}/livecd/files/generic.motd.txt \
130 ${clst_sharedir}/livecd/files/universal.motd.txt \
131 ${clst_sharedir}/livecd/files/minimal.motd.txt \
132 ${clst_sharedir}/livecd/files/environmental.motd.txt \
133 ${clst_sharedir}/livecd/files/gamecd.motd.txt \
134 ${clst_chroot_path}/etc
137 # move over the xinitrc (if applicable)
138 if [ -n "${clst_livecd_xinitrc}" ]
140 cp -a ${clst_livecd_xinitrc} ${clst_chroot_path}/etc/X11/xinit/xinitrc
143 # move over the environment
144 cp ${clst_sharedir}/livecd/files/livecd-bashrc \
145 ${clst_chroot_path}/root/.bashrc
146 cp ${clst_sharedir}/livecd/files/livecd-bash_profile \
147 ${clst_chroot_path}/root/.bash_profile
148 cp ${clst_sharedir}/livecd/files/livecd-local.start \
149 ${clst_chroot_path}/etc/conf.d/local.start
150 mkdir -p /usr/share/faces
151 cp ${clst_sharedir}/livecd/files/gentoo.png \
152 ${clst_chroot_path}/usr/share/faces
154 # touch /etc/startx if our livecd/type requires it
155 if [ "${clst_livecd_type}" = "gentoo-gamecd" ] #\
156 #|| [ "${clst_livecd_type}" = "gentoo-release-environmental" ]
158 touch ${clst_chroot_path}/etc/startx
161 # now, finalize and tweak the livecd fs (inside of the chroot)
162 cp ${clst_sharedir}/livecd/runscript-support/livecdfs-update.sh ${clst_chroot_path}/tmp
163 ${clst_CHROOT} ${clst_chroot_path} /tmp/livecdfs-update.sh || exit 1
164 rm -f ${clst_chroot_path}/tmp/livecdfs-update.sh
166 # execute gamecdfs-update.sh if we're a gamecd
167 if [ "${clst_livecd_type}" = "gentoo-gamecd" ]
169 cp ${clst_sharedir}/livecd/runscript-support/gamecdfs-update.sh ${clst_chroot_path}/tmp
170 ${clst_CHROOT} ${clst_chroot_path} /tmp/gamecdfs-update.sh || exit 1
171 rm -f ${clst_chroot_path}/tmp/gamecdfs-update.sh
174 # if the user has their own fs update script, execute it
175 if [ -n "${clst_livecd_fsscript}" ]
177 cp ${clst_livecd_fsscript} ${clst_chroot_path}/tmp/fsscript.sh
178 chmod 755 ${clst_chroot_path}/tmp/fsscript.sh
179 ${clst_CHROOT} ${clst_chroot_path} /tmp/fsscript.sh || exit 1
180 rm -f ${clst_chroot_path}/tmp/fsscript.sh
185 find ${clst_chroot_path}/usr/lib -iname "*.pyc" -exec rm -f {} \;
193 if [ "${clst_livecd_cdfstype}" = "normal" ]
197 elif [ "${clst_livecd_cdfstype}" = "zisofs" ]
201 elif [ "${clst_livecd_cdfstype}" = "noloop" ]
205 elif [ "${clst_livecd_cdfstype}" = "gcloop" ]
209 elif [ "${clst_livecd_cdfstype}" = "squashfs" ]