From 70b0cf24e5578560417a4c6653f43196ddf5a34d Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Thu, 3 Jun 2021 01:31:22 +0100 Subject: [PATCH] postmarketos-mkinitfs: flash new boot image (MR 2215) On Android devices that support kernel updates (marked by the deviceinfo variable "deviceinfo_flash_kernel_on_update") lets flash the kernel and initramfs automatically! --- main/postmarketos-mkinitfs/APKBUILD | 6 +++--- main/postmarketos-mkinitfs/mkinitfs.sh | 1 + main/postmarketos-mkinitfs/mkinitfs_functions.sh | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index 1d49311f3..8b7effeef 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,6 +1,6 @@ # Maintainer: Oliver Smith pkgname=postmarketos-mkinitfs -pkgver=0.25 +pkgver=0.26 pkgrel=1 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://postmarketos.org" @@ -55,7 +55,7 @@ sha512sums=" 4717bf24bd13fd4d90f3ab000ab43f7d61529515de224ebc86458ae709ebe0b5065655457e34f5952126bac6ab45143a91cddb09a8ad2d0a55c5cecd564a0135 00-default.modules 1a267dd958609263a4f24657f602ac0e4e0c724bf1284adec85e82d05c9b07553085edea5a56f7fa09d1652af232c72d4d39a06858c2a580ff830577b5f37d67 init.sh.in e72adfb06745ad596a02837c8d52837490a7940f4d5589b8937155ee1be1bc4176d79d3f24c40882d20592d00c23c2daf3ef1ceba6ef05cadb76906084373f1b init_functions.sh -4f74995c52b3fd18ef77347dbbca4b3575d23fd339b62a257c1c4b45a16feb5a95f391d6189f62e94ac00d8da3077d192c678554a5f9b8190e34bf3fa6c86e95 mkinitfs.sh -adf021623cfcb8fba4e71f1a5b373bcce1a8cf5946c51dd801ea7b80daf628f9f9c2bc017db930f4b1a61fefcc471602cb1be31cea52dbbe65526f82c7cdce89 mkinitfs_functions.sh +54c8ea6c4b5313c0ca82bbc40498a35d4b5cbcdbf950dc01b5025238ea6b8caa2f9a9ee57a269fb78673fbcac186c33243188458ecda45deb3354d5d8a77fdfe mkinitfs.sh +0b89d1c43516d1be154fcf51082a89ab9dbff7de5f8dc3964399514584752b2356d34958923e66250af4639eb98b94f51ac9046c2d69c608fcf12794f78c2cca mkinitfs_functions.sh c7a3c33daeb12b33ac72207191941c4d634f15c22958273b52af381a70ebaba1d3a9299483f0c447d9e66c560151fe7b9588bb4bbef2c8914f83185984ee4622 mkinitfs_test.sh " diff --git a/main/postmarketos-mkinitfs/mkinitfs.sh b/main/postmarketos-mkinitfs/mkinitfs.sh index d66e71d11..8eb7c2c2c 100644 --- a/main/postmarketos-mkinitfs/mkinitfs.sh +++ b/main/postmarketos-mkinitfs/mkinitfs.sh @@ -34,6 +34,7 @@ append_or_copy_dtb add_mtk_header create_uboot_files create_bootimg +flash_updated_boot_parts rm -rf "$tmpdir" diff --git a/main/postmarketos-mkinitfs/mkinitfs_functions.sh b/main/postmarketos-mkinitfs/mkinitfs_functions.sh index ad0cc4d07..46192d08b 100644 --- a/main/postmarketos-mkinitfs/mkinitfs_functions.sh +++ b/main/postmarketos-mkinitfs/mkinitfs_functions.sh @@ -24,6 +24,7 @@ deviceinfo_initfs_compression="" deviceinfo_kernel_cmdline="" deviceinfo_legacy_uboot_load_address="" deviceinfo_modules_initfs="" +deviceinfo_flash_kernel_on_update="" # Overwritten by mkinitfs.sh tmpdir="" @@ -431,6 +432,21 @@ create_bootimg() fi } +flash_updated_boot_parts() +{ + [ "${deviceinfo_flash_kernel_on_update}" = "true" ] || return + # If postmarketos-update-kernel is not installed then nop + [ -f /sbin/pmos-update-kernel ] || return + if [ -f "/in-pmbootstrap" ]; then + echo "==> Not flashing boot in chroot" + return + fi + + echo "==> Flashing boot image" + flavor=$(uname -r | sed "s/^[^-]*-//") + pmos-update-kernel "$flavor" +} + # Append the correct device tree to the linux image file or copy the dtb to the boot partition append_or_copy_dtb() {