AK3: use lptools resize for vendor_dlkm (#73)

- default to replace and fallback to resize when not enough space in super
This commit is contained in:
Captain Trips authored and GitHub committed 2022-08-02 17:31:51 -03:00
1 parent 330de65c77
commit 97794de0a2
3 files changed
+26 -13

No files matched your search

+1 -1
View File
@@ -3,4 +3,4 @@
# Dummy file; update-binary is a shell script (DO NOT CHANGE)
#
#
# AK_BASE_VERSION=20220727
# AK_BASE_VERSION=20220802
+25 -12
View File
@@ -415,7 +415,7 @@ flash_boot() {
# flash_generic <name>
flash_generic() {
local avb avbblock file flags img imgblock isro path;
local avb avbblock avbpath file flags img imgblock isro isunmounted path;
cd $home;
for file in $1 $1.img; do
@@ -444,27 +444,37 @@ flash_generic() {
flags=$($bin/httools_static disable-flags);
[ $? == 0 ] || abort "Failed to parse top-level vbmeta. Aborting...";
if [ "$flags" == "enabled" ]; then
[ "$1" == "vendor_dlkm" -a "$avb" == "vbmeta" ] || abort "Unable to patch $1 on $avb. Aborting ...";
ui_print " " "dm-verity detected! Patching vbmeta...";
for path in /dev/block/bootdevice/by-name /dev/block/mapper; do
ui_print " " "dm-verity detected! Patching $avb...";
for avbpath in /dev/block/bootdevice/by-name /dev/block/mapper; do
for file in $avb $avb$slot; do
if [ -e $path/$file ]; then
avbblock=$path/$file;
if [ -e $avbpath/$file ]; then
avbblock=$avbpath/$file;
break 2;
fi;
done;
done;
cd $bin;
$bin/httools_static patch $home/$img $avbblock || abort "Failed to patch $1 on $avb. Aborting...";
$bin/httools_static patch $1 $home/$img $avbblock || abort "Failed to patch $1 on $avb. Aborting...";
cd $home;
fi
fi
$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;
if $bin/lptools_static create $1_ak3 $(wc -c < $img); then
$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;
else
ui_print "Creating $1_ak3 failed. Attempting to resize $1$slot...";
$bin/httools_static umount $1 || abort "Unmounting $1 failed. Aborting...";
if [ -e $path/$1-verity ]; then
$bin/lptools_static unmap $1-verity || abort "Unmapping $1-verity failed. Aborting...";
fi
$bin/lptools_static unmap $1$slot || abort "Unmapping $1$slot failed. Aborting...";
$bin/lptools_static resize $1$slot $(wc -c < $img) || abort "Resizing $1$slot failed. Aborting...";
$bin/lptools_static map $1$slot || abort "Mapping $1$slot failed. Aborting...";
isunmounted=1;
fi
elif [ "$(wc -c < $img)" -gt "$(wc -c < $imgblock)" ]; then
abort "New $1 image larger than $1 partition. Aborting...";
fi;
@@ -488,6 +498,9 @@ flash_generic() {
if [ "$isro" != 0 ]; then
blockdev --setro $imgblock 2>/dev/null;
fi;
if [ "$isunmounted" -a "$path" == "/dev/block/mapper" ]; then
$bin/httools_static mount $1 || abort "Mounting $1 failed. Aborting...";
fi
touch ${1}_flashed;
fi;
}
Binary file not shown.