Initial arm64 / aarch64 support
authorMichael Prokop <mika@grml.org>
Fri, 8 Sep 2023 15:55:47 +0000 (17:55 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 8 Sep 2023 15:55:47 +0000 (17:55 +0200)
Relevant changes:

* arm64 (ARM64 in terms of FAI class) is considered a valid and
  supported architecture within grml-live now; updated documentation,
  configuration files and zsh completion accordingly

* arm64 was enabled as supported architecture in grml repositories

* the architecture specific grml-scripts + grml-scripts-core packages
  got built for arm64 and uploaded to the grml-testing repository

* memtest86+ + syslinux aren't available on arm64, therefore move
  memtest86+ to Recommends to avoid ending up with an `Arch: any`
  package, also depend on either syslinux or syslinux-efi

* Software related changes in GRML* (other than the obvious
  linux-image-arm64 and further arm64 specific packages):

  * GRMLBASE:

    - grml2usb is I386 + AMD64 specific for now (if we want to use
      grml2usb on arm64 as well, we'd need to port it)

    - grub-efi-amd64-bin, grub-efi-ia32-bin + grub-pc as well as
      syslinux, syslinux-common + syslinux-utils all are also
      I386 + AMD64 specific

  * GRML_FULL:

    - cciss-vol-status, cmospwd, cpuid, grub-pc-bin + ltrace all
      are I386 + AMD64 specific (so not available for arm64)

    - grml-terminalserver is I386 + AMD64 specific for now (at least
      until we ported grml2usb for arm64)

* /etc/grml/fai/config/scripts/GRMLBASE/44-grub: invocation of
  grub-mkimage is I386 + AMD64 specific (at least until we identify
  whether there's an actual use-case for our generated
  /boot/grub/core.img)

* /etc/grml/fai/config/scripts/GRMLBASE/45-grub-images: we use
  /boot/bootaa64.efi for the EFI boot image name for arm64, though need
  to skip the unavailable efi_uga module and also skipt the i386-pc
  architecture, since grub on arm64 doesn't provide /usr/lib/grub/i386-efi

Known TODOs:

* decide official naming for Grml on arm64 (also keep e.g.
  `update-grml-rescueboot -t small -a 64` in mind!)

* grml2usb isn't available for arm64 yet, and therefore also
  grml-terminalserver isn't available for arm64

* when booting the resulting ISO inside an arm64 / aarch64, the default
  terminal seems to start up as /dev/ttyAMA0 (instead of /dev/tty1, as
  expected and handled via our getty@tty1.service)

* look into SecureBoot support

Development sponsored by netcup GmbH

debian/control
docs/grml-live.txt
etc/grml/fai/config/package_config/GRMLBASE
etc/grml/fai/config/package_config/GRML_FULL
etc/grml/fai/config/package_config/GRML_SMALL
etc/grml/fai/config/scripts/GRMLBASE/44-grub
etc/grml/fai/config/scripts/GRMLBASE/45-grub-images
etc/grml/grml-live.conf
etc/zsh/completion.d/_grml-live
grml-live
templates/boot/grub/addons.cfg

index 3955d2b..8b5ca8a 100644 (file)
@@ -24,14 +24,13 @@ Depends:
  fai-client (>= 3.4.0),
  isolinux (>= 3:6.03+dfsg-5+deb8u1~),
  jo,
- memtest86+,
  mksh,
  moreutils,
  mtools,
  pciutils,
  rsync,
  squashfs-tools (>= 1:4.2-0~bpo60),
- syslinux,
+ syslinux | syslinux-efi,
  xorriso,
  ${misc:Depends},
 Recommends:
@@ -39,6 +38,7 @@ Recommends:
  grub-pc-bin,
  imagemagick,
  ipxe,
+ memtest86+,
  syslinux-utils,
 Suggests:
  fai-doc,
index 3d5ca3a..dab3f38 100644 (file)
@@ -62,8 +62,8 @@ Use the specified architecture instead of the currently running one.  This
 allows building a 32bit system on a 64bit host (though you can't build a 64bit
 system on a 32bit system/kernel of course). Please notice that real
 crosscompiling (like building a ppc system on x86) isn't possible due to the
-nature and the need of working in a chroot. Currently supported values: i386
-and amd64.
+nature and the need of working in a chroot. Currently supported values: i386,
+amd64 and arm64.
 
   -b::
 
@@ -82,7 +82,7 @@ really know that you do not want to update the chroot.
   -c **CLASSES**::
 
 Specify the CLASSES to be used for building the ISO via FAI.  By default only
-the classes GRMLBASE, GRML_FULL and I386/AMD64 (depending on system
+the classes GRMLBASE, GRML_FULL and I386/AMD64/ARM64 (depending on system
 architecture) are assumed.  Additionally you can specify a class providing a
 (grml-)kernel (see <<classes,the 'CLASSES' section in this document>> for
 details about available classes). So instead of GRML_FULL you can also use e.g.
@@ -297,9 +297,9 @@ losing the simplicity in the build process.
 The main and base class provided by grml-live is named GRMLBASE. It's strongly
 recommended to **always** use the class GRMLBASE when building an ISO using
 grml-live, as well as the architecture dependent class which provides the kernel
-(being 'I386' for x86_32 and 'AMD64' for x86_64) and a GRML_* class (like
-GRML_SMALL or GRML_FULL). The following files and directories are
-relevant for class GRMLBASE by default:
+(being 'I386' for x86_32, 'AMD64' for x86_64 and 'ARM64' for arm64) and a GRML_*
+class (like GRML_SMALL or GRML_FULL).
+The following files and directories are relevant for class GRMLBASE by default:
 
   ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/
   ${GRML_FAI_CONFIG}/config/debconf/GRMLBASE
@@ -312,10 +312,10 @@ files/directories.
 
 If you want to use your own configuration, extend an existing configuration
 and/or add additional packages to your ISO just invent a new class (or extend an
-existing one). For example if you want to use your own class named "FOOBAR" just
-set CLASSES="GRMLBASE,GRML_SMALL,AMD64,FOOBAR" inside /etc/grml/grml-live.local
-or invoke grml-live using the classes option: "grml-live -c
-GRMLBASE,GRML_SMALL,AMD64,FOOBAR ...".
+existing one). For example if you want to use your own class named "FOOBAR" on
+your amd64 build, et CLASSES="GRMLBASE,GRML_SMALL,AMD64,FOOBAR" inside
+/etc/grml/grml-live.local or invoke grml-live using the classes option:
+"grml-live -c GRMLBASE,GRML_SMALL,AMD64,FOOBAR ...".
 
 More details regarding the class concept can be found in the documentation of
 FAI itself (being available at /usr/share/doc/fai-doc/).
@@ -544,6 +544,7 @@ Instructions
   # mkdir -p /etc/grml/fai/config/basefiles/
   # mv I386.tar.gz /etc/grml/fai/config/basefiles/
   # mv AMD64.tar.gz /etc/grml/fai/config/basefiles/
+  # mv ARM64.tar.gz /etc/grml/fai/config/basefiles/
 
   # install relevant tools
   apt-get --no-install-recommends install grml-live
@@ -705,15 +706,15 @@ syslinux, used by default for official Grml images) then just execute:
   % isohybrid grml.iso
 
 [[create-a-base-tgz]]
-How do I create a base tar.gz (I386.tar.gz or AMD64.tar.gz)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+How do I create a base tar.gz (I386.tar.gz or AMD64.tar.gz or ARM64.tar.gz)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 [[basetgz]]
 
 First of all create the chroot using debootstrap (requires root):
 
   BASECHROOT='/tmp/basefile'  # path where the chroot gets generated
   SUITE='bookworm'              # using the current stable release should always work
-  debootstrap --exclude=info,tasksel,tasksel-data "$SUITE" "$BASECHROOT" http://ftp.debian.org/debian
+  debootstrap --exclude=info,tasksel,tasksel-data,isc-dhcp-client,isc-dhcp-common "$SUITE" "$BASECHROOT" http://deb.debian.org/debian
   tar -C "$BASECHROOT" --exclude='var/cache/apt/archives/*.deb' -zcf "${SUITE}".tar.gz ./
 
 [TIP]
@@ -721,10 +722,11 @@ By default debootstrap builds a chroot matching the architecture of the running
 host system. If you're using an amd64 system and want to build an i386 base.tgz
 then invoke debootstrap using the '--arch i386' option. Disclaimer: building an
 AMD64 base.tgz won't work if you are using a 32bit kernel system of course.
+Also building an ARM64 base.tgz requires an arm64 system.
 
 Finally place the generated tarball in /etc/grml/fai/config/basefiles/ (note
 that it needs to be uppercase letters matching the class names, so: e.g.
-AMD64.tar.gz for amd64 and I386.tar.gz for i386).
+AMD64.tar.gz for amd64, I386.tar.gz for i386 or ARM64.tar.gz for arm64).
 
 Then executing grml-live should use this file as base system instead of executing
 debootstrap. Check out the output for something like:
index c7e69a0..115df2d 100644 (file)
@@ -13,7 +13,6 @@ eject
 fdisk
 file
 gpm
-grml2usb
 grml-autoconfig
 grml-crypt
 grml-debian-keyring
@@ -28,9 +27,6 @@ grml-scripts
 grml-scripts-core
 grml-tips
 grml-udev-config
-grub-efi-amd64-bin
-grub-efi-ia32-bin
-grub-pc
 haveged
 hdparm
 hwinfo
@@ -51,7 +47,6 @@ resolvconf
 rsync
 rsyslog
 strace
-syslinux syslinux-common syslinux-utils
 udev
 usbutils
 uuid-runtime
@@ -83,3 +78,20 @@ firmware-zd1211
 
 libpam-systemd
 systemd-container
+
+PACKAGES install I386
+grub-pc
+grub-efi-amd64-bin
+grub-efi-ia32-bin
+syslinux syslinux-common syslinux-utils
+grml2usb
+
+PACKAGES install AMD64
+grub-pc
+grub-efi-amd64-bin
+grub-efi-ia32-bin
+syslinux syslinux-common syslinux-utils
+grml2usb
+
+PACKAGES install ARM64
+grub-efi-arm64-bin
index 5cceb2b..e0dc1c5 100644 (file)
@@ -3,7 +3,6 @@ PACKAGES install
 grml-live
 grml-paste
 grml-quickconfig-standard
-grml-terminalserver
 
 # base os
 apt
@@ -41,9 +40,6 @@ brltty
 espeak-ng
 espeakup
 
-# broken userland debugging
-ltrace
-
 # deploy on remote sites
 openvpn
 ppp
@@ -51,7 +47,6 @@ pppoeconf
 
 # disk subsystems support/debugging
 array-info
-cciss-vol-status
 cryptsetup
 disktype
 dmraid
@@ -76,7 +71,6 @@ stenc
 # disk partitioning/boot
 boot-info-script
 gparted
-grub-pc-bin
 kpartx
 mbr
 partclone
@@ -334,8 +328,6 @@ xterm
 # x86 hardware support
 acpi
 acpi-support
-cmospwd
-cpuid
 irqbalance
 lm-sensors
 lshw
@@ -355,15 +347,41 @@ stress
 man-db
 
 PACKAGES install I386
+# kernel related
 linux-image-686
 linux-cpupower
+# disk subsystems support/debugging, I386/AMD64 specific
+cciss-vol-status
+# x86 hardware support
+cmospwd
+cpuid
+# broken userland debugging
+ltrace
+# disk partitioning/boot
+grub-pc-bin
+
+# PXE boot
+grml-terminalserver
 
 # firmware updates
 fwupd-i386-signed
 
 PACKAGES install AMD64
+# kernel related
 linux-image-amd64
 linux-cpupower
+# disk subsystems support/debugging
+cciss-vol-status
+# x86 hardware support
+cmospwd
+cpuid
+# broken userland debugging
+ltrace
+# disk partitioning/boot
+grub-pc-bin
+
+# PXE boot
+grml-terminalserver
 
 # EFI PXE boot support in grml-terminalserver
 grub-efi-amd64-signed
@@ -371,3 +389,11 @@ shim-signed
 
 # firmware updates
 fwupd-amd64-signed
+
+PACKAGES install ARM64
+# kernel related
+linux-image-arm64
+linux-cpupower
+
+# firmware updates
+fwupd-arm64-signed
index 3ad56a4..82e0a82 100644 (file)
@@ -113,3 +113,6 @@ linux-image-686
 
 PACKAGES install AMD64
 linux-image-amd64
+
+PACKAGES install ARM64
+linux-image-arm64
index 5caa73a..d00d376 100755 (executable)
@@ -11,7 +11,14 @@ set -u
 
 $ROOTCMD mkdir -p /boot/grub
 
-$ROOTCMD grub-mkimage -d /usr/lib/grub/i386-pc \
+if ifclass ARM64 ; then
+  echo "Skipping execution of script on ARM64"
+  exit 0
+fi
+
+# generate /boot/grub/core.img
+$ROOTCMD grub-mkimage \
+  -d /usr/lib/grub/i386-pc \
   -p /boot/grub \
   -o /boot/grub/core.img \
   biosdisk iso9660 \
index 16c0e9a..76c0e10 100755 (executable)
@@ -28,6 +28,19 @@ ARCHS=(i386-pc)
 declare -A ADDITIONAL_MODULES
 ADDITIONAL_MODULES[i386-pc]="biosdisk"
 
+# arm64 doesn't provide /usr/lib/grub/i386-efi, so we don't include
+# i386-pc in $ARCHS (whereas on AMD64 we have both i386-pc + x86_64-efi)
+if ifclass ARM64 ; then
+  if [ -r "${target}"/usr/lib/grub/arm64-efi/moddep.lst ] ; then
+    ARCHS=(arm64-efi)
+    # NOTE: efi_uga (EFI Universal Graphics Adapter) is deprecated + unavailable on arm64
+    ADDITIONAL_MODULES[arm64-efi]="efi_gop"  # no efi_uga available
+  else
+    echo "/usr/lib/grub/arm64-efi/moddep.lst.lst could not be found, skipping."
+    echo "NOTE: grub-efi-arm64-bin not installed?"
+  fi
+fi
+
 if ifclass AMD64 ; then
   if [ -r "${target}"/usr/lib/grub/x86_64-efi/moddep.lst ] ; then
     ARCHS+=(x86_64-efi)
@@ -54,6 +67,7 @@ for arch in "${ARCHS[@]}" ; do
     i386-pc)    filename=/boot/grub/grub.img ;;
     x86_64-efi) filename=/boot/bootx64.efi   ;;
     i386-efi)   filename=/boot/bootia32.efi  ;;
+    arm64-efi)  filename=/boot/bootaa64.efi  ;;
   esac
 
   $ROOTCMD grub-mkimage -O $arch -o "$filename" --prefix=/boot/grub/ --config="$TMP_CONFIG" \
index 4fb6935..6762ff7 100644 (file)
@@ -58,7 +58,7 @@
 # Notice: GRMLBASE is recommended in any case unless you *really* know what you
 # are doing; make sure to also use a GRML_* class (for example GRML_SMALL
 # or GRML_FULL) to get an according kernel and also select the
-# architecture (I386 for x86; AMD64 for x86_64)
+# architecture (I386 for x86; AMD64 for x86_64, ARM64 for arm64)
 # CLASSES="GRMLBASE,GRML_FULL,I386"
 
 # HTTP Proxy to use for APT
index aff48e8..b0750ec 100644 (file)
@@ -36,7 +36,7 @@ _grmllive_classes() { #{{{
         DEBORPHAN FRESHCLAM
         GRMLBASE GRML_FULL GRML_SMALL
         LATEX LATEX_CLEANUP LOCALES NO_ONLINE RELEASE REMOVE_DOCS SOURCES XORG ZFS
-        I386 AMD64
+        I386 AMD64 ARM64
     )
     compset -P '*,'
     already=(${(s<,>)IPREFIX})
index fa478b8..02cf2e8 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -43,7 +43,7 @@ $PN - build process script for generating a (grml based) Linux Live-ISO
 
 Usage: $PN [options, see as follows]
 
-   -a <architecture>       architecture; available values: i386 and amd64
+   -a <architecture>       architecture; available values: i386, amd64 + arm64
    -A                      clean build directories before and after running
    -b                      build the ISO without updating the chroot via FAI
    -B                      build the ISO without touching the chroot (skips cleanup)
@@ -484,6 +484,12 @@ specify it on the command line using the -c option."
 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
 specify it on the command line using the -o option."
 
+if [[ "$(dpkg --print-architecture)" != "arm64" ]] && [[ "$ARCH" == "arm64" ]] ; then
+  eerror "Failure: trying to build for arm64, but not running on arm64."
+  eend 1
+  bailout
+fi
+
 # trim characters that are known to cause problems inside $GRML_NAME;
 # for example isolinux does not like '-' inside the directory name
 [ -n "$GRML_NAME" ] && export SHORT_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
@@ -493,6 +499,7 @@ specify it on the command line using the -o option."
 [ -n "$RELEASENAME" ] && export RELEASENAME="$RELEASENAME"
 # }}}
 
+
 # ZERO_LOGFILE - check for backwards compatibility reasons {{{
 # this was default behaviour until grml-live 0.9.34:
 if [ -n "$ZERO_LOGFILE" ] ; then
@@ -685,20 +692,28 @@ export SUITE # make sure it's available in FAI scripts
 # architecture (option), otherwise installation of kernel will fail
 if echo $CLASSES | grep -qw I386 ; then
    if ! [[ "$ARCH" == "i386" ]] ; then
-      log    "Error: You specified the I386 class but are trying to build something else (AMD64?)."
-      eerror "Error: You specified the I386 class but are trying to build something else (AMD64?)."
+      log    "Error: You specified the I386 class but are trying to build something else (AMD64/ARM64?)."
+      eerror "Error: You specified the I386 class but are trying to build something else (AMD64/ARM64?)."
       eerror "Tip:   Either invoke grml-live with '-a i386' or adjust the architecture class. Exiting."
       eend 1
       bailout
    fi
 elif echo $CLASSES | grep -qi amd64 ; then
    if ! [[ "$ARCH" == "amd64" ]] ; then
-      log    "Error: You specified the AMD64 class but are trying to build something else (I386?)."
-      eerror "Error: You specified the AMD64 class but are trying to build something else (I386?)."
+      log    "Error: You specified the AMD64 class but are trying to build something else (I386/ARM64?)."
+      eerror "Error: You specified the AMD64 class but are trying to build something else (I386/ARM64?)."
       eerror "Tip:   Either invoke grml-live with '-a amd64' or adjust the architecture class. Exiting."
       eend 1
       bailout
    fi
+elif echo $CLASSES | grep -qi arm64 ; then
+   if ! [[ "$ARCH" == "arm64" ]] ; then
+      log    "Error: You specified the ARM64 class but are trying to build something else (I386/AMD64?)."
+      eerror "Error: You specified the ARM64 class but are trying to build something else (I386/AMD64?)."
+      eerror "Tip:   Either invoke grml-live with '-a arm64' or adjust the architecture class. Exiting."
+      eend 1
+      bailout
+   fi
 fi
 
 # generate nfsroot configuration for FAI on the fly
@@ -905,8 +920,6 @@ fi
 
 # grub boot {{{
 grub_setup() {
-  BOOTX64="/boot/bootx64.efi"
-  BOOTX32="/boot/bootia32.efi"
   EFI_IMG="/boot/efi.img"
 
   local efi_size
@@ -917,7 +930,16 @@ grub_setup() {
     efi_size='8M'
   fi
 
-  if [[ "$ARCH" == "amd64" ]] ; then
+  if [[ "$ARCH" == "amd64" ]] || [[ "$ARCH" == "arm64" ]] ; then
+    case "$ARCH" in
+      arm64)
+        BOOTX64="/boot/bootaa64.efi"
+        ;;
+      amd64)
+        BOOTX64="/boot/bootx64.efi"
+        ;;
+    esac
+
     # important: this depends on execution of ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/45-grub-images
     if ! [ -r "${CHROOT_OUTPUT}/${BOOTX64}" ] ; then
       log    "Can not access GRUB efi image ${CHROOT_OUTPUT}/${BOOTX64}, required for Secure Boot support"
@@ -936,8 +958,15 @@ grub_setup() {
       log   "Secure Boot is disabled."
       einfo "Secure Boot is disabled." ; eend 0
 
-      # install "$BOOTX64" as ::EFI/BOOT/bootx64.efi inside image file "$EFI_IMG":
-      mcopy -i "${CHROOT_OUTPUT}/${EFI_IMG}" "${CHROOT_OUTPUT}/${BOOTX64}" ::EFI/BOOT/bootx64.efi >/dev/null || bailout 53
+      # install "$BOOTX64" as ::EFI/BOOT/{bootx64.efi|bootaa64.efi} inside image file "$EFI_IMG":
+      case "$ARCH" in
+        arm64)
+          mcopy -i "${CHROOT_OUTPUT}/${EFI_IMG}" "${CHROOT_OUTPUT}/${BOOTX64}" ::EFI/BOOT/bootaa64.efi >/dev/null || bailout 53
+          ;;
+        amd64)
+          mcopy -i "${CHROOT_OUTPUT}/${EFI_IMG}" "${CHROOT_OUTPUT}/${BOOTX64}" ::EFI/BOOT/bootx64.efi >/dev/null || bailout 53
+          ;;
+      esac
 
       log   "Generated 64-bit EFI image $BOOTX64"
       einfo "Generated 64-bit EFI image $BOOTX64" ; eend 0
@@ -998,6 +1027,7 @@ grub_setup() {
   fi
 
   if [[ "$ARCH" == "i386" ]] ; then
+    BOOTX32="/boot/bootia32.efi"
     if ! [ -r "${CHROOT_OUTPUT}/${BOOTX32}" ] ; then
       log    "Can not access GRUB efi image ${CHROOT_OUTPUT}/${BOOTX32}."
       eerror "Can not access GRUB efi image ${CHROOT_OUTPUT}/${BOOTX32}." ; eend 1
@@ -1022,7 +1052,7 @@ grub_setup() {
 mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for stage ARCH"
 
 # prepare ISO
-if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
+if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] || [ "$ARCH" = arm64 ] ; 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
@@ -1092,9 +1122,17 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
     grub_setup
 
     # EFI boot files
-    if [ -r "${CHROOT_OUTPUT}/boot/efi.img" -a -r "${CHROOT_OUTPUT}/boot/bootx64.efi" ] ; then
-      einfo "Copying 64-bit EFI boot files into ISO path."
-      log   "Copying 64-bit EFI boot files into ISO path."
+    if [ -r "${CHROOT_OUTPUT}/boot/efi.img" -a -r "${CHROOT_OUTPUT}/boot/bootaa64.efi" ] ; then
+      einfo "Copying 64-bit EFI boot files (arm64) into ISO path."
+      log   "Copying 64-bit EFI boot files (arm64) into ISO path."
+      RC=$0
+      cp "${CHROOT_OUTPUT}/boot/efi.img" "${BUILD_OUTPUT}/boot/" || RC=$?
+      mkdir -p "${BUILD_OUTPUT}/EFI/BOOT/" || RC=$?
+      cp "${CHROOT_OUTPUT}/boot/bootaa64.efi" "${BUILD_OUTPUT}/EFI/BOOT/bootaa64.efi" || RC=$?
+      eend $?
+    elif [ -r "${CHROOT_OUTPUT}/boot/efi.img" -a -r "${CHROOT_OUTPUT}/boot/bootx64.efi" ] ; then
+      einfo "Copying 64-bit EFI boot files (amd64) into ISO path."
+      log   "Copying 64-bit EFI boot files (amd64) into ISO path."
       RC=$0
       cp "${CHROOT_OUTPUT}/boot/efi.img" "${BUILD_OUTPUT}/boot/" || RC=$?
       mkdir -p "${BUILD_OUTPUT}/EFI/BOOT/" || RC=$?
@@ -1102,7 +1140,7 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
       eend $?
     elif [ -r "${CHROOT_OUTPUT}/boot/efi.img" -a -r "${CHROOT_OUTPUT}/boot/bootia32.efi" ] ; then
       einfo "Copying 32-bit EFI boot files into ISO path."
-      log "Copying 32-bit EFI boot files into ISO path."
+      log   "Copying 32-bit EFI boot files into ISO path."
       RC=$0
       cp "${CHROOT_OUTPUT}/boot/efi.img" "${BUILD_OUTPUT}/boot/" || RC=$?
       mkdir -p "${BUILD_OUTPUT}/EFI/BOOT/" || RC=$?
@@ -1231,22 +1269,34 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
     fi
     echo "source /boot/grub/footer.cfg" >> "${BUILD_OUTPUT}"/boot/grub/loopback.cfg
 
-    # copy grub files from target
-    mkdir -p "${BUILD_OUTPUT}"/boot/grub/i386-pc/
-    cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.mod "${BUILD_OUTPUT}"/boot/grub/i386-pc/
-    cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.o "${BUILD_OUTPUT}"/boot/grub/i386-pc/
-    cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.lst "${BUILD_OUTPUT}"/boot/grub/i386-pc/
-    cp -a "${CHROOT_OUTPUT}"/usr/share/grub/ascii.pf2 "${BUILD_OUTPUT}"/boot/grub/
-    cp -a "${CHROOT_OUTPUT}"/boot/grub/core.img "${BUILD_OUTPUT}"/boot/grub/
-    cp -a "${CHROOT_OUTPUT}"/boot/grub/grub.img "${BUILD_OUTPUT}"/boot/grub/
-
-    # copy modules for UEFI grub, 64-bit
-    mkdir -p "${BUILD_OUTPUT}"/boot/grub/x86_64-efi/
-    cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/x86_64-efi/*.{mod,lst} "${BUILD_OUTPUT}"/boot/grub/x86_64-efi/
-
-    # copy modules for UEFI grub, 32-bit
-    mkdir -p "${BUILD_OUTPUT}"/boot/grub/i386-efi/
-    cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/i386-efi/*.{mod,lst} "${BUILD_OUTPUT}"/boot/grub/i386-efi/
+    # copy modules for GRUB
+    if [ "${ARCH}" = "arm64" ] ; then
+      mkdir -p "${BUILD_OUTPUT}"/boot/grub/arm64-efi/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/arm64-efi/*.mod "${BUILD_OUTPUT}"/boot/grub/arm64-efi/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/arm64-efi/*.lst "${BUILD_OUTPUT}"/boot/grub/arm64-efi/
+      # NOTE: usage of /boot/grub/core.img + /boot/grub/grub.img unclear yet
+    elif [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "i386" ] ; then
+      # grub-pc-bin
+      mkdir -p "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.mod  "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.o    "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.lst  "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+
+      # grub-efi-amd64-bin
+      mkdir -p "${BUILD_OUTPUT}"/boot/grub/x86_64-efi/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/x86_64-efi/*.{mod,lst} "${BUILD_OUTPUT}"/boot/grub/x86_64-efi/
+
+      # grub-efi-ia32-bin
+      mkdir -p "${BUILD_OUTPUT}"/boot/grub/i386-efi/
+      cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/i386-efi/*.{mod,lst} "${BUILD_OUTPUT}"/boot/grub/i386-efi/
+
+      cp -a "${CHROOT_OUTPUT}"/boot/grub/core.img       "${BUILD_OUTPUT}"/boot/grub/
+      cp -a "${CHROOT_OUTPUT}"/boot/grub/grub.img       "${BUILD_OUTPUT}"/boot/grub/
+    fi
+
+    # arch independent files
+    cp -a "${CHROOT_OUTPUT}"/usr/share/grub/ascii.pf2     "${BUILD_OUTPUT}"/boot/grub/
+    cp -a "${CHROOT_OUTPUT}"/usr/share/grub/unicode.pf2   "${BUILD_OUTPUT}"/boot/grub/  # clarify
 
     if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
       log    "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
index b4ce608..e0a3d26 100644 (file)
@@ -2,18 +2,23 @@ submenu "Addons ->" --class=submenu {
 
 # EFI:
 if [ "${grub_platform}" == "efi" ] ; then
-  # try to detect amd64 by checking whether CPU supports 64-bit (long) mode
-  if cpuid -l ; then
-    if test -e /boot/addons/memtest86+x64.efi ; then
-      menuentry "Memory test (memtest86+x64.efi)" {
-        linuxefi /boot/addons/memtest86+x64.efi
-      }
-    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
-      }
+  # arm64 doesn't provide the cpuid command, and we also
+  # don't have any memtest* efi files available, so only
+  # run on architectures other than arm64 (amd64 + i386)
+  if [ "${grub_cpu}" != "arm64" ] ; then
+    # try to detect amd64 by checking whether CPU supports 64-bit (long) mode
+    if cpuid -l ; then
+      if test -e /boot/addons/memtest86+x64.efi ; then
+        menuentry "Memory test (memtest86+x64.efi)" {
+          linuxefi /boot/addons/memtest86+x64.efi
+        }
+      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
+        }
+      fi
     fi
   fi
 fi