diff --git a/Dockerfile b/Dockerfile index dfee46f3..fe5f8b57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,18 @@ RUN zypper addrepo https://download.opensuse.org/repositories/isv:SUSE:Edge:Edge nm-configurator && \ zypper clean -a +# Make adjustments for running guestfish and image modifications on aarch64 +# guestfish looks for very specific locations on the filesystem for UEFI firmware +# and also expects the boot kernel to be a portable executable (PE), not ELF. +RUN if [[ $(uname -m) == "aarch64" ]]; then \ + zypper install -y qemu-uefi-aarch64; \ + mkdir -p /usr/share/edk2/aarch64; \ + cp /usr/share/qemu/aavmf-aarch64-code.bin /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw; \ + cp /usr/share/qemu/aavmf-aarch64-vars.bin /usr/share/edk2/aarch64/vars-template-pflash.raw; \ + mv /boot/vmlinux* /boot/backup-vmlinux; \ + zypper clean -a; \ +fi + COPY --from=0 /src/eib /bin/eib ENTRYPOINT ["/bin/eib"] diff --git a/pkg/build/raw_test.go b/pkg/build/raw_test.go index a40648be..e54b29e6 100644 --- a/pkg/build/raw_test.go +++ b/pkg/build/raw_test.go @@ -78,7 +78,7 @@ func TestWriteModifyScript(t *testing.T) { "btrfs filesystem label / INSTALL", "sed -i '/ignition.platform/ s/$/ alpha beta /' /tmp/grub.cfg", "truncate -s 64G", - "virt-resize --expand /dev/sda3", + "virt-resize --expand $ROOT_PART", }, expectedMissing: []string{}, }, diff --git a/pkg/build/templates/modify-raw-image.sh.tpl b/pkg/build/templates/modify-raw-image.sh.tpl index a5fb7c1a..293d6a6a 100644 --- a/pkg/build/templates/modify-raw-image.sh.tpl +++ b/pkg/build/templates/modify-raw-image.sh.tpl @@ -13,6 +13,17 @@ set -euo pipefail # # Guestfish Command Documentation: https://libguestfs.org/guestfish.1.html +# In x86_64, the default root partition is the third partition +ROOT_PART=/dev/sda3 + +# Make the necessarry adaptations for aarch64 +if [[ $(uname -m) == "aarch64" ]]; then + if ! test -f /dev/kvm; then + export LIBGUESTFS_BACKEND_SETTINGS=force_tcg + fi + ROOT_PART=/dev/sda2 +fi + # Test the block size of the base image and adapt to suit either 512/4096 byte images BLOCKSIZE=512 if ! guestfish -i --blocksize=$BLOCKSIZE -a {{.ImagePath}} echo "[INFO] 512 byte sector check successful."; then @@ -26,7 +37,7 @@ fi {{ if ne .DiskSize "" -}} truncate -r {{.ImagePath}} {{.ImagePath}}.expanded truncate -s {{.DiskSize}} {{.ImagePath}}.expanded -virt-resize --expand /dev/sda3 {{.ImagePath}} {{.ImagePath}}.expanded +virt-resize --expand $ROOT_PART {{.ImagePath}} {{.ImagePath}}.expanded cp {{.ImagePath}}.expanded {{.ImagePath}} rm -f {{.ImagePath}}.expanded {{ end }} diff --git a/pkg/rpm/resolver/templates/prepare-tarball.sh.tpl b/pkg/rpm/resolver/templates/prepare-tarball.sh.tpl index acf97d5c..bd3b3315 100644 --- a/pkg/rpm/resolver/templates/prepare-tarball.sh.tpl +++ b/pkg/rpm/resolver/templates/prepare-tarball.sh.tpl @@ -10,6 +10,11 @@ set -euo pipefail WORK_DIR={{.WorkDir}} IMG_PATH={{.ImgPath}} +# Make the necessarry adaptations for aarch64 +if [[ $(uname -m) == "aarch64" ]]; then + export LIBGUESTFS_BACKEND_SETTINGS=force_tcg +fi + {{ if eq .ImgType "iso" -}} xorriso -osirrox on -indev $IMG_PATH extract / $WORK_DIR/iso-root/ diff --git a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl index 99bcb210..a646a74e 100644 --- a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl +++ b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl @@ -12,7 +12,7 @@ set -euo pipefail {{ if ne .RegCode "" }} suseconnect -r {{ .RegCode }} -SLE_SP=$(cat /etc/rpm/macros.sle | awk '/sle/ {print $2};' | cut -c4) && suseconnect -p PackageHub/15.$SLE_SP/x86_64 +SLE_SP=$(cat /etc/rpm/macros.sle | awk '/sle/ {print $2};' | cut -c4) && suseconnect -p PackageHub/15.$SLE_SP/$(uname -m) zypper ref trap "suseconnect -d" EXIT {{ end -}} @@ -51,4 +51,4 @@ zypper \ --allow-vendor-change \ -n {{.PKGList}} {{.LocalRPMList}} -touch {{.CacheDir}}/zypper-success \ No newline at end of file +touch {{.CacheDir}}/zypper-success