+# }}}
+
+# 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/isolinux ] ; then
+ ewarn "$BUILD_TARGET/boot exists already, skipping stage 'boot/isolinux'" ; eend 0
+ log "$BUILD_TARGET/boot exists already, skipping stage 'boot/isolinux'"
+ 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/allinone.img "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/balder10.imz "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/boot-beep.msg "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/boot.msg "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/f* "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/isolinux.cfg "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/logo.16 "$BUILD_TARGET"/boot/isolinux/
+ cp /usr/share/grml-live/i386_files/boot/isolinux/syslinux.cfg "$BUILD_TARGET"/boot/isolinux/
+
+ # adjust boot splash information:
+ ISO_DATE="$(date +%Y-%m-%d)"
+ VERSION="$(cut_string 5 "$VERSION")" ; VERSION="$(extend_string_end 5 "$VERSION")"
+ CODENAME="$(cut_string 30 "$CODENAME")" ; CODENAME="$(extend_string_end 30 "$CODENAME")"
+
+ sed -i "s/%VERSION%/$VERSION/" "$BUILD_TARGET"/boot/isolinux/boot.msg
+ sed -i "s/%CODENAME%/$CODENAME/" "$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/%CODENAME%/$CODENAME/" "$BUILD_TARGET"/boot/isolinux/boot-beep.msg
+ sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_TARGET"/boot/isolinux/boot-beep.msg
+
+ # 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/isolinux'" ; 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"
+if [ -d "$ISO_TARGET" ] ; 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'"
+ [ -n "$ISO_NAME" ] || ISO_NAME="grml_0.0-1.iso"
+ ( cd "$BUILD_TARGET" &&
+ mkisofs -V "Debian/etch grml" -publisher 'grml-live | 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}"/"${ISO_NAME}" .
+ )
+ einfo "Finished execution of stage 'iso build'" ; eend 0
+ log "Finished execution of stage 'iso build' [$(date)]"
+fi
+# }}}