AK3: add support for resizing logical partitions (#69)

- add flash_generic support for flashing to dynamic/logical partitions larger than stock using phhusson's lptools binary
- enable full automated support for flashing custom vendor_dlkm.img (note: must NOT be sparse format; factory images are sparse, but images generated from source are not)

Co-authored-by: Chris Renshaw <osm0sis@outlook.com>
This commit is contained in:
Captain TripsandChris Renshaw authored and GitHub committed 2022-04-30 20:01:03 -03:00
1 parent 4ebf8e538c
commit 79cb6945ff
4 files changed
+29 -4

No files matched your search

+9 -3
View File
@@ -437,8 +437,14 @@ flash_generic() {
if [ ! "$imgblock" ]; then
abort "$1 partition could not be found. Aborting...";
fi;
# TODO: add dynamic partition resizing using lptools_static instead of aborting
if [ "$(wc -c < $img)" -gt "$(wc -c < $imgblock)" ]; then
if [ "$path" == "/dev/block/mapper" ]; then
$bin/lptools_static remove $1_ak3;
$bin/lptools_static create $1_ak3 $(wc -c < $img) || abort "Creating $1_ak3 failed. Aborting...";
$bin/lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting...";
$bin/lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting...";
$bin/lptools_static replace $1_ak3 $1$slot || abort "Replacing $1$slot failed. Aborting...";
imgblock=/dev/block/mapper/$1_ak3;
elif [ "$(wc -c < $img)" -gt "$(wc -c < $imgblock)" ]; then
abort "New $1 image larger than $1 partition. Aborting...";
fi;
isro=$(blockdev --getro $imgblock 2>/dev/null);
@@ -470,10 +476,10 @@ flash_dtbo() { flash_generic dtbo; }
### write_boot (repack ramdisk then build, sign and write image, vendor_dlkm and dtbo)
write_boot() {
flash_generic vendor_dlkm; # TODO: move below boot once resizing is supported
repack_ramdisk;
flash_boot;
flash_generic vendor_boot; # temporary until hdr v4 can be unpacked/repacked fully by magiskboot
flash_generic vendor_dlkm;
flash_generic dtbo;
}
###