+# on-the-fly configuration {{{
+if [ -n "$GRML_LIVE_SOURCES" ] ; then
+ echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
+fi
+
+if [ -n "$FAI_DEBOOTSTRAP" ] ; then
+ sed -i "s#^FAI_DEBOOTSTRAP#FAI_DEBOOTSTRAP=$FAI_DEBOOTSTRAP#" /etc/grml/fai/make-fai-nfsroot.conf
+fi
+# }}}
+
+# CHROOT_TARGET - execute FAI {{{
+[ -n "$CHROOT_TARGET" ] || CHROOT_TARGET="$TARGET/grml_chroot"
+if [ -d "$CHROOT_TARGET" ] ; then
+ echo " [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirnstall'"
+else
+ mkdir "$CHROOT_TARGET" || bailout 5 "Problem with creating $CHROOT_TARGET for FAI"
+ fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" dirinstall "$CHROOT_TARGET" $FAI_ARGS
+ umount $CHROOT_TARGET/proc 2>/dev/null || /bin/true
+ umount $CHROOT_TARGET/sys 2>/dev/null || /bin/true
+ echo " [*] Finished execution of stage 'fai dirinstall'"
+fi
+# }}}
+
+# BUILD_TARGET - execute arch specific stuff and squashfs {{{
+[ -n "$BUILD_TARGET" ] || BUILD_TARGET="$TARGET/grml_cd"
+mkdir -p "$BUILD_TARGET" || bailout 6 "Problem with creating $BUILD_TARGET for stage ARCH"
+
+# x86:
+if [ "$ARCH" = x86 ] ; then
+ if [ -d "$BUILD_TARGET"/boot/isolinux ] ; then
+ echo " [x] $BUILD_TARGET/boot/isolinux exists already - skipping stage 'boot/isolinux'"
+ continue
+ else
+ mkdir -p "$BUILD_TARGET"/boot/isolinux
+ mkdir "$BUILD_TARGET"/GRML
+ cp /boot/memtest86+.bin "$BUILD_TARGET"/boot/isolinux/memtest
+ cp "$CHROOT_TARGET"/boot/initrd* "$BUILD_TARGET"/boot/isolinux/initrd.gz
+ cp "$CHROOT_TARGET"/boot/vmlinuz* "$BUILD_TARGET"/boot/isolinux/linux26
+ cp /usr/lib/syslinux/chain.c32 "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/lib/syslinux/isolinux.bin "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/lib/syslinux/memdisk "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/lib/syslinux/menu.c32 "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/allinone.img "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/balder10.imz "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/boot-beep.msg "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/boot.msg "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/f* "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/isolinux.cfg "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/logo.16 "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/x86_files/boot/isolinux/syslinux.cfg "$BUILD_TARGET"/boot/isolinux/
+ # minirt26.gz
+ # boot.cat
+ if [ -n "$WINDOWS_BINARIES" ] ; then
+ if [ -d "$BUILD_TARGET"/windows ] ; then
+ echo " [x] $BUILD_TARGET/windows exists already - skipping stage 'WINDOWS_BINARIES'"
+ return 0
+ else
+ mkdir "$BUILD_TARGET"/windows
+ ( cd "$BUILD_TARGET"/windows
+ for file in pageant plink pscp psftp putty puttygen ; do
+ wget ${WINDOWS_BINARIES}/${file}.exe
+ done )
+ fi
+ echo " [*] Finished execution of stage 'WINDOWS_BINARIES'"
+ fi
+ echo " [*] Finished execution of stage 'boot/isolinux'"
+ fi
+# amd64:
+elif [ "$ARCH" = amd64 ] ; then
+ echo 'Warning: gebi, it is your turn. :)'>2
+# ppc:
+elif [ "$ARCH" = ppc ] ; then
+ echo 'Warning: formorer, it is your turn. :)'>2
+# unsuported:
+else
+ echo 'Warning: Unsupported ARCH, sorry. Want to support it? Contribute!'>&2
+fi
+
+if [ -d "$BUILD_TARGET"/live ] ; then
+ echo " [x] $BUILD_TARGET/live exists already, skipping stage 'squashfs'"
+else
+ mkdir "$BUILD_TARGET"/live
+ mksquashfs $CHROOT_TARGET/* $BUILD_TARGET/live/grml.squashfs -noappend
+fi
+echo " [*] Finished execution of stage 'squashfs'"
+# }}}
+
+# ISO_TARGET - mkisofs {{{
+[ -n "$ISO_TARGET" ] || ISO_TARGET="$TARGET/grml_isos"
+if [ -d "$ISO_TARGET" ] ; then
+ echo " [x] $ISO_TARGET exists already, skipping the stage 'iso build'"
+else
+ mkdir -p "$ISO_TARGET" || bailout 6 "Problem with creating $ISO_TARGET for stage 'iso build'"
+ ( cd "$BUILD_TARGET" &&
+ mkisofs -V "Debian/etch grml" -publisher 'Michael Prokop <mika@grml.org>' \
+ -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
+ -c boot/isolinux/boot.cat -b boot/isolinux/isolinux.bin \
+ -o "$ISO_TARGET"/grml_0.0-1.iso .
+ )
+ echo " [*] Finished execution of stage 'iso build'"
+fi
+# }}}
+
+# finalize {{{
+echo " [*] Sucessfully finished execution of $PN"
+bailout 0