Files
Factory/kiwi-builder-image/editbootinstall_rpi.sh
Rhys Oxenham 27aa096244
All checks were successful
Build PR in OBS / Build PR in OBS (pull_request_target) Successful in -39s
Add support for uEFI aarch64 images without rpi config as default
Previously, the default model for aarch64 raw disk images assumes that
you're deploying on Raspberry Pi, and not standard aarch64 systems. This
meant that all raw disk images were built with RPi firmware, and an MBR
boot record, which made it incompatible with systems that require uEFI/GPT
compatibility, especially with Edge Image Builder and Metal3/CAPI deployment
usage.

This PR introduces the following changes:

* Introduces new `Default-RPi` and `Base-RPi` profiles for compatibility with RPi users
* Forces `Base` and `Base-RT` profiles to use GPT based images (not MBR)
* Introduces a new `Base-RT-RPi` profile for kernel-rt on RPi (with MBR)
* Removes Raspberry Pi firmware packages from anything other than RPi profiles
* Modifies the `editbootinstall_rpi.sh` script to support container builds
* Adds policycoreutils-python-utils to the list of packages (for semanage)

See: https://bugzilla.suse.com/show_bug.cgi?id=1240619
2025-04-29 14:54:54 +01:00

48 lines
1.1 KiB
Bash

#!/bin/bash
set -euxo pipefail
diskname=$1
devname="$2"
loopname="${devname%*p?}"
loopdev=/dev/${loopname#/dev/*}
if [ ! -f $loopdev ]; then loopdev=/dev/${loopdev#/dev/mapper/}; fi
#==========================================
# copy Raspberry Pi firmware to EFI partition
#------------------------------------------
echo "RPi EFI system, installing firmware on ESP"
mkdir -p ./mnt-pi
mount ${loopname}p1 ./mnt-pi
( cd boot/vc; tar c . ) | ( cd ./mnt-pi/; tar x )
umount ./mnt-pi
rmdir ./mnt-pi
#==========================================
# Change partition label type to MBR
#------------------------------------------
#
# The target system doesn't support GPT, so let's move it to
# MBR partition layout instead.
#
# Also make sure to set the ESP partition to type 0xc so that
# broken firmware (Rpi) detects it as FAT.
#
# Use tabs, "<<-" strips tabs, but no other whitespace!
cat > gdisk.tmp <<-'EOF'
x
r
g
t
1
c
w
y
EOF
dd if=$loopdev of=mbrid.bin bs=1 skip=440 count=4
gdisk $loopdev < gdisk.tmp
dd of=$loopdev if=mbrid.bin bs=1 seek=440 count=4
rm -f mbrid.bin
rm -f gdisk.tmp