umorpha-boxes/images/orangepi.sh.uefi

67 lines
2.0 KiB
Plaintext
Raw Normal View History

2024-02-26 23:38:25 +00:00
#!/bin/bash
set -euE -o pipefail
cleanup=()
_do_cleanup() {
if [[ $? == 0 ]]; then
echo ":: Cleaning up..."
else
echo >&2 "!! ERROR! Cleaning up..."
fi
for (( i=${#cleanup[@]}-1; i >= 0; i-- )); do
eval "${cleanup[$i]}"
done
}
trap '_do_cleanup' EXIT
set -x
################################################################################
rm -f orangepi.img
rmdir orangepi.d
truncate --size=2G orangepi.img
parted --script "$loopdev" -- mklabel gpt
parted --script "$loopdev" -- mkpart 8192 $((1024*1024))
parted --script "$loopdev" -- type 1 3DE21764-95BD-54BD-A5C3-4ABE786F38A8 # U-Boot Env
parted --script "$loopdev" -- name 1 "U-Boot"
parted --script "$loopdev" -- mkpart 1M 513M
parted --script "$loopdev" -- type 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B # EFI System Partition
parted --script "$loopdev" -- name 1 "EFI System Partition"
parted --script "$loopdev" -- mkpart 8192 $((1024*1024))
parted --script "$loopdev" -- type 1 3DE21764-95BD-54BD-A5C3-4ABE786F38A8 # U-Boot
parted --script "$loopdev" -- name 1 "U-Boot"
set 1 boot on
sudo partprobe "$loopdev"
loopdev=$(sudo losetup --find --show --partscan -- orangepi.img)
cleanup+=("sudo losetup --detach ${loopdev@Q}")
sudo mkfs.ext4 -F -O ^metadata_csum,^64bit "${loopdev}p1"
mkdir -p orangepi.d
sudo mount "${loopdev}p1" orangepi.d
cleanup+=("sudo umount orangepi.d")
./bin/osi-mk \
--conf=format=dir --conf=bootloader=none --edit \
--package=base \
--package=linux-libre \
--package=uboot4extlinux-orangepi_one \
orangepi.d
sudo install -m644 \
/home/lukeshu/packages/abslibre/libre/uboot4extlinux-sunxi/pkg/uboot4extlinux-orangepi_one/usr/lib/u-boot/uboot4extlinux-orangepi_one/u-boot-sunxi-with-spl.bin \
orangepi.d/usr/lib/u-boot/uboot4extlinux-orangepi_one/u-boot-sunxi-with-spl.bin
sudo arch-chroot orangepi.d \
/usr/lib/u-boot/uboot4extlinux-orangepi_one/install-uboot4extlinux.sh "$loopdev"
sudo arch-chroot orangepi.d \
install -Dm644 /usr/lib/u-boot/uboot4extlinux-sunxi/extlinux.conf /boot/extlinux/extlinux.conf