# Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: $ # These variables are to be used for creating the menu entry and also to tell # the CD what to execute GAME_NAME="Unreal Tournament 2004 Demo" GAME_SHORT_NAME="UT2004 Demo" GAME_EXECUTABLE="/usr/games/bin/ut2004demo" #return codes to be used by archscript die() { echo "$1" exit 1 } case $clst_livecd_cdfstype in zisofs) cmdline_opts="looptype=zisofs loop=/zisofs" ;; normal) cmdline_opts="looptype=normal loop=/livecd.loop" ;; noloop) cmdline_opts="looptype=noloop" ;; squashfs) cmdline_opts="looptype=squashfs loop=/livecd.squashfs" ;; gcloop) cmdline_opts="looptype=gcloop loop=/livecd.gcloop" ;; esac source ${clst_livecd_archscript} 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 )) # Add 4MB for filesystem slop loopsize=`expr $loopsize + 4096` echo "Creating loopback file..." dd if=/dev/zero of=$clst_cdroot_path/livecd.loop bs=1k 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 -q $clst_cdroot_path/livecd.loop || die "Couldn't create ext2 filesystem" # 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. } 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" } 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)" } create_gcloop() { create_normal_loop 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?" rm -f "${clst_cdroot_path}/livecd.loop" # only a gcloop image should exist in cdroot path } create_squashfs() { echo "Creating squashfs..." mksquashfs "${clst_chroot_path}" "${clst_cdroot_path}/livecd.squashfs" -noappend || die "mksquashfs failed, did you emerge squashfs-utils?" } case $1 in kernel) shift numkernels="$1" shift $clst_CHROOT $clst_chroot_path /bin/bash << EOF env-update source /etc/profile export CONFIG_PROTECT="-*" [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript emerge genkernel install -d /tmp/binaries EOF [ $? -ne 0 ] && exit 1 count=0 while [ $count -lt $numkernels ] do clst_kname="$1" shift clst_ksource="$1" shift clst_kextversion="$1" shift $clst_CHROOT $clst_chroot_path /bin/bash << EOF die() { echo "$1" exit 1 } # Script to build each kernel, kernel-related packages source /etc/profile [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript rm -f /usr/src/linux #set the timezone for the kernel build rm /etc/localtime ln -s /usr/share/zoneinfo/UTC /etc/localtime [ -e /var/tmp/$clst_kname.use ] && export USE="\$( cat /var/tmp/$clst_kname.use )" || unset USE # Don't use pkgcache here, as the kernel source may get emerge with different USE variables # (and thus different patches enabled/disabled.) Also, there's no real benefit in using the # pkgcache for kernel source ebuilds. emerge $clst_ksource || exit 1 [ ! -e /usr/src/linux ] && die "Can't find required directory /usr/src/linux" #if catalyst has set NULL_VALUE, extraversion wasn't specified so we skip this part if [ "$clst_kextversion" != "NULL_VALUE" ] then # Append Extraversion sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextversion}:" /usr/src/linux/Makefile fi if [ -n "${clst_CCACHE}" ] then #enable ccache for genkernel export PATH="/usr/lib/ccache/bin:\${PATH}" fi [ -e /etc/init.d/bootsplash ] && sed -i -e 's/gentoo/livecd-2004.1/' /etc/conf.d/bootsplash genkernel ${genkernel_args} --kerneldir=/usr/src/linux --kernel-config=/var/tmp/$clst_kname.config --minkernpackage=/tmp/binaries/$clst_kname.tar.bz2 all || exit 1 #now we merge any kernel-dependent packages if [ -e /var/tmp/$clst_kname.packages ] then for x in \$( cat /var/tmp/$clst_kname.packages ) do # we don't want to use the pkgcache for these since the results # are kernel-dependent. echo DEBUG emerge "\$x" emerge "\$x" update-modules done fi #fix to get modprobe.conf ln -s /lib/modules/\`sed -n '1s/.* //;1s/"//g; 1p' /usr/src/linux/include/linux/version.h\` /lib/modules/`uname -r` /sbin/modules-update rm `uname -r` cd /usr/src rm -rf linux* #now the unmerge... (wipe db entry) emerge -C $clst_ksource unset USE EOF [ $? -ne 0 ] && exit 1 count=$(( $count + 1 )) done $clst_CHROOT $clst_chroot_path /bin/bash << EOF #cleanup steps source /etc/profile emerge -C genkernel /sbin/depscan.sh find /lib/modules -name modules.dep -exec touch {} \; EOF [ $? -ne 0 ] && exit 1 ;; preclean) cat > $clst_chroot_path/etc/conf.d/local.start << EOF # /etc/conf.d/local.start: # This is a good place to load any misc. # programs on startup ( 1>&2 ) echo "root:\`pwgen -s 16\`" | chpasswd > /dev/null 2>&1 GLTYPE=nvidia modprobe -qs nvidia > /dev/null 2>&1 if [ "\`lsmod | grep nvidia\`" ] then echo "NVIDIA driver loaded." else modprobe -qs fglrx > /dev/null 2>&1 if [ "\`lsmod | grep fglrx\`" ] then echo "ATI driver loaded." GLTYPE=ati else echo "**********************************************************" echo "NVIDIA or ATI drivers unable to load; aborting." echo "${GAME_SHORT_NAME} requires modern NVIDIA or ATI graphics hardware." echo "**********************************************************" echo "" GLTYPE=xfree fi fi opengl-update \${GLTYPE} VERTREFRESH="\`ddcxinfo-knoppix -vsync\`" if [ "$VERTREFRESH" = "0-0" ] then echo "No DDC information detected; assuming reasonable defaults." VERTREFRESH=50-80 HORIZSYNC=30-70 else HORIZSYNC="\`ddcxinfo-knoppix -hsync\`" fi sed -i -e "s/##VERTREFRESH##/\$VERTREFRESH/" \ -e "s/##HORIZSYNC##/\$HORIZSYNC/" \ -e "s/DefaultColorDepth 16/DefaultColorDepth 24/" \ /etc/X11/XF86Config-4 # Experimental ALSA stuff if [ -d /proc/asound/card0 ]; then amixer scontrols > /etc/amixer [ -n "\`grep Master /etc/amixer\`" ] && amixer set Master 75% \ && amixer set Master unmute [ -n "\`grep PCM /etc/amixer\`" ] && amixer set PCM 75% \ && amixer set PCM unmute [ -n "\`grep Mic /etc/amixer\`" ] && amixer set Mic 75% \ && amixer set Mic cap [ -n "\`grep Wave /etc/amixer\`" ] && amixer set Wave 75% \ && amixer set Wave unmute [ -n "\`grep Capture /etc/amixer\`" ] && amixer set Capture 75% \ && amixer set Capture cap && amixer set Capture unmute fi EOF cat > $clst_chroot_path/etc/motd << EOF Welcome to Gentoo Linux. This is a special version of the Gentoo Linux LiveCD. This CD is a GameCD for ${GAME_NAME} and is fully playable. You can also use this CD to install Gentoo Linux. Detailed instructions can be found online in the Gentoo Handbook at: http://www.gentoo.org/doc/en/handbook/index.xml To (re)start the game, type "startx" at the prompt below. EOF cat > $clst_chroot_path/usr/share/fluxbox/menu << EOF [begin] (Gentoo) [exec] (${GAME_SHORT_NAME}) {${GAME_EXECUTABLE}} [exec] (Mozilla Firefox) {firefox http://www.gentoo.org} [exec] (Volume) {xterm -e "alsamixer"} [submenu] (Setup Network) [exec] (net-setup eth0) {xterm -e "net-setup eth0"} [exec] (net-setup eth1) {xterm -e "net-setup eth1"} [end] [submenu] (Terminals) [exec] (xterm) {xterm -fg white -bg black} [end] [submenu] (Settings) [workspaces] (Workspace List) [submenu] (Styles) {Choose a style...} [stylesdir] (/usr/share/fluxbox/styles) [end] [config] (Configure) [reconfig] (Reload config) [end] [restart] (Restart) [end] EOF cat > $clst_chroot_path/root/.xinitrc << EOF ${GAME_EXECUTABLE} & exec fluxbox EOF cat > $clst_chroot_path/root/.bash_profile << EOF #!/bin/bash if [ -e /etc/startgame ] then rm -f /etc/startgame startx cat /etc/motd fi EOF cat > $clst_chroot_path/etc/conf.d/net << EOF iface_eth0="dhcp" iface_eth1="dhcp" EOF cat > $clst_chroot_path/usr/sbin/opengl-update << EOF #!/bin/bash source /etc/init.d/functions.sh if [ "\`id -u\`" -ne 0 ] then eerror "\${0}: must be root." exit 1 fi usage() { cat << FOO usage: opengl-update note: This utility switch between OpenGL implementations. Currently there are two supported implementations, namely "xfree" and "nvidia", the implementations for XFree86 and the NVidia drivers respectively. examples: opengl-update xfree This will setup things to use libGL.so from XFree86 opengl-update nvidia This will setup things to use libGL.so from the NVidia drivers. FOO exit 1 } if [ "\$#" -ne 1 ] then usage fi if [ ! -d /usr/lib/opengl/\${1} ] then usage else ebegin "Switching to \${1} OpenGL interface" #set up the \$LDPATH echo "LDPATH=/usr/lib/opengl/\${1}/lib" >/etc/env.d/09opengl /usr/sbin/env-update &>/dev/null #setup the /usr/lib/libGL.so symlink rm -f /etc/opengl/libGL.so /etc/opengl/libGL.so.1 realname="\$(readlink /usr/lib/opengl/\${1}/lib/libGL.so)" ln -sf /usr/lib/opengl/\${1}/lib/\${realname} \ /etc/opengl/libGL.so ln -sf /usr/lib/opengl/\${1}/lib/\${realname} \ /etc/opengl/libGL.so.1 #setup the /usr/X11R6/lib/libMesaGL.so symlink rm -f /etc/opengl/libMesaGL.so realname="\$(readlink /usr/lib/opengl/\${1}/lib/libGL.so)" ln -sf /usr/lib/opengl/\${1}/lib/\${realname} \ /etc/opengl/libMesaGL.so rm -f /etc/opengl/libGLcore.so* if [ -e /usr/lib/opengl/\${1}/lib/libGLcore.so ] then realname="\$(readlink /usr/lib/opengl/\${1}/lib/libGLcore.so)" ln -sf /usr/lib/opengl/\${1}/lib/\${realname} \ /etc/opengl/libGLcore.so ln -sf /usr/lib/opengl/\${1}/lib/\${realname} \ /etc/opengl/libGLcore.so.1 fi #setup the /usr/X11R6/lib/modules/extensions/libglx.so symlink rm -f /etc/opengl/libglx.* if [ -e /usr/lib/opengl/\${1}/extensions/libglx.so ] then ln -sf /usr/lib/opengl/\${1}/extensions/libglx.so \ /etc/opengl/libglx.so fi #setup the /usr/X11R6/lib/modules/extensions/libglx.a symlink if [ -e /usr/lib/opengl/\${1}/extensions/libglx.a ] then ln -sf /usr/lib/opengl/\${1}/extensions/libglx.a \ /etc/opengl/libglx.a fi eend 0 fi # vim:ts=4 EOF cat > $clst_chroot_path/usr/sbin/openglify << EOF #move symlinks to a malleable /etc/opengl directory. install -d /etc/opengl mv /usr/lib/libGL.* /etc/opengl/ mv /usr/lib/libGLcore.* /etc/opengl/ ln -sf /etc/opengl/libGL.so /usr/lib/libGL.so ln -sf /etc/opengl/libGL.so.1 /usr/lib/libGL.so.1 ln -sf /etc/opengl/libGLcore.so /usr/lib/libGLcore.so ln -sf /etc/opengl/libGLcore.so.1 /usr/lib/libGLcore.so.1 mv /usr/X11R6/lib/libMesaGL.so /etc/opengl/ ln -sf /etc/opengl/libMesaGL.so /usr/X11R6/lib/libMesaGL.so for x in libglx.a libglx.so do if [ -e /usr/X11R6/lib/modules/extensions/\${x} -o -L \ /usr/X11R6/lib/modules/extensions/\${x} ] then mv /usr/X11R6/lib/modules/extensions/\${x} /etc/opengl/ fi ln -s /etc/opengl/\${x} \ /usr/X11R6/lib/modules/extensions/\${x} done EOF $clst_CHROOT $clst_chroot_path /bin/bash << EOF # SCRIPT TO UPDATE FILESYSTEM SPECIFIC FOR LIVECD. THIS GETS EXECUTED IN CHROOT env-update source /etc/profile if [ -e /etc/sshd/sshd_config ] then #allow root logins to the livecd by default sed -e "s/^#PermitRootLogin\ yes/PermitRootLogin\ yes/" /etc/ssh/sshd_config > /etc/ssh/sshd_config1 mv /etc/ssh/sshd_config1 /etc/ssh/sshd_config fi rc-update del iptables default rc-update del netmount default # rc-update add hotplug default # rc-update add kudzu default rc-update add autoconfig default rc-update del keymaps rc-update del consolefont rc-update add metalog default rc-update add modules default rc-update add alsasound default rc-update add mkxf86config default [ -e /etc/init.d/bootsplash ] && rc-update add bootsplash default && sed -i -e 's/gentoo/livecd-2004.1/' /etc/conf.d/bootsplash rm -rf /etc/localtime cp /usr/share/zoneinfo/GMT /etc/localtime echo "livecd" > /etc/hostname echo "2004.1" > /etc/dnsdomainname sed -i -e '/\/dev\/[RBS]*/ s/^/#/' /etc/fstab echo "tmpfs / tmpfs defaults 0 0" >> /etc/fstab sed -i -e '/dev-state/ s/^/#/' /etc/devfsd.conf sed -i -e 's/localhost/localhost livecd/' /etc/hosts sed -i -e 's/DRIVER nv/DRIVER nvidia/' /usr/share/hwdata/Cards sed -i -e 's/DRIVER radeon/DRIVER fglrx/' /usr/share/hwdata/Cards sh /usr/sbin/openglify touch /etc/startgame /etc/asound.state echo "alias cp='cp -i'" >> /etc/profile echo "alias ls='ls --color'" >> /etc/profile echo "alias mv='mv -i'" >> /etc/profile echo "alias pico='nano -w'" >> /etc/profile echo "alias rm='rm -i'" >> /etc/profile # END OF SCRIPT TO UPDATE FILESYSTEM EOF [ $? -ne 0 ] && exit 1 ;; clean) find $clst_chroot_path/usr/lib -iname "*.pyc" -exec rm -f {} \; ;; bootloader) ;; cdfs) loopret=1 if [ "${clst_livecd_cdfstype}" = "normal" ] then create_normal_loop loopret=$? elif [ "${clst_livecd_cdfstype}" = "zisofs" ] then create_zisofs loopret=$? elif [ "${clst_livecd_cdfstype}" = "noloop" ] then create_noloop loopret=$? elif [ "${clst_livecd_cdfstype}" = "gcloop" ] then create_gcloop loopret=$? elif [ "${clst_livecd_cdfstype}" = "squashfs" ] then create_squashfs loopret=$? fi exit $loopret ;; iso) ;; esac exit 0