Drop hping2 from GRML_FULL
[grml-live.git] / grml-live
index 0e0a639..0e2a49d 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -1,7 +1,9 @@
 #!/bin/bash
 # Filename:      grml-live
 # Purpose:       build process script for generating a (grml based) Linux Live-ISO
 #!/bin/bash
 # Filename:      grml-live
 # Purpose:       build process script for generating a (grml based) Linux Live-ISO
-# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
+# Authors:       grml-team (grml.org),
+#                (c) Michael Prokop <mika@grml.org>,
+#                (c) Thorsten Glaser <tg@mirbsd.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
 ################################################################################
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
 ################################################################################
 export LANG=C
 export LC_ALL=C
 
 export LANG=C
 export LC_ALL=C
 
+# define function getfilesize before "set -e"
+if stat --help >/dev/null 2>&1; then
+       getfilesize='stat -c %s'        # GNU stat
+else
+       getfilesize='stat -f %z'        # BSD stat
+fi
+
 # exit on any error:
 set -e
 
 # exit on any error:
 set -e
 
-GRML_LIVE_VERSION='0.9.18'
+GRML_LIVE_VERSION='0.9.20'
 PN="$(basename $0)"
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
 PN="$(basename $0)"
 CMDLINE="$0 $@"
 ISO_DATE="$(date +%Y-%m-%d)"
@@ -553,7 +562,7 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
 
       if [ -z "$NO_ADDONS" ] ; then
          if ! [ -d /usr/share/grml-live/templates/boot/addons/bsd4grml ] ; then
 
       if [ -z "$NO_ADDONS" ] ; then
          if ! [ -d /usr/share/grml-live/templates/boot/addons/bsd4grml ] ; then
-           ewarn "Boot addons not found, skipping therefor. (Consider installing package grml-live-addons)" ; eend 0
+           ewarn "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)" ; eend 0
          else
            # copy only files so we can handle bsd4grml on its own
            for file in ${TEMPLATE_DIRECTORY}/boot/addons/* ; do
          else
            # copy only files so we can handle bsd4grml on its own
            for file in ${TEMPLATE_DIRECTORY}/boot/addons/* ; do
@@ -616,6 +625,27 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
       sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4
       sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f5
 
       sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4
       sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f5
 
+      # jump back to grub from bsd4grml:
+      if [ -e "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.6 ]; then
+         if [ -e "$BUILD_OUTPUT"/boot/grub/core.img ]; then
+            GRUB_VERSION=2
+         else
+            GRUB_VERSION=1
+         fi
+         if [ -e "$BUILD_OUTPUT"/boot/grub/stage2 ]; then
+            GRUB_LEGACY=stage2
+         else
+            GRUB_LEGACY=stage2_eltorito
+         fi
+
+         # why not ed(1)?
+         for file in "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.6 \
+                     "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.cfg; do
+             sed -i -e "s!%GRUB_VERSION%!$GRUB_VERSION!g" \
+                    -e "s!%GRUB_LEGACY%!$GRUB_LEGACY!g" "$file"
+         done
+      fi
+
       # autostart for Windows:
       if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
          cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
       # autostart for Windows:
       if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
          cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
@@ -735,9 +765,16 @@ else
       log "mkisofs -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b $BOOT_FILE -o ${ISO_OUTPUT}/${ISO_NAME} ."
       mkisofs -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
               -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table    \
       log "mkisofs -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b $BOOT_FILE -o ${ISO_OUTPUT}/${ISO_NAME} ."
       mkisofs -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
               -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table    \
-              -b $BOOT_FILE \
+              -b $BOOT_FILE -no-pad \
               -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
 
               -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
 
+      # pad the output ISO to multiples of 256 KiB for partition table support
+      siz=$($getfilesize "${ISO_OUTPUT}/${ISO_NAME}")
+      cyls=$((siz / 512 / 32 / 16 + 1))                # C=$cyls H=16 S=32
+      siz=$((cyls * 16 * 32 * 512))            # size after padding
+      dd if=/dev/zero bs=1 count=1 seek=$((siz - 1)) \
+         of="${ISO_OUTPUT}/${ISO_NAME}" 2>/dev/null
+
       # support disabling hybrid ISO image
       if [ "$HYBRID_METHOD" = "disable" ] ; then\
          log "Skipping creation of hybrid ISO file as requested via HYBRID_METHOD=disable"
       # support disabling hybrid ISO image
       if [ "$HYBRID_METHOD" = "disable" ] ; then\
          log "Skipping creation of hybrid ISO file as requested via HYBRID_METHOD=disable"
@@ -760,7 +797,10 @@ else
          else
            log "Creating hybrid ISO file with manifold method"
            einfo "Creating hybrid ISO file with manifold method"
          else
            log "Creating hybrid ISO file with manifold method"
            einfo "Creating hybrid ISO file with manifold method"
-           echo 1 63 | mksh /usr/share/grml-live/scripts/bootgrub.mksh | cat - boot/grub/core.img | dd conv=notrunc of="${ISO_OUTPUT}/${ISO_NAME}" conv=notrunc
+           echo 1 63 | \
+               mksh /usr/share/grml-live/scripts/bootgrub.mksh -A -M 1 -p 0x83 -g $cyls:16:32 | \
+               cat - boot/grub/core.img | \
+               dd conv=notrunc of="${ISO_OUTPUT}/${ISO_NAME}" conv=notrunc 2>/dev/null
            eend $?
          fi
       fi
            eend $?
          fi
       fi