summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/livecd/livecd-ng')
-rw-r--r--src/livecd/livecd-ng509
1 files changed, 0 insertions, 509 deletions
diff --git a/src/livecd/livecd-ng b/src/livecd/livecd-ng
deleted file mode 100644
index 8fcdc61006..0000000000
--- a/src/livecd/livecd-ng
+++ /dev/null
@@ -1,509 +0,0 @@
-#!/bin/bash
-# Daniel Robbins, 28 Sep 2002 <drobbins@gentoo.org> , Bob Johnson <livewire@gentoo.org>
-# Copyright 2002 Gentoo Technologies, Inc; http://www.gentoo.org
-# Released under the GNU General Public License version 2
-
-## HELP AND BASIC ARGUMENT PROCESSING
-#####################################
-export CD_PROFILE=${1}
-usage() {
- cat <<EOF
-livecd-ng: Gentoo Linux LiveCD-generation tool
-Syntax: livecd <profile> <command1> ...
-
-Essential Commands:
- fetch Fetch required sources
- build Build a bootable LiveCD tree (requires 'fetch')
- delete Remove chroot directory (to allow 'build' to work)
- kernbuild Perform only the kernel building steps (requires 'build')
- clean Prepare chroot for CD by removing extraneous data
- cloop Create compressed loopback filesystem
- isogen Generate the final bootable LiveCD ISO image (requires 'prep')
- all Run all steps to build a livecd iso
-Cleanup Commands:
- initrd-delete Clean the LiveCD initrd directory
- umount Unmount things that are bound to chroot directories
- (e.g. /usr/portage)
-
-Other Commands:
- enter Use "chroot" to start a shell inside the CD root.
- can be used to modify the CD before preparing an iso.
-
- -h|--help Display this screen
-
-Copyright 2002 Gentoo Technologies, Inc. (http://www.gentoo.org)
-Distributed under the GNU Public License version 2
-EOF
-}
-
-if [ "$1" = "-h" ] || [ "$1" = "--help" ]
-then
- usage
- exit 1
-fi
-
-if [ "`whoami`" != "root" ]
-then
- echo "$0: This script requires root privileges to operate."
- exit 1
-fi
-
-if [ -z "$LIVECD_ROOT" ]
-then
- echo "Using current working directory as LIVECD_ROOT."
- export LIVECD_ROOT=.
-fi
-
-if [ -z "$1" ]
-then
- echo "$0: Please specify a profile to use."
- exit 1
-fi
-
-if [ ! -d "${LIVECD_ROOT}/profiles/${1}" ]
-then
- echo "$0: Cannot find profile directory:"
- echo "${LIVECD_ROOT}/profiles/${1}"
- exit 1
-fi
-
-if [ ! -e "${LIVECD_ROOT}/profiles/${1}/settings" ]
-then
- echo "$0: Profile \"${1}\" missing \"settings\" file."
- exit 1
-fi
-
-if [ ! -e "${LIVECD_ROOT}/profiles/${1}/settings" ]
-then
- echo "$0: Cannot find global settings"
- exit 1
-fi
-
-PROG=${0}
-
-## ERROR HANDLING
-#####################################
-
-die() {
- if [ -n "$1" ]
- then
- echo "${PROG}: error: $1"
- else
- echo "${PROG}: aborting."
- fi
- exit 1
-}
-
-## CONVENIENCE FUNCTIONS
-#####################################
-
-#"zapmost" is used to remove an entire directory tree, *except* for certain
-#specified files. Arg 1 is the tree, args 2+ are the items to keep, which can
-#be files or directories at the root or deeper levels.
-
-#example calls:
-#zapmost /usr/share/locales en_us
-#zapmost /usr/share/terminfo l/linux
-
-zapmost() {
- local rootdir
- rootdir="${CD_BUILDCHROOT}${1}/"
- [ ! -e "$rootdir" ] && echo "zapmost: $rootdir not found; skipping..." && return 1
- install -d ${CD_BUILDTEMP}/zap
- local dirs
- shift
- local x
- for x in ${*}
- do
- if [ "${x##*/}" = "${x}" ]
- then
- #one deep
- mv ${rootdir}${x} ${CD_BUILDTEMP}/zap
- else
- #more than one deep; create intermediate directories
- dirs=${x%/*}
- install -d ${CD_BUILDTEMP}/zap/${dirs}
- mv ${rootdir}${x} ${CD_BUILDTEMP}/zap/${x}
- fi
- done
- rm -rf ${rootdir}*
- mv ${CD_BUILDTEMP}/zap/* ${rootdir}
-}
-
-## GRABBING PROFILE SETTINGS
-#####################################
-source ${LIVECD_ROOT}/profiles/${CD_PROFILE}/settings
-if [ "$KERNCONFIG" = "" ]
-then
- KERNCONFIG="kernel-config"
-fi
-CD_BUILDTEMP=${CD_BUILDROOT}/tmp
-CD_BUILDCHROOT=${CD_BUILDROOT}/cdroot
-#it's important to keep CDROOT defined; some stuff uses it, and it may be nice to switch over
-#to it since it's a shorter name.
-export CDROOT=${CD_BUILDCHROOT}
-export CCACHEDIR=${CCACHEDIR:-/root/.ccache}
-CD_STAGEFILE="${CD_STAGELOC}/${CD_STAGETARBALL##*/}"
-LOOP_ROOT=${CD_BUILDROOT}/looproot
-ISO_ROOT=${CD_BUILDROOT}/isoroot
-LOOP_FILE=${CD_BUILDROOT}/livecd.loop
-CLOOP_FILE=${CD_BUILDROOT}/livecd.cloop
-
-#A good way to view/debug the environment....
-#set | grep CD_
-
-umount_all() {
- local x
- for x in /usr/portage /proc /home/distfiles /dev ${CCACHEDIR} /tmp/livecd -initrd
- do
- umount ${CD_BUILDCHROOT}${x} 2>/dev/null || true
- done
- umount ${LOOP_ROOT} 2>/dev/null || true
- echo "Bind mounts should all be unmounted now."
-}
-
-mount_all() {
- mount -o bind /dev $CD_BUILDCHROOT/dev || chroot_die
- mount -o bind /proc $CD_BUILDCHROOT/proc || chroot_die
- mount -o bind $CD_PORTDIR $CD_BUILDCHROOT/usr/portage || chroot_die
- [ ! -e $CD_BUILDCHROOT/tmp/livecd ] && install -d $CD_BUILDCHROOT/tmp/livecd
- mount -o bind $CD_BUILDTEMP $CD_BUILDCHROOT/tmp/livecd || chroot_die
- mount -o bind ${CCACHEDIR} ${CD_BUILDCHROOT}/${CCACHEDIR} || chroot_die
- mount -o bind $CD_DISTDIR $CD_BUILDCHROOT/home/distfiles || chroot_die
-}
-
-chroot_die() {
- umount_all
- if [ -n "$1" ]
- then
- echo "chroot_generate: error: $1"
- else
- echo "chroot_generate: aborting."
- fi
- exit 1
-}
-
-#clean up if we are interrupted:
-trap "chroot_die" SIGINT SIGQUIT
-
-pre_fetch() {
- #extract stage tarball...
- if [ ! -e "$CD_STAGEFILE" ]
- then
- ( cd $CD_STAGELOC; wget $CD_STAGETARBALL )
- fi
-}
-
-build_setup() {
- cat > $CD_BUILDTEMP/build-setup << EOF
-#env-update is important for gcc-3.2.1-r6 and higher.
-env-update
-source /etc/profile
-export DISTDIR=/home/distfiles
-export CONFIG_PROTECT='-*'
-#lilo appears to need to write to /etc do do awking
-export FEATURES="-sandbox ccache distcc"
-export PATH="/usr/bin/ccache:/usr/lib/distcc/bin:\${PATH}"
-export CFLAGS="$CD_CFLAGS"
-export CXXFLAGS="$CD_CFLAGS"
-export USE="$CD_USE"
-export PKGDIR=/tmp/livecd/packages
-export CLEAN_DELAY=0
-[ ! -e /tmp/log ] && install -d /tmp/log
-
-ewrapper() {
- local opts
- local pkgs
- for x in \$*
- do
- if [ "\${x:0:1}" = "-" ]
- then
- opts="\$opts \$x"
- else
- pkgs="\$pkgs \$x"
- fi
- done
- for x in \$pkgs
- do
- echo ">>> Emerging \${x}..."
-#once the --buildpkg bug is fixed, we may have to --buildpkg --usepkg
- emerge --buildpkg \$opts \$x 2>&1 | cat >> /tmp/log/emerge.log
- if [ \$? -ne 0 ]
- then
- echo ">>> Error emerging \${x}."
- exit 1
- fi
- done
-}
-
-cwrapper() {
- echo ">>> Executing \${*}..."
- \${*} 2>&1 | cat >> /tmp/log/build.log
- if [ \$? -ne 0 ]
- then
- echo ">>> Error executing \${*}."
- exit 1
- fi
-}
-EOF
- }
-
-base_build() {
- cp "${LIVECD_ROOT}/profiles/${CD_PROFILE}/aux-files/freeramdisk.c" $CD_BUILDTEMP || chroot_die
- cp ${LIVECD_ROOT}/profiles/${CD_PROFILE}/base-packages $CD_BUILDTEMP || chroot_die
- if [ -d ${LIVECD_ROOT}/profiles/${CD_PROFILE}/launcher ]
- then
- cp -a ${LIVECD_ROOT}/profiles/${CD_PROFILE}/launcher $CD_BUILDTEMP || chroot_die
- fi
- cat > $CD_BUILDTEMP/base-build << EOF
-cd /tmp/livecd
-source /tmp/livecd/build-setup || exit 1
-mv /etc/fstab /etc/fstab.bak
-#update portage, then get ccache up and running.
-#on separate line to allow for a portage db upgrade
-emerge --noreplace portage
-ewrapper --noreplace ccache
-emerge --noreplace distcc
-distcc-config --set-hosts "${DISTCC_HOSTS}"
-distccd &
-echo 'MAKEOPTS="${MAKEOPTS}"' >>/etc/make.conf
-#build our packages...
-for x in \`cat /tmp/livecd/base-packages | grep -v ^#\`
- do
- if [ "\${x:0:1}" = "^" ]
- then
- ACCEPT_KEYWORDS="~${MAINARCH}" emerge -pv --noreplace --buildpkg --usepkg \${x:1} || exit 1
- ACCEPT_KEYWORDS="~${MAINARCH}" emerge --noreplace --buildpkg --usepkg \${x:1} || exit 1
- else
- emerge -pv --noreplace --buildpkg --usepkg \$x || exit 1
- emerge --noreplace --buildpkg --usepkg \$x || exit 1
- fi
- done
-gcc ${CFLAGS} freeramdisk.c -o /sbin/freeramdisk || exit 1
-strip /sbin/freeramdisk
-if [ -d /tmp/livecd/launcher ]
-then
- cd /tmp/livecd/launcher
- #get the qt stuff in our path
- env-update
- source /etc/profile
- qmake || exit 1
- make || exit 1
- cp gamelaunch /usr/sbin/ || exit 1
-fi
-EOF
- chmod +x $CD_BUILDTEMP/base-build
- chroot $CD_BUILDCHROOT /tmp/livecd/base-build
- [ $? -ne 0 ] && chroot_die "base build failure"
-}
-
-kern_build() {
- cp ${LIVECD_ROOT}/profiles/${CD_PROFILE}/kern-packages $CD_BUILDTEMP || chroot_die
- cat > $CD_BUILDTEMP/kern-build << EOF
-cd /tmp/livecd
-source /tmp/livecd/build-setup || exit 1
-#build our packages...
-for x in \`cat /tmp/livecd/kern-packages | grep -v ^#\`
-do
- if [ "\${x:0:1}" = "^" ]
- then
- ACCEPT_KEYWORDS="~${MAINARCH}" emerge -pv --noreplace --buildpkg --usepkg \${x:1} || exit 1
- ACCEPT_KEYWORDS="~${MAINARCH}" emerge --noreplace --buildpkg --usepkg \${x:1} || exit 1
- else
- emerge -pv --noreplace --buildpkg --usepkg \$x || exit 1
- emerge --noreplace --buildpkg --usepkg \$x || exit 1
- fi
- done
-
-EOF
- chmod +x $CD_BUILDTEMP/kern-build
- chroot $CD_BUILDCHROOT /tmp/livecd/kern-build
- [ $? -ne 0 ] && chroot_die "kernel packages build failure"
-}
-
-kernel_build() {
- cp "${LIVECD_ROOT}/profiles/${CD_PROFILE}/${KERNCONFIG}" "${CD_BUILDCHROOT}/etc/kernels/myconfig" || chroot_die
- cp "${LIVECD_ROOT}/profiles/${CD_PROFILE}/settings" "${CD_BUILDCHROOT}/etc/kernels/settings" || chroot_die
- cat > $CD_BUILDTEMP/kernel-build << EOF
- source /tmp/livecd/build-setup
- cd /usr/src/linux
- if [ ! -d /tmp/livecd/kernel/.complete ]
- then
- install -d /tmp/livecd/kernel
- genkernel --livecd --myconfig --config || die
- mv -f /kernel* /tmp/livecd/kernel/bzImage || die
- mv -f /initrd* /tmp/livecd/kernel/initrd.gz || die
- touch /tmp/livecd/kernel/.complete
-fi
-EOF
- chmod +x $CD_BUILDTEMP/kernel-build
- chroot $CD_BUILDCHROOT /tmp/livecd/kernel-build
- [ $? -ne 0 ] && chroot_die "Chroot kernel/2nd package build failure"
-}
-
-cloop_create() {
- umount_all
- rm -f ${CD_BUILDROOT}/livecd.*
- install -d ${LOOP_ROOT} || chroot_die
- dd if=/dev/zero of=${LOOP_FILE} bs=1k count=${LOOP_SIZE} || chroot_die
- mke2fs -F -q ${LOOP_FILE} || chroot_die
- mount -t ext2 -o loop ${LOOP_FILE} ${LOOP_ROOT} || chroot_die
- cp -a ${CD_BUILDCHROOT}/* ${LOOP_ROOT} || chroot_die
- umount ${LOOP_ROOT} || chroot_die
- if [ "$LOOP_MODE" = "cloop" ]
- then
- cat ${LOOP_FILE} | /${CD_BUILDTEMP}/create_compressed_fs - 65536 > ${CLOOP_FILE} || chroot_die
- rm -f ${CD_BUILDCHROOT}/tmp/create_compressed_fs || chroot_die
- fi
-}
-
-iso_create() {
- install -d ${ISO_ROOT} || die
- install -d ${ISO_ROOT}/isolinux
- cp ${LIVECD_ROOT}/archives/isolinux.bin ${ISO_ROOT}/isolinux || die
- cp ${LIVECD_ROOT}/profiles/${CD_PROFILE}/isolinux.cfg ${ISO_ROOT}/isolinux || die
- cp ${LIVECD_ROOT}/profiles/${CD_PROFILE}/{*.lss,*.msg} ${ISO_ROOT}/isolinux || die
- cp ${CD_BUILDTEMP}/kernel/bzImage ${ISO_ROOT}/isolinux/gentoo || die
- cp ${CD_BUILDTEMP}/kernel/initrd.gz ${ISO_ROOT}/isolinux/initrd || die
-
- if [ "${BOOTSPLASH}" = "yes" ]
- then
- cat ${LIVECD_ROOT}/profiles/${CD_PROFILE}/aux-files/1024.initrd >> ${ISO_ROOT}/isolinux/initrd || die
- fi
-
- if [ -f ${LIVECD_ROOT}/profiles/${CD_PROFILE}/aux-files/memtest ]
- then
- cp ${LIVECD_ROOT}/profiles/${CD_PROFILE}/aux-files/memtest ${ISO_ROOT}/isolinux || die
- fi
- #First, clean up any old loops so we don't get extras on the Cd
- rm -f ${ISO_ROOT}/${CLOOP_FILE} ${ISO_ROOT}/${LOOP_FILE}
-
-
- #now, copy the one we want into place
- if [ "$LOOP_MODE" = "cloop" ]
- then
- cp ${CLOOP_FILE} ${ISO_ROOT} || die
- else
- cp ${LOOP_FILE} ${ISO_ROOT} || die
- fi
- mkisofs -J -R -l -o ${CD_BUILDROOT}/${CD_ISONAME} -b isolinux/isolinux.bin -c isolinux/boot.cat \
- -no-emul-boot -boot-load-size 4 -boot-info-table ${ISO_ROOT}
-}
-
-chroot_generate() {
- umount_all
- [ ! -e "$CD_STAGEFILE" ] && chroot_die "$CD_STAGEFILE not found; please run \"fetch\" first."
- [ -e "$CD_BUILDCHROOT" ] && chroot_die "$CD_BUILDCHROOT already exists; please run $0 $CD_PROFILE delete before running $0 $CD_PROFILE build"
- #create build chroot directory and extract stage tarball
- install -d "$CD_BUILDCHROOT"
- echo ">>> Extracting stage tarball..."
- tar xjpf $CD_STAGEFILE -C $CD_BUILDCHROOT || die "stage tarball extraction error"
- #set up our private temp directory and the mount-point inside the chroot.
- install -d "$CD_BUILDTEMP" "${CD_BUILDCHROOT}/tmp/livecd" || die "couldn't create chroot temp. directories"
- #set up ccache so we can get funky.
- if [ ! -d "${CD_BUILDCHROOT}/${CCACHEDIR}" ]
- then
- install -d "${CD_BUILDCHROOT}/${CCACHEDIR}" || die "couldn't initialize ccache dir"
- fi
- #set up distfile mount-point...
- install -d "${CD_BUILDCHROOT}/home/distfiles" || die "couldn't create /home/distfiles mountpoint"
-
- #set up the profile symlink so that it points to the profile we want
- rm -f "${CD_BUILDCHROOT}/etc/make.profile"
- ln -s ../usr/portage/profiles/${CD_PORTAGE_PROFILE} ${CD_BUILDCHROOT}/etc/make.profile
-
- #copy our local resolv.conf and hosts over for now; this allows downloading to work.
- cp /etc/resolv.conf /etc/hosts ${CD_BUILDCHROOT}/etc
-
- #let's do this....
- mount_all
- build_setup
- base_build
- kernel_build
- kern_build
- umount_all
-}
-
-chroot_enter() {
- umount_all
- mount_all
- chroot $CD_BUILDCHROOT
- umount_all
-}
-
-chroot_clean() {
-umount_all
- #first do local modifications script
- mv -f ${CD_BUILDCHROOT}/tmp/create_compressed_fs ${CD_BUILDTEMP}
- if [ -e "${LIVECD_ROOT}/profiles/${CD_PROFILE}/mods" ]
- then
- source ${LIVECD_ROOT}/profiles/${CD_PROFILE}/mods
- else
- echo "No ${CD_PROFILE} mods script found; skipping."
- fi
- #next do global clean script
- if [ -e "${LIVECD_ROOT}/profiles/${CD_PROFILE}/clean" ]
- then
- source ${LIVECD_ROOT}/profiles/${CD_PROFILE}/clean
- else
- echo "No global clean script found; skipping."
- fi
- #now do the local post-clean
- if [ -e "${LIVECD_ROOT}/profiles/${CD_PROFILE}/post-clean" ]
- then
- source ${LIVECD_ROOT}/profiles/${CD_PROFILE}/post-clean
- else
- echo "No ${CD_PROFILE} post-clean script found; skipping."
- fi
- umount_all
-
-}
-
-case "$2" in
- fetch)
- pre_fetch;;
- build)
- chroot_generate;;
- cloop)
- cloop_create;;
- prep)
- chroot_prep
- ;;
- isogen)
- iso_create
- ;;
- enter)
- chroot_enter
- ;;
- umount)
- umount_all
- ;;
- kernbuild)
- umount_all
- mount_all
- kernel_build
- umount_all
- ;;
- clean)
- chroot_clean
- ;;
- delete)
- umount_all
- rm -rf $CD_BUILDCHROOT
- ;;
- all)
- chroot_generate
- kernel_build
- chroot_clean
- cloop_create
- iso_create
- ;;
-
- *)
- usage
- exit 1
- ;;
-
-esac
-exit 0
-