Files
pmaports-rtwo/temp/powervm-boot/powervm-boot.post-upgrade
T
Aelin 06bdbdba69 temp/powervm-boot: new aport
This is a bootloader for Open Firmware PowerPC systems that we will use
to replace grub-ieee1275 in device-generic-ppc64le. Due to its use of
RUSTC_BOOTSTRAP, this APKBUILD cannot go to Alpine at the moment, but
once the Rust targets are added upstream, this can be moved to aports.

Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/9002>
2026-08-03 19:24:11 +00:00

47 lines
1.3 KiB
Bash

#!/bin/sh
if [ ! -f /usr/lib/powervm-boot/powervm-boot ]; then
echo "powervm-boot not found"
exit
fi
PREP_GUID="9e1a2d38-c612-4316-aa26-8b49521e5a8b"
PREP_TYPE=0x41
lsblk -nrpo NAME,TYPE,PARTTYPE |
while read -r dev type parttype; do
[ "$type" = "part" ] || continue
case "$(printf '%s' "$parttype" | tr '[:upper:]' '[:lower:]')" in
"$PREP_GUID"|"$PREP_TYPE")
echo "Found PReP boot partition $dev"
magic=$(dd if="$dev" bs=1 count=4 2>/dev/null | od -An -tx1 | tr -d ' \n')
if [ "$magic" != "7f454c46" ]; then
echo "Not an ELF file"
continue
fi
class=$(dd if="$dev" bs=1 skip=4 count=1 2>/dev/null | od -An -tu1 | tr -d ' ')
if [ "$class" != "1" ]; then
echo "Not ELF32"
continue
fi
machine=$(dd if="$dev" bs=1 skip=18 count=2 2>/dev/null | od -An -tx1 | tr -d ' \n')
if [ "$machine" != "0014" ]; then
echo "Not PowerPC ELF"
continue
fi
echo "PReP boot partition with bootloader installed detected, flashing powervm-boot"
dd if=/usr/lib/powervm-boot/powervm-boot of="$dev" bs=512 conv=notrunc
sync
;;
esac
done