From: Michael Prokop Date: Mon, 16 Oct 2023 11:11:18 +0000 (+0200) Subject: Rework memtest handling, incl. usage of latest available memtest file X-Git-Tag: v0.47.0~2 X-Git-Url: https://git.grml.org/?p=grml-live.git;a=commitdiff_plain;h=1a9a788fa46053e882e7332c6403b59ff8d437f1 Rework memtest handling, incl. usage of latest available memtest file If we try to copy the memtest86+.bin file as shipped with memtest86+ versions <=5.01-3.1, we either copy such an old file from the build directory (grml_chroot), or if that doesn't exist (e.g. because the memtest86+ package isn't installed), we might end up copying an old memtest file from the build host system instead. AS ${BUILD_OUTPUT}/boot/addons/memtest exists already then, we don't update the file any longer (e.g. from a more recent memtest86+ package), and therefore end up with an old and outdated memtest version in BIOS boot, while EFI boot provides a more recent memtest version. This is inconsistent and unexpected behavior. So instead try to use the most recent version of memtest86* files first, and only then fall back to the old memtest86+ <=5.01-3.1 file behavior. While looking into this, I also noticed that until memtest86+ versions <=6.10-2 it used to be named memtest86+x32.bin, while as of memtest86+ versions >=6.10-3 it's memtest86+ia32.bin instead. As we have version 6.10-4 in bookworm/stable and only pre-6 version 5.01-3.1 in e.g. bullseye/oldstable, let's skip any backwards compatibility for memtest86+x32.bin. Furthermore while at it, drop duplicate execution of `copy_addon_file memtest86+x64.bin /boot addons` and `copy_addon_file memtest86+x32.bin /boot addons` to avoid ending up with further duplicate files on the ISO. So related to https://github.com/grml/grml-live/issues/128, we now ship /boot/addons/memtest on each of grml64 + grml32, and respectively only /boot/addons/memtest86+x64.efi on grml64 only and /boot/addons/memtest86+ia32.efi on grml32 only. To rename the files into FAT16/8.3 compatible "/boot/addons/memtest", let's provide a proper return code from within copy_addon_file() if we couldn't find any matching file. Related to https://github.com/grml/grml-live/issues/128 Closes: https://github.com/grml/grml/issues/178 --- diff --git a/grml-live b/grml-live index 02cf2e8..cc1dbfb 100755 --- a/grml-live +++ b/grml-live @@ -327,6 +327,7 @@ copy_addon_file() { msg="Missing addon file: \"$1\"" ewarn "$msg" ; eend 1 log "copy_addon_file: $msg" + return 1 } # replace placeholders in template files with actual information @@ -1193,34 +1194,39 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] || [ "$ARCH" = arm64 ] ; then copy_addon_file ipxe.efi /usr/lib/ipxe addons copy_addon_file pci.ids /usr/share/misc addons - # memtest86+ <=5.01-3.1 - copy_addon_file memtest86+.bin /boot addons - # make memtest filename FAT16/8.3 compatible - if [ -r "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" ] ; then - mv "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" \ - "${BUILD_OUTPUT}/boot/addons/memtest" - fi - # memtest86+ >=6.00-1 - copy_addon_file memtest86+x32.bin /boot addons - copy_addon_file memtest86+x32.efi /boot addons - copy_addon_file memtest86+x64.bin /boot addons - copy_addon_file memtest86+x64.efi /boot addons + if [[ "$ARCH" == "amd64" ]] ; then + copy_addon_file memtest86+x64.efi /boot addons + elif [[ "$ARCH" == "i386" ]] ; then + copy_addon_file memtest86+ia32.efi /boot addons + fi # provide memtest86+ >=6.00-1 files as "memtest" file # for BIOS boot in isolinux/syslinux if ! [ -r "${BUILD_OUTPUT}/boot/addons/memtest" ] ; then if [[ "$ARCH" == "amd64" ]] ; then - copy_addon_file memtest86+x64.bin /boot addons + copy_addon_file memtest86+x64.bin /boot addons && + # make memtest filename FAT16/8.3 compatible mv "${BUILD_OUTPUT}/boot/addons/memtest86+x64.bin" \ "${BUILD_OUTPUT}/boot/addons/memtest" elif [[ "$ARCH" == "i386" ]] ; then - copy_addon_file memtest86+x32.bin /boot addons - mv "${BUILD_OUTPUT}/boot/addons/memtest86+x32.bin" \ + copy_addon_file memtest86+ia32.bin /boot addons && + # make memtest filename FAT16/8.3 compatible + mv "${BUILD_OUTPUT}/boot/addons/memtest86+ia32.bin" \ "${BUILD_OUTPUT}/boot/addons/memtest" fi fi + # fallback: if we still don't have /boot/addons/memtest available, we + # might have an older memtest86+ version (<=5.01-3.1) which ships + # file "memtest86+.bin" instead + if ! [ -r "${BUILD_OUTPUT}/boot/addons/memtest" ] ; then + copy_addon_file memtest86+.bin /boot addons && + # make memtest filename FAT16/8.3 compatible + mv "${BUILD_OUTPUT}/boot/addons/memtest86+.bin" \ + "${BUILD_OUTPUT}/boot/addons/memtest" + fi + # since syslinux(-common) v3:6.03~pre1+dfsg-4 the files are in a # different directory :( if [ -d "${CHROOT_OUTPUT}/usr/lib/syslinux/modules/bios/" ] ; then diff --git a/templates/boot/grub/addons.cfg b/templates/boot/grub/addons.cfg index e0a3d26..a96c780 100644 --- a/templates/boot/grub/addons.cfg +++ b/templates/boot/grub/addons.cfg @@ -14,9 +14,9 @@ if [ "${grub_platform}" == "efi" ] ; then } fi else # assume i386 - if test -e /boot/addons/memtest86+x32.efi ; then - menuentry "Memory test (memtest86+x32.efi)" { - linuxefi /boot/addons/memtest86+x32.efi + if test -e /boot/addons/memtest86+ia32.efi ; then + menuentry "Memory test (memtest86+ia32.efi)" { + linuxefi /boot/addons/memtest86+ia32.efi } fi fi @@ -39,10 +39,10 @@ if [ "${grub_platform}" != "efi" ] ; then } fi else # assume i386 - if test -e /boot/addons/memtest86+x32.bin ; then - menuentry "Memory test (memtest86+x32.bin)" { + if test -e /boot/addons/memtest86+ia32.bin ; then + menuentry "Memory test (memtest86+ia32.bin)" { insmod linux16 - linux16 /boot/addons/memtest86+x32.bin + linux16 /boot/addons/memtest86+ia32.bin } elif test -e /boot/addons/memtest ; then # fallback to old memtest menuentry "Memory test (memtest86+)" {