- [ -d "$BUILD_OUTPUT"/GRML ] || mkdir "$BUILD_OUTPUT"/GRML
- cp -a ${TEMPLATE_DIRECTORY}/GRML/* "$BUILD_OUTPUT"/GRML/
-
- # adjust boot splash information:
- RELEASE_INFO="$GRML_NAME $VERSION - Release Codename $RELEASENAME"
- RELEASE_INFO="$(cut_string 68 "$RELEASE_INFO")"
- RELEASE_INFO="$(extend_string_end 68 "$RELEASE_INFO")"
-
- sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/GRML/grml-version
- sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/GRML/grml-version
-
- # make sure the squashfs filename is set accordingly:
- SQUASHFS_NAME="$GRML_NAME.squashfs"
-
- # adjust all variables in the templates with the according distribution information
- for file in "${BUILD_OUTPUT}"/boot/isolinux/*.cfg "${BUILD_OUTPUT}"/boot/isolinux/*.msg \
- "${BUILD_OUTPUT}"/boot/grub/* ; do
- sed -i "s/%ARCH%/$ARCH/g" "${file}"
- sed -i "s/%DATE%/$ISO_DATE/g" "${file}"
- sed -i "s/%DISTRI_INFO%/$DISTRI_INFO/g" "${file}"
- sed -i "s/%DISTRI_NAME%/$DISTRI_NAME/g" "${file}"
- sed -i "s/%DISTRI_SPLASH%/$DISTRI_SPLASH/g" "${file}"
- sed -i "s/%GRML_NAME%/$GRML_NAME/g" "${file}"
- sed -i "s/%SQUASHFS_NAME%/$SQUASHFS_NAME/g" "${file}"
- sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/g" "${file}"
- sed -i "s/%SHORT_NAME%/$SHORT_NAME/g" "${file}"
- sed -i "s/%VERSION%/$VERSION/g" "${file}"
- done
-
- # adjust bootsplash accordingly but make sure the string has the according lenght
- SQUASHFS_NAME="$(cut_string 20 "$SQUASHFS_NAME")"
- SQUASHFS_NAME="$(extend_string_end 20 "$SQUASHFS_NAME")"
- sed -i "s/%SQUASHFS_NAME%/$SQUASHFS_NAME/" "$BUILD_OUTPUT"/boot/isolinux/f4
- sed -i "s/%SQUASHFS_NAME%/$SQUASHFS_NAME/" "$BUILD_OUTPUT"/boot/isolinux/f5
-
- # generate addon list
- rm "${BUILD_OUTPUT}/${ADDONS_LIST_FILE}"
- for name in $(ls "${BUILD_OUTPUT}"/boot/isolinux/addon_*.cfg) ; do
- include_name=$(basename "$name")
- echo "include $include_name" >> "${BUILD_OUTPUT}/${ADDONS_LIST_FILE}"
- done
-
- if ! [ -r "${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg" ] || [ "$DISTRI_NAME" = "grml" ] ; then
- log "including grmlmain.cfg in ${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
- echo "include grmlmain.cfg" > "${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
- echo "include default.cfg" > "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- echo "include menuoptions.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- echo "include grml.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- echo "include options.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- if [ ! -n "$NO_ADDONS" ] ; then
- echo "include addons.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- fi
- echo "include isoprompt.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- echo "include hd.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- echo "include hidden.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
- else # assume we are building a custom distribution:
- log "File ${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg found, using it."
- einfo "File ${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg found, using it."
- if grep -q "^include ${DISTRI_NAME}.cfg" "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" ; then
- log "include for ${DISTRI_NAME}.cfg already present, nothing to do."
- eindent
- einfo "include for ${DISTRI_NAME}.cfg already present, nothing to do."
- eoutdent
- eend $?
- else
- log "including ${DISTRI_NAME}.cfg in ${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
- echo "include ${DISTRI_NAME}.cfg" > "${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
- [ -n "$NO_ADDONS" ] || echo "include addons.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
- fi
- fi
+# prepare ISO
+if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
+ if [ -n "$BOOTSTRAP_ONLY" ] ; then
+ log "Skipping stage 'boot' as building with bootstrap only."
+ ewarn "Skipping stage 'boot' as building with bootstrap only." ; eend 0
+ else
+ if [ -d "$BUILD_OUTPUT"/boot/isolinux -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
+ log "Skipping stage 'boot' as $BUILD_OUTPUT/boot/isolinux exists already."
+ ewarn "Skipping stage 'boot' as $BUILD_OUTPUT/boot/isolinux exists already." ; eend 0
+ else
+ # booting stuff:
+ [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
+ [ -d "$BUILD_OUTPUT"/boot/"${SHORT_NAME}" ] || mkdir -p "$BUILD_OUTPUT"/boot/"${SHORT_NAME}"
+
+ # if we don't have an initrd we a) can't boot and b) there was an error
+ # during build, so check for the file:
+ INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
+ if [ -n "$INITRD" ] ; then
+ cp $INITRD "$BUILD_OUTPUT"/boot/"${SHORT_NAME}"/initrd.gz
+ find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
+ else
+ log "Error: No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
+ eerror "Error: No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
+ bailout 10
+ fi
+
+ KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
+ if [ -n "$KERNEL_IMAGE" ] ; then
+ cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/"${SHORT_NAME}"/linux26
+ else
+ log "Error: No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
+ eerror "Error: No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
+ bailout 11
+ fi
+
+ [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
+ if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
+ log "Error: ${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
+ eerror "Error: ${TEMPLATE_DIRECTORY}/boot does not exist. Exiting." ; eend 1
+ bailout 8
+ fi
+
+ # copy _required_ isolinux files
+ for file in ifcpu64.c32 isolinux.bin vesamenu.c32; do
+ copy_addon_file "${file}" /usr/lib/syslinux isolinux
+ done
+
+ # *always* copy files to output directory so the variables
+ # get adjusted according to the build.
+ cp ${TEMPLATE_DIRECTORY}/boot/isolinux/* "$BUILD_OUTPUT"/boot/isolinux/
+
+ if [ -n "$NO_ADDONS" ] ; then
+ log "Skipping installation of boot addons as requested via \$NO_ADDONS."
+ einfo "Skipping installation of boot addons as requested via \$NO_ADDONS."; eend 0
+ else
+ if ! [ -d "$TEMPLATE_DIRECTORY"/boot/addons ] ; then
+ log "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)"
+ ewarn "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)" ; eend 0
+ else
+ # copy addons from system packages or grml-live-compat
+ copy_addon_file ipxe.lkrn /usr/lib/ipxe addons
+ copy_addon_file pci.ids /usr/share/misc addons
+ copy_addon_file memtest86+.bin /boot addons
+ for file in memdisk chain.c32 hdt.c32 menu.c32; do
+ copy_addon_file "${file}" /usr/lib/syslinux addons
+ done
+
+ # make memtest filename FAT16/8.3 compatible
+ mv "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" \
+ "${BUILD_OUTPUT}/boot/addons/memtest"
+
+ # copy only files so we can handle bsd4grml on its own
+ for file in ${TEMPLATE_DIRECTORY}/boot/addons/* ; do
+ test -f $file && cp $file "$BUILD_OUTPUT"/boot/addons/
+ done
+
+ if [ -n "$NO_ADDONS_BSD4GRML" ] ; then
+ log "Skipping installation of bsd4grml as requested via \$NO_ADDONS_BSD4GRML."
+ einfo "Skipping installation of bsd4grml as requested via \$NO_ADDONS_BSD4GRML."; eend 0
+ else
+ if [ -d "$TEMPLATE_DIRECTORY"/boot/addons/bsd4grml ] ; then
+ cp -a ${TEMPLATE_DIRECTORY}/boot/addons/bsd4grml "$BUILD_OUTPUT"/boot/addons/
+ else
+ log "Missing addon file: bsd4grml"
+ ewarn "Missing addon file: bsd4grml" ; eend 0
+ fi
+ fi