From 429710af8f098d5545d6b08b352a06b058308f2d Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Fri, 9 Mar 2018 20:10:38 +0100 Subject: [PATCH] patcher: initial A/B partition scheme support --- ChangeLog.md | 4 ++ .../META-INF/com/google/android/update-binary | 40 ++++++++++++++----- patcher/dexpatcher/75-nanodroidpatcher.sh | 39 +++++++++++++----- 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 910c1e1..05d56b4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,10 @@ ## 16.3 in-dev +* Full, microG, F-Droid packages + * improved A/B partition scheme support +* Patcher + * initial A/B parition scheme support * Updates (automatic) * AnySoftKeyboard (1.9.1117) * Déjà Vu nlpBackend (1.1.3) diff --git a/patcher/META-INF/com/google/android/update-binary b/patcher/META-INF/com/google/android/update-binary index 33ed8fd..4eb29d4 100644 --- a/patcher/META-INF/com/google/android/update-binary +++ b/patcher/META-INF/com/google/android/update-binary @@ -81,6 +81,34 @@ mount_image() { fi } +# taken from Magisk, with minor modifications for NanoDroid +mount_partitions () { + SLOT=$(getprop ro.boot.slot_suffix) + if [ -z ${SLOT} ]; then + SLOT=$(getprop ro.boot.slot) + [ "${SLOT}" = "_" ] && SLOT= + fi + + is_mounted /data || mount /data 2>/dev/null + + ${BOOTMODE} || mount -o bind /dev/urandom /dev/random + + [ ! -f /system/build.prop ] && mount -o ro /system 2>/dev/null + + if [ ! -f /system/build.prop ]; then + SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1) + mount -t ext4 -o ro $SYSTEMBLOCK /system + fi + + if [ -f /system/init.rc ]; then + mkdir /system_root 2>/dev/null + mount --move /system /system_root + mount -o bind /system_root/system /system + fi + + [ ! -f /system/build.prop ] && error "failed to mount /system" +} + error () { ui_print "${@}" magisk_cleanup @@ -454,11 +482,7 @@ nanodroid_sigspoofui=0 get_config .nanodroid-setup [ "$config_exists" -eq 1 ] && source ${config} -if ! (is_mounted /data); then - mount -orw /data || error " !! failed to mount /data" -else mount -orw,remount /data || \ - error " !! failed to remount /data read-write" -fi +mount_partition if [ -f /data/adb/.nanodroid-patcher ]; then ui_print " !! /data/adb/.nanodroid-patcher exists" @@ -466,12 +490,6 @@ if [ -f /data/adb/.nanodroid-patcher ]; then error " !! remove this file and try again" fi -if ! (is_mounted /system); then - mount -orw /system || error " !! failed to mount /system" -else mount -orw,remount /system || \ - error " !! failed to remount /system read-write" -fi - setup_patcher detect_sdk diff --git a/patcher/dexpatcher/75-nanodroidpatcher.sh b/patcher/dexpatcher/75-nanodroidpatcher.sh index d761271..374e6fc 100644 --- a/patcher/dexpatcher/75-nanodroidpatcher.sh +++ b/patcher/dexpatcher/75-nanodroidpatcher.sh @@ -68,6 +68,34 @@ mount_image() { fi } +# taken from Magisk, with minor modifications for NanoDroid +mount_partitions () { + SLOT=$(getprop ro.boot.slot_suffix) + if [ -z ${SLOT} ]; then + SLOT=$(getprop ro.boot.slot) + [ "${SLOT}" = "_" ] && SLOT= + fi + + is_mounted /data || mount /data 2>/dev/null + + ${BOOTMODE} || mount -o bind /dev/urandom /dev/random + + [ ! -f /system/build.prop ] && mount -o ro /system 2>/dev/null + + if [ ! -f /system/build.prop ]; then + SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1) + mount -t ext4 -o ro $SYSTEMBLOCK /system + fi + + if [ -f /system/init.rc ]; then + mkdir /system_root 2>/dev/null + mount --move /system /system_root + mount -o bind /system_root/system /system + fi + + [ ! -f /system/build.prop ] && error "failed to mount /system" +} + error () { ui_print "${@}" magisk_cleanup @@ -389,18 +417,11 @@ main () { ui_print "*******************************" ui_print " " + mount_partitions + [ -f /data/adb/.nanodroid-patcher ] && \ rm -f /data/adb/.nanodroid-patcher - if ! (is_mounted /data); then - mount -orw /data || error " !! failed to mount /data" - else mount -orw,remount /data || error " !! failed to remount /data read-write" - fi - - if ! (is_mounted /system); then - mount -oro /system || error " !! failed to mount /system" - fi - get_config .nanodroid-setup [ "$config_exists" -eq 1 ] && source ${config}