From 049180b3cd4e467beb180f28ef14b473f1994e0a Mon Sep 17 00:00:00 2001 From: osm0sis Date: Sat, 16 Oct 2021 14:38:57 -0300 Subject: [PATCH] Backend: update apex support - support unmounting TWRP's mounted apex files to avoid conflicts - hide less apex u/mount stderr to aid future debugging --- META-INF/com/google/android/update-binary | 15 ++++++--------- META-INF/com/google/android/updater-script | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 31ffcc9..7a1afb7 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -69,8 +69,8 @@ mount_apex() { if [ $? != 0 ]; then while [ $num -lt 64 ]; do loop=/dev/block/loop$num; - ($BB mknod $loop b 7 $((num * minorx)); - $BB losetup $loop $dest.img) 2>/dev/null; + [ -e $loop ] || $BB mknod $loop b 7 $((num * minorx)); + $BB losetup $loop $dest.img 2>/dev/null; num=$((num + 1)); $BB losetup $loop | $BB grep -q $dest.img && break; done; @@ -89,9 +89,8 @@ mount_apex() { $($BB grep -o 'export .* /.*' /system_root/init.environ.rc | $BB sed 's; /;=/;'); unset export; } umount_apex() { - [ -d /apex/com.android.runtime ] || return 1; local dest loop var; - for var in $($BB grep -o 'export .* /.*' /system_root/init.environ.rc | $BB awk '{ print $2 }'); do + for var in $($BB grep -o 'export .* /.*' /system_root/init.environ.rc 2>/dev/null | $BB awk '{ print $2 }'); do if [ "$(eval echo \$OLD_$var)" ]; then eval $var=\$OLD_${var}; else @@ -100,11 +99,9 @@ umount_apex() { unset OLD_${var}; done; for dest in $($BB find /apex -type d -mindepth 1 -maxdepth 1); do - if [ -f $dest.img ]; then - loop=$($BB mount | $BB grep $dest | $BB cut -d\ -f1); - fi; - ($BB umount -l $dest; - $BB losetup -d $loop) 2>/dev/null; + loop=$($BB mount | $BB grep $dest | $BB grep loop | $BB cut -d\ -f1); + $BB umount -l $dest; + [ "$loop" ] && $BB losetup -d $loop; done; $BB rm -rf /apex 2>/dev/null; } diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script index 5270bfd..c984734 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=20211004 +# AK_BASE_VERSION=20211016