From ebd2b04b2c0eb3a50aecfed6413a8fe8c7230789 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Wed, 29 Jan 2020 14:24:41 -0400 Subject: Backend: work around some Lineage 17 (AOSP Q) Recovery issues - Lineage 17 Recovery has some problems currently: /system mountpoint in ramdisk, neither /system nor /system_root in fstab (it has / instead, which is useless), ANDROID_ROOT=/system, and no /system_root symlink - /etc is linked to /system/etc so once /system is mounted /etc/fstab is gone and no further simple mount commands will work so move other mounts before /system - /system/bin are the only utilities available on PATH with none at all in /sbin so we need /apex files mounted immediately or no non-busybox commands will work after mounting /system over the recovery's skeleton /system - not all devices have /dev/block/bootdevice symlinks, but at some point "broken recovery is broken" has to apply, so I don't intend to build out full system partition discovery for the SAR mount fallback --- META-INF/com/google/android/update-binary | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 252ff0a..01a62af 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -39,12 +39,12 @@ mount_apex() { test -d /system/apex || return 1; local apex dest loop minorx num; setup_mountpoint /apex; - test -e /dev/block/loop1 && minorx=$(ls -l /dev/block/loop1 | $BB awk '{ print $6 }') || minorx=1; + test -e /dev/block/loop1 && minorx=$($BB ls -l /dev/block/loop1 | $BB awk '{ print $6 }') || minorx=1; num=0; for apex in /system/apex/*; do - dest=/apex/$(basename $apex .apex); + dest=/apex/$($BB basename $apex .apex); test "$dest" == /apex/com.android.runtime.release && dest=/apex/com.android.runtime; - mkdir -p $dest; + $BB mkdir -p $dest; case $apex in *.apex) $BB unzip -qo $apex apex_payload.img -d /apex; @@ -81,10 +81,15 @@ umount_apex() { ($BB umount -l $dest; $BB losetup -d $loop) 2>/dev/null; done; - rm -rf /apex; + $BB rm -rf /apex 2>/dev/null; unset ANDROID_RUNTIME_ROOT ANDROID_TZDATA_ROOT BOOTCLASSPATH; } mount_all() { + if ! is_mounted /data; then + $BB mount /data; + UMOUNT_DATA=1; + fi; + $BB mount -o ro -t auto /vendor 2>/dev/null; setup_mountpoint $ANDROID_ROOT; if ! is_mounted $ANDROID_ROOT; then $BB mount -o ro -t auto $ANDROID_ROOT 2>/dev/null; @@ -102,19 +107,15 @@ mount_all() { if [ $? != 0 ]; then $BB umount /system; $BB umount -l /system 2>/dev/null; - $BB mount -o ro -t auto /dev/block/bootdevice/by-name/system$(getprop ro.boot.slot_suffix 2>/dev/null) /system_root; + test -e /dev/block/bootdevice/by-name/system || local slot=$(getprop ro.boot.slot_suffix 2>/dev/null); + $BB mount -o ro -t auto /dev/block/bootdevice/by-name/system$slot /system_root; fi; ;; esac; if is_mounted /system_root; then $BB mount -o bind /system_root/system /system; fi; - $BB mount -o ro -t auto /vendor 2>/dev/null; $BOOTMODE || mount_apex; - if ! is_mounted /data; then - $BB mount /data; - UMOUNT_DATA=1; - fi; } umount_all() { (if ! $BOOTMODE; then @@ -137,10 +138,9 @@ setup_env() { $BOOTMODE || $BB mount -o bind /dev/urandom /dev/random; umount_all; mount_all; - OLDLDPATH="$LD_LIBRARY_PATH"; - OLDLDPRE="$LD_PRELOAD"; - unset LD_LIBRARY_PATH; - unset LD_PRELOAD; + OLD_LD_PATH=$LD_LIBRARY_PATH; + OLD_LD_PRE=$LD_PRELOAD; + unset LD_LIBRARY_PATH LD_PRELOAD; if [ ! "$(getprop 2>/dev/null)" ]; then getprop() { local propdir propfile propval; @@ -160,8 +160,8 @@ setup_env() { restore_env() { local dir; unset -f getprop; - test "$OLDLDPATH" && export LD_LIBRARY_PATH="$OLDLDPATH"; - test "$OLDLDPRE" && export LD_PRELOAD="$OLDLDPRE"; + test "$OLD_LD_PATH" && export LD_LIBRARY_PATH=$OLD_LD_PATH; + test "$OLD_LD_PRE" && export LD_PRELOAD=$OLD_LD_PRE; umount_all; (for dir in /apex /system /system_root; do if [ -L "${dir}_link" ]; then -- cgit v1.2.3