From 32073dff09cb76f4d0a199045cf588a39caf089c Mon Sep 17 00:00:00 2001 From: Chris Renshaw Date: Thu, 10 Aug 2023 13:11:32 -0300 Subject: [PATCH] AK3: add per-partition attributes, multi-partition fixes - attributes function now runs via core in setup_ak and reset_ak, but only if it exists, allowing more easy removal of it for setups with no ramdisk changes (so all should now remove the awkward `&& attributes` call from anykernel3.sh, see next commit) - for multi-partition zips with multiple ramdisks requiring different files, multiple attributes functions may now be specified, either redefine attributes() in anykernel.sh for the next partition, or add a different function for each partition, e.g. boot_attributes() and vendor_boot_attributes() - fix block=auto multi-partition setup creating an "auto-files" directory instead of final found block, e.g. "init_boot-files" --- META-INF/com/google/android/updater-script | 2 +- tools/ak3-core.sh | 27 +++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script index 1ff15ed..ffb6603 100644 --- a/META-INF/com/google/android/updater-script +++ b/META-INF/com/google/android/updater-script @@ -3,4 +3,4 @@ # Dummy file; update-binary is a shell script (DO NOT CHANGE) # # -# AK_BASE_VERSION=20230801 +# AK_BASE_VERSION=20230810 diff --git a/tools/ak3-core.sh b/tools/ak3-core.sh index 3253e36..3b47744 100755 --- a/tools/ak3-core.sh +++ b/tools/ak3-core.sh @@ -848,17 +848,6 @@ setup_ak() { touch vendor_v3_setup; fi; - # allow multi-partition ramdisk modifying configurations (using reset_ak) - if [ "$block" ] && [ ! -d "$ramdisk" -a ! -d "$patch" ]; then - blockfiles=$home/$(basename $block)-files; - if [ "$(ls $blockfiles 2>/dev/null)" ]; then - cp -af $blockfiles/* $home; - else - mkdir $blockfiles; - fi; - touch $blockfiles/current; - fi; - # target block partition detection enabled by block= or auto (from anykernel.sh) case $block in /dev/*) @@ -915,6 +904,22 @@ setup_ak() { if [ ! "$no_block_display" ]; then ui_print "$block"; fi; + + # allow multi-partition ramdisk modifying configurations (using reset_ak) + name=$(basename $block | sed -e 's/_a$//' -e 's/_b$//'); + if [ "$block" ] && [ ! -d "$ramdisk" -a ! -d "$patch" ]; then + blockfiles=$home/$name-files; + if [ "$(ls $blockfiles 2>/dev/null)" ]; then + cp -af $blockfiles/* $home; + else + mkdir $blockfiles; + fi; + touch $blockfiles/current; + fi; + + # run attributes function for current block if it exists + type attributes >/dev/null 2>&1 && attributes; # backwards compatibility + type ${name}_attributes >/dev/null 2>&1 && ${name}_attributes; } ###