Skip to content

Commit

Permalink
AK3: use lptools resize for vendor_dlkm (#73)
Browse files Browse the repository at this point in the history
- default to replace and fallback to resize when not enough space in super
  • Loading branch information
capntrips committed Aug 2, 2022
1 parent 330de65 commit 97794de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion META-INF/com/google/android/updater-script
Expand Up @@ -3,4 +3,4 @@
# Dummy file; update-binary is a shell script (DO NOT CHANGE)
#
#
# AK_BASE_VERSION=20220727
# AK_BASE_VERSION=20220802
37 changes: 25 additions & 12 deletions tools/ak3-core.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Binary file modified tools/httools_static
Binary file not shown.

0 comments on commit 97794de

Please sign in to comment.