From 12914fac70deb2a22d8bb86e092a002a993ab3b3 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Sat, 17 Mar 2018 05:54:56 -0500 Subject: [PATCH 1/4] update-binary: Add support for system-as-root devices for the zip * We'll first check the currently loaded slot. We can assume the user just flashed a rom and that the target slot for this rom is the other slot, so mount that system image. TODO: autodetect this somehow * Mount this system partition at /system_root (rw) and then mount the /system/system folder at /system. We do it this way for a couple reasons. Because it makes the script easier to work with and because we're using toybox from the system partition for operations, which is expecting /system/bin/linker64 to exist. Change-Id: Ia6f96f0864d725b0123665bbbce0e31523bb834f --- build/meta/com/google/android/update-binary | 58 +++++++++++++-------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/build/meta/com/google/android/update-binary b/build/meta/com/google/android/update-binary index 0fc5a88..8e2ce68 100644 --- a/build/meta/com/google/android/update-binary +++ b/build/meta/com/google/android/update-binary @@ -29,38 +29,50 @@ ui_print "**********************" ui_print "MindTheGapps installer" ui_print "**********************" -ABDEVICE=`getprop ro.build.system_root_image` +SYSTEMASROOT=`getprop ro.build.system_root_image` ui_print "Mounting system partition" -if [ "$ABDEVICE" == "true" ]; then - SYSTEM="/system/system" - # TODO: Actually handle A/B ota devices - ui_print "A/B OTA device detected! This is unsupported. Aborting" - exit 1 -else - SYSTEM="/system" - if mount $SYSTEM; then - ui_print "$SYSTEM mounted" +if [ "$SYSTEMASROOT" == "true" ]; then + CURRENTSLOT=`getprop ro.boot.slot_suffix` + if [ ! -z "$CURRENTSLOT" ]; then + if [ "$CURRENTSLOT" == "_a" ]; then + TARGETSYSTEM=/dev/block/bootdevice/by-name/system_b + else + TARGETSYSTEM=/dev/block/bootdevice/by-name/system_a + fi else - ui_print "Could not mount $SYSTEM! Aborting" - exit 1 + TARGETSYSTEM=/dev/block/bootdevice/by-name/system + fi + mkdir -p /system_root + if mount -o rw $TARGETSYSTEM /system_root && mount /system_root/system /system; then + ui_print "/system mounted" + else + ui_print "Could not mount /system! Aborting" + exit 1 + fi +else + if mount /system; then + ui_print "/system mounted" + else + ui_print "Could not mount /system! Aborting" + exit 1 fi fi -if [ -f $SYSTEM/bin/toybox ]; then - UTILS=$SYSTEM/bin/toybox - LD_PATH=$SYSTEM/lib +if [ -f /system/bin/toybox ]; then + UTILS=/system/bin/toybox + LD_PATH=/system/lib else - ui_print "Could not find $SYSTEM/bin/toybox! Aborting" + ui_print "Could not find /system/bin/toybox! Aborting" exit 1 fi DIRS="addon.d app priv-app framework etc lib" -if [ -d $SYSTEM/lib64 ]; then +if [ -d /system/lib64 ]; then DIRS="$DIRS lib64" - LD_PATH=$SYSTEM/lib64 + LD_PATH=/system/lib64 fi LOWMEM=1572864 @@ -103,14 +115,18 @@ for dirs in $DIRS; do done done ui_print "Copying files" -exec_util "cp --preserve=a -r ./* $SYSTEM/" -exec_util "rm -rf $SYSTEM/priv-app/Provision/" +exec_util "cp --preserve=a -r ./* /system/" +exec_util "rm -rf /system/priv-app/Provision/" ui_print "Cleaning up files" cd ../ exec_util "rm -rf system/" ui_print "Unmounting system partition" -umount $SYSTEM +if umount /system; then + if [ "$SYSTEMASROOT" == "true" ]; then + umount /system_root + fi +fi ui_print "Done!" exit 0 From 6a9b00f22b1a5cd94eca26c8e4b6f8a3ebfb3071 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Sat, 17 Mar 2018 06:13:40 -0500 Subject: [PATCH 2/4] update-binary: lazy unmount /system and /system_root * Unsure why these don't want to unmount normally Change-Id: I732d6f0309e668f64b31561362e93fd09707bafd --- build/meta/com/google/android/update-binary | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/meta/com/google/android/update-binary b/build/meta/com/google/android/update-binary index 8e2ce68..0739eb3 100644 --- a/build/meta/com/google/android/update-binary +++ b/build/meta/com/google/android/update-binary @@ -122,9 +122,9 @@ cd ../ exec_util "rm -rf system/" ui_print "Unmounting system partition" -if umount /system; then +if umount -l /system; then if [ "$SYSTEMASROOT" == "true" ]; then - umount /system_root + umount -l /system_root fi fi From 9aeb1c1bbdac1469f89c519395f1b6d02813684b Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Sat, 17 Mar 2018 06:34:04 -0500 Subject: [PATCH 3/4] update-binary: clean up addon.d_[head,tail] Change-Id: Iafcfe56d004f3395e194a56b8914febff0948935 --- build/meta/com/google/android/update-binary | 1 + 1 file changed, 1 insertion(+) diff --git a/build/meta/com/google/android/update-binary b/build/meta/com/google/android/update-binary index 0739eb3..042c90a 100644 --- a/build/meta/com/google/android/update-binary +++ b/build/meta/com/google/android/update-binary @@ -96,6 +96,7 @@ for f in `exec_util "find . -type f"`; do echo "$line" >> addon.d/30-gapps.sh done cat addon.d/addond_tail >> addon.d/30-gapps.sh +rm addon.d/addond_head addon.d/addond_tail ui_print "Preparing files for copying" for dirs in $DIRS; do set_perm 0755 $dir From 74859c6634b8d8df7bc674847513a9686e0e67e7 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Sat, 17 Mar 2018 06:44:54 -0500 Subject: [PATCH 4/4] addon.d: support version 2 Change-Id: Ie9fb81b096de81d80e6a8489a439b9aed668d69a --- addond_head | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addond_head b/addond_head index dcd5e93..11b364e 100644 --- a/addond_head +++ b/addond_head @@ -1,5 +1,7 @@ #!/sbin/sh # +# ADDOND_VERSION=2 +# # /system/addon.d/30-gapps.sh # . /tmp/backuptool.functions