postmarketos-update-kernel: support A/B devices (MR 2214)
Add support for detecting A/B devices and cleanup the script a bit.
This commit is contained in:
parent
d677f1ed32
commit
d0d6372405
2 changed files with 40 additions and 18 deletions
|
@ -1,5 +1,5 @@
|
|||
pkgname=postmarketos-update-kernel
|
||||
pkgver=0.0.4
|
||||
pkgver=0.0.5
|
||||
pkgrel=0
|
||||
pkgdesc="kernel updater script for postmarketOS"
|
||||
url="https://postmarketos.org"
|
||||
|
@ -12,4 +12,7 @@ package() {
|
|||
install -Dm755 "$srcdir/update-kernel.sh" \
|
||||
"$pkgdir/sbin/pmos-update-kernel"
|
||||
}
|
||||
sha512sums="17de682e88fec2632cb51c6b034e7b9c27e77736d5943906a57e276fb4c594af7af93e411e8cdb1ea2aeefb8d7f231408195102b02af3e8e55d594d1c812ff16 update-kernel.sh"
|
||||
|
||||
sha512sums="
|
||||
256892629581fb9813ef9e7aa5bc18e7c1b80c88b97baeb96d7d432418f4cba79e0687193d7eca48bb3dba1543a3b7d1685f686206497c82df2e1ef80e026eb1 update-kernel.sh
|
||||
"
|
||||
|
|
|
@ -15,28 +15,47 @@ deviceinfo_append_dtb=""
|
|||
# shellcheck disable=SC1091
|
||||
. /etc/deviceinfo
|
||||
|
||||
# On A/B devices with bootloader cmdline ON this will return the slot suffix
|
||||
# if booting with an alternate method which erases the stock bootloader cmdline
|
||||
# this will be empty and the update will fail.
|
||||
# https://source.android.com/devices/bootloader/updating#slots
|
||||
# On non-A/B devices this will be empty
|
||||
ab_get_slot() {
|
||||
ab_slot_suffix=$(grep -o 'androidboot\.slot_suffix=..' /proc/cmdline | cut -d "=" -f2) || :
|
||||
echo "$ab_slot_suffix"
|
||||
}
|
||||
|
||||
update_android_fastboot() {
|
||||
BOOT_PART_SUFFIX=$(ab_get_slot) # Empty for non-A/B devices
|
||||
BOOT_PARTITION=$(findfs PARTLABEL="boot${BOOT_PART_SUFFIX}")
|
||||
echo "Flashing boot.img to 'boot${BOOT_PART_SUFFIX}'"
|
||||
dd if=/boot/boot.img-"$FLAVOR" of="$BOOT_PARTITION" bs=1M
|
||||
}
|
||||
|
||||
update_android_split_kernel_initfs() {
|
||||
KERNEL_PARTITION=$(findfs PARTLABEL="${deviceinfo_flash_heimdall_partition_kernel:?}")
|
||||
INITFS_PARTITION=$(findfs PARTLABEL="${deviceinfo_flash_heimdall_partition_initfs:?}")
|
||||
|
||||
KERNEL="vmlinuz-$FLAVOR"
|
||||
if [ "${deviceinfo_append_dtb}" = "true" ]; then
|
||||
KERNEL="$KERNEL-dtb"
|
||||
fi
|
||||
|
||||
echo "Flashing kernel ($KERNEL)..."
|
||||
dd if=/boot/"$KERNEL" of="$KERNEL_PARTITION" bs=1M
|
||||
|
||||
echo "Flashing initramfs..."
|
||||
gunzip -c /boot/initramfs-"$FLAVOR" | lzop | dd of="$INITFS_PARTITION" bs=1M
|
||||
}
|
||||
|
||||
FLAVOR=$1
|
||||
METHOD=${deviceinfo_flash_method:?}
|
||||
case $METHOD in
|
||||
fastboot|heimdall-bootimg)
|
||||
BOOT_PARTITION=$(findfs PARTLABEL="boot")
|
||||
echo "Flashing boot.img..."
|
||||
dd if=/boot/boot.img-"$FLAVOR" of="$BOOT_PARTITION" bs=1M
|
||||
update_android_fastboot
|
||||
;;
|
||||
heimdall-isorec)
|
||||
KERNEL_PARTITION=$(findfs PARTLABEL="${deviceinfo_flash_heimdall_partition_kernel:?}")
|
||||
INITFS_PARTITION=$(findfs PARTLABEL="${deviceinfo_flash_heimdall_partition_initfs:?}")
|
||||
|
||||
KERNEL="vmlinuz-$FLAVOR"
|
||||
if [ "${deviceinfo_append_dtb}" = "true" ]; then
|
||||
KERNEL="$KERNEL-dtb"
|
||||
fi
|
||||
|
||||
echo "Flashing kernel ($KERNEL)..."
|
||||
dd if=/boot/"$KERNEL" of="$KERNEL_PARTITION" bs=1M
|
||||
|
||||
echo "Flashing initramfs..."
|
||||
gunzip -c /boot/initramfs-"$FLAVOR" | lzop | dd of="$INITFS_PARTITION" bs=1M
|
||||
update_android_split_kernel_initfs
|
||||
;;
|
||||
0xffff)
|
||||
echo -n "No need to use this utility, since uboot loads the kernel directly from"
|
||||
|
|
Loading…
Reference in a new issue