+# }}}
+
+# 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"
+
+# i386:
+[ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
+if [ "$ARCH" = i386 ] ; then
+ if [ -d "$BUILD_TARGET"/boot ] ; then
+ ewarn "$BUILD_TARGET/boot exists already, skipping stage 'boot'" ; eend 0
+ log "$BUILD_TARGET/boot exists already, skipping stage 'boot'"
+ else
+ # booting stuff:
+ mkdir -p "$BUILD_TARGET"/boot/isolinux
+ [ -d "$BUILD_TARGET"/GRML ] || 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/i386_files/boot/isolinux/* "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/* "$BUILD_TARGET"/boot/isolinux/
+ cp -a /usr/share/grml-live/i386_files/boot/grub "$BUILD_TARGET"/boot/
+
+ # adjust boot splash information:
+ ISO_DATE="$(date +%Y-%m-%d)"
+ VERSION="$(cut_string 5 "$VERSION")" ; VERSION="$(extend_string_end 5 "$VERSION")"
+ RELEASENAME="$(cut_string 30 "$RELEASENAME")" ; RELEASENAME="$(extend_string_end 30 "$RELEASENAME")"
+
+ sed -i "s/%VERSION%/$VERSION/" "$BUILD_TARGET"/boot/isolinux/boot.msg
+ sed -i "s/%RELEASENAME%/$RELEASENAME/" "$BUILD_TARGET"/boot/isolinux/boot.msg
+ sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_TARGET"/boot/isolinux/boot.msg
+
+ sed -i "s/%VERSION%/$VERSION/" "$BUILD_TARGET"/boot/isolinux/boot-beep.msg
+ sed -i "s/%RELEASENAME%/$RELEASENAME/" "$BUILD_TARGET"/boot/isolinux/boot-beep.msg
+ sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_TARGET"/boot/isolinux/boot-beep.msg
+
+ sed -i "s/%VERSION%/$VERSION/" "$BUILD_TARGET"/boot/grub/menu.lst
+
+ # autostart for Windows:
+ cp /usr/share/grml-live/windows/autostart/autorun.bat "$BUILD_TARGET"/
+ cp /usr/share/grml-live/windows/autostart/autorun.inf "$BUILD_TARGET"/
+ cp /usr/share/grml-live/windows/autostart/autorun.pif "$BUILD_TARGET"/
+ cp /usr/share/grml-live/windows/autostart/cdrom.ico "$BUILD_TARGET"/
+ # windows-binaries:
+ if [ -n "$WINDOWS_BINARIES" ] ; then
+ if [ -f "$BUILD_TARGET"/windows/putty.exe ] ; then
+ ewarn "$BUILD_TARGET/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
+ log "$BUILD_TARGET/windows exists already, skipping stage 'WINDOWS_BINARIES'"
+ else
+ mkdir "$BUILD_TARGET"/windows
+ ( cd "$BUILD_TARGET"/windows
+ for file in pageant plink pscp psftp putty puttygen ; do
+ wget -O ${file}.exe ${WINDOWS_BINARIES}/${file}.exe
+ done )
+ fi
+ einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
+ log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
+ fi
+ einfo "Finished execution of stage 'boot'" ; eend 0
+ fi
+# amd64:
+elif [ "$ARCH" = amd64 ] ; then
+ ewarn 'Warning: gebi, it is your turn. :)'>&2
+# ppc:
+elif [ "$ARCH" = powerpc ] ; then
+ ewarn 'Warning: formorer, it is your turn. :)'>&2
+# unsuported:
+else
+ eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
+fi
+
+if [ -f "$BUILD_TARGET"/live/grml.squashfs ] ; then
+ ewarn "$BUILD_TARGET/live exists already, skipping stage 'squashfs'" ; eend 0
+ log "$BUILD_TARGET/live exists already, skipping stage 'squashfs'"
+else
+ mkdir "$BUILD_TARGET"/live
+ mksquashfs $CHROOT_TARGET/* $BUILD_TARGET/live/grml.squashfs -noappend
+ einfo "Finished execution of stage 'squashfs'" ; eend 0
+ log "Finished execution of stage 'squashfs' [$(date)]"
+fi
+# }}}
+
+# ISO_TARGET - mkisofs {{{
+[ -n "$ISO_TARGET" ] || ISO_TARGET="$TARGET/grml_isos"
+[ -n "$ISO_NAME" ] || ISO_NAME="grml_${VERSION}.iso"
+
+if [ "$BOOT_METHOD" = "isolinux" ] ; then
+ BOOT_FILE="boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat"
+elif [ "$BOOT_METHOD" = "grub" ] ; then
+ BOOT_FILE="boot/grub/stage2_eltorito"
+fi
+
+if [ -f "${ISO_TARGET}/${ISO_NAME}" ] ; then
+ ewarn "$ISO_TARGET exists already, skipping stage 'iso build'" ; eend 0
+ log "$ISO_TARGET exists already, skipping stage 'iso build'"
+else
+ mkdir -p "$ISO_TARGET" || bailout 6 "Problem with creating $ISO_TARGET for stage 'iso build'"
+ ( cd "$BUILD_TARGET" &&
+ mkisofs -V "grml $VERSION" -publisher 'grml-live | grml.org' \
+ -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
+ -b $BOOT_FILE \
+ -o "${ISO_TARGET}/${ISO_NAME}" .
+ )
+ einfo "Finished execution of stage 'iso build'" ; eend 0
+ log "Finished execution of stage 'iso build' [$(date)]"
+fi
+# }}}