device-apple-mac-aarch64: add support for os-installer
This also sneaks in a change to add 'quiet' on the kernel cmdline, to remove some kernel msg noise on the screen that overwrites the splash sometimes on boot. Signed-off-by: Clayton Craft <craftyguy@postmarketos.org> Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7112>
This commit is contained in:
parent
923c4ab36e
commit
557772ebd4
3 changed files with 104 additions and 3 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# Reference: <https://postmarketos.org/devicepkg>
|
||||
pkgname=device-apple-mac-aarch64
|
||||
pkgdesc="Apple M-series Macs"
|
||||
pkgver=2
|
||||
pkgver=3
|
||||
pkgrel=0
|
||||
url="https://postmarketos.org"
|
||||
license="MIT"
|
||||
|
|
@ -24,8 +24,9 @@ source="
|
|||
initramfs_copy_vendorfw.sh
|
||||
initramfs_setup_vendorfw.sh
|
||||
modules-initfs
|
||||
os-installer-deploy.sh
|
||||
"
|
||||
subpackages="$pkgname-audio"
|
||||
subpackages="$pkgname-audio $pkgname-os-installer:os_installer"
|
||||
|
||||
build() {
|
||||
devicepkg_build $startdir $pkgname
|
||||
|
|
@ -40,6 +41,10 @@ package() {
|
|||
install -Dm755 "$srcdir"/initramfs_copy_vendorfw.sh \
|
||||
-t "$pkgdir"/usr/share/mkinitfs/hooks-cleanup/
|
||||
|
||||
# os-installer support
|
||||
install -Dm755 "$srcdir"/os-installer-deploy.sh \
|
||||
"$pkgdir"/etc/os-installer/deploy.sh
|
||||
|
||||
# u-boot-asahi has a trigger that installs m1n1+u-boot and expects this dir to
|
||||
# exist, or else it crashes. This dir won't exist when building a new
|
||||
# install/image so we have to create it manually.
|
||||
|
|
@ -55,9 +60,18 @@ audio() {
|
|||
mkdir -p "$subpkgdir"
|
||||
}
|
||||
|
||||
os_installer() {
|
||||
install_if="$pkgname=$pkgver-r$pkgrel postmarketos-ui-os-installer"
|
||||
description="Support for using os-installer"
|
||||
depends="gojq"
|
||||
|
||||
amove etc/os-installer/deploy.sh
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
42a8fe25e024a9cec7b900ddbb2bd1275810b80bafadc043e571e060c76c8aa0eb545c5ad4714aa6ce0354785187ae987827dfc3b3948d7d9901575bbc2a70b0 deviceinfo
|
||||
ae2ad6d49ee3d0d1328f6e5a2c44daaca29d200122c5a8972b254a2504bd7712b54cb08fa15481eb667705e1c7934b3b30a614ebf478222f8b48db8f7559bcdc deviceinfo
|
||||
f111ddc0484f079af23520dcc9b4d909b55da327aec91545921a4ceafc52b21d88f37fbdb702e51ca1e49440b6afc2011ada8b681c1801f572bddc9cd34c9d9e initramfs_copy_vendorfw.sh
|
||||
11d5d6af50ed73e7e6940f7d56730f94a1bb42990d5dba9a798522060e7717c410c025b12def0345b4f43c97da268dabcb484c3004d23c1ac39b1eeaaefd2967 initramfs_setup_vendorfw.sh
|
||||
d6aa23ece36ff7b393f0cc50627198584a9f052f5f900e8d44b6655c8aa2b7c7b025a00b8fef426a5541b4f20432f6249da80486ebe7597e2c4a54dc6caf467b modules-initfs
|
||||
7b9a75b2d471be7eef06d4f4b6bff64a2164fd23332311388e1a1962a63b18dfed4d2252a910302313f556c84030ef92cdca4f853f9076874776db070b1c09cc os-installer-deploy.sh
|
||||
"
|
||||
|
|
|
|||
|
|
@ -15,5 +15,6 @@ deviceinfo_external_storage="false"
|
|||
deviceinfo_drm="true"
|
||||
|
||||
# Bootloader related
|
||||
deviceinfo_kernel_cmdline="quiet"
|
||||
deviceinfo_generate_systemd_boot="true"
|
||||
deviceinfo_boot_filesystem="fat32"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
#!/bin/sh
|
||||
|
||||
IMAGE_PATH="$1"
|
||||
if [ ! -f "$IMAGE_PATH" ]; then
|
||||
echo "ERROR: No image given!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find ESP on local device, which should have the stage 2 bootloader that
|
||||
# started this current session, then use that to locate the local storage device
|
||||
# containing this ESP. If we're not installing to this device then throw an
|
||||
# error.
|
||||
ESP_UUID=$(cat /proc/device-tree/chosen/asahi,efi-system-partition)
|
||||
ESP_PART_DEV=$(readlink -f "/dev/disk/by-partuuid/$ESP_UUID")
|
||||
ESP_PART_NAME=$(basename "$ESP_PART_DEV")
|
||||
LOCAL_DEVICE="/dev/$(basename "$(readlink -f "/sys/class/block/$ESP_PART_NAME/..")")"
|
||||
|
||||
if [ -z "$LOCAL_DEVICE" ]; then
|
||||
echo "ERROR: unable to find boot device!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if installing to local device with stage2 ESP
|
||||
if [ "$LOCAL_DEVICE" != "$OSI_DEVICE_PATH" ]; then
|
||||
echo "ERROR: This currently only supports installing to local storage ($LOCAL_DEVICE), selected device: $OSI_DEVICE_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup() {
|
||||
# Unmount ESP and image ESP if mounted
|
||||
if mountpoint -q /mnt/esp 2>/dev/null; then
|
||||
doas umount /mnt/esp
|
||||
fi
|
||||
if mountpoint -q /mnt/image-esp 2>/dev/null; then
|
||||
doas umount /mnt/image-esp
|
||||
fi
|
||||
|
||||
# Detach loop device
|
||||
if [ -n "$LOOP_DEV" ] && [ -e "$LOOP_DEV" ]; then
|
||||
doas losetup -d "$LOOP_DEV"
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# Set up loop device to access image partitions
|
||||
LOOP_DEV=$(doas losetup --find --show --partscan "$IMAGE_PATH")
|
||||
|
||||
# TODO: Don't hardcode partition layout assumptions
|
||||
# Currently assuming: p1=ESP/boot, p2=root partition
|
||||
IMG_ESP_PART="${LOOP_DEV}p1"
|
||||
IMG_ROOT_PART="${LOOP_DEV}p2"
|
||||
|
||||
# The ESP's filesystem UUID won't match the UUID in the image's fstab, so let's
|
||||
# set the ESP's filesystem UUID to the UUID of the image's ESP. This saves us
|
||||
# from having to mount (and optionally decrypt) the image's rootfs to change
|
||||
# fstab...
|
||||
IMG_ESP_UUID=$(doas blkid -s UUID -o value "$IMG_ESP_PART")
|
||||
if [ -z "$IMG_ESP_UUID" ]; then
|
||||
echo "ERROR: Could not get ESP UUID from image!"
|
||||
exit 1
|
||||
fi
|
||||
# The FAT32 UUID is actually the ID for the volume.
|
||||
# Convert FAT32 UUID format (1234-5678) to 8-digit hex vol. ID (12345678)
|
||||
IMG_ESP_VOL_ID=$(echo "$IMG_ESP_UUID" | tr -d '-')
|
||||
echo "Setting target ESP serial to match image: $IMG_ESP_VOL_ID"
|
||||
doas fatlabel -i "$ESP_PART_DEV" "$IMG_ESP_VOL_ID"
|
||||
|
||||
# Generate repart config and use CopyBlocks for block-level copy, which should
|
||||
# preserve filesystem UUID, and (optional) luks
|
||||
doas mkdir -p /run/repart.d
|
||||
doas tee /run/repart.d/70-pmos-root.conf > /dev/null <<EOF
|
||||
[Partition]
|
||||
Type=root
|
||||
CopyBlocks=${IMG_ROOT_PART}
|
||||
SizeMinBytes=5G
|
||||
EOF
|
||||
|
||||
# Create the rootfs on target device
|
||||
doas systemd-repart --dry-run=no "$OSI_DEVICE_PATH"
|
||||
|
||||
# Mount ESP partitions and copy contents
|
||||
doas mkdir -p /mnt/esp /mnt/image-esp
|
||||
doas mount "$ESP_PART_DEV" /mnt/esp
|
||||
doas mount "$IMG_ESP_PART" /mnt/image-esp
|
||||
doas cp -a /mnt/image-esp/* /mnt/esp/
|
||||
Loading…
Add table
Add a link
Reference in a new issue