on-pc framework-patcher: A/B partition scheme support

merge-requests/23/head
Christopher Roy Bratusek 6 years ago
parent 66149bc5b7
commit 7e6f7c6c12

@ -82,10 +82,17 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
alias cp=gcp
fi
adb shell "umount /system"
adb shell "mount -orw /system" || error "Failed to mount /system read-write"
adb push "${CWD}/framework-patcher-remote" /tmp/ || \
error "Failed to push helper script to device"
adb shell "chmod 0755 /tmp/framework-patcher-remote" || \
error "Failed to set permissions for helper script"
adb shell "/tmp/framework-patcher-remote --mount" || \
error "Failed to install /system"
rm -rf "${CWD}/haystack/mydevice*"
"${CWD}/haystack/pull-fileset" mydevice || error "Failed to pull files from device!"
"${CWD}/haystack/patch-fileset" "${CWD}/haystack/patches/${PATCH_HOOK}" \
@ -100,13 +107,7 @@ rm -rf "${CWD}/haystack/mydevice*"
adb push "${CWD}/haystack/mydevice__${PATCH_HOOK}__${PATCH_CORE}/services.jar" \
/tmp/services.jar || error "Failed to push services.jar to device"
adb push "${CWD}/framework-patcher-remote" /tmp/ || \
error "Failed to push helper script to device"
adb shell "chmod 0755 /tmp/framework-patcher-remote" || \
error "Failed to set permissions for helper script"
adb shell "/tmp/framework-patcher-remote" || \
adb shell "/tmp/framework-patcher-remote --patch" || \
error "Failed to install services.jar"
echo -e "\nNow reboot device and enjoy microG!"

@ -76,57 +76,98 @@ umount_magisk () {
rm /tmp/loopdevice
}
# taken from Magisk, with minor modifications for NanoDroid
mount_partitions () {
SLOT=$(grep_cmdline androidboot.slot_suffix)
if [ -z ${SLOT} ]; then
SLOT=_$(grep_cmdline androidboot.slot)
[ "${SLOT}" = "_" ] && SLOT=
fi
is_mounted /data || mount /data
${BOOTMODE} || mount -o bind /dev/urandom /dev/random
! is_mounted /system && mount -o rw /system
if [ ! -f /system/build.prop ]; then
SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1)
mount -t ext4 -o rw ${SYSTEMBLOCK} /system
fi
[ -f /system/build.prop ] || is_mounted /system || error "failed to mount /system (unsupported A/B device?)"
if [ -f /system/init ]; 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 (unsupported A/B device?)"
}
patch_system () {
if [[ -f /data/adb/magisk.img ]]; then
MAGISK_IMG=/data/adb/magisk.img
elif [[ -f /data/magisk.img ]]; then
MAGISK_IMG=/data/magisk.img
fi
if [[ -f ${MAGISK_IMG} ]]; then
grow_magisk_img
echo "magisk found: mount to /magisk"
mount_magisk
fi
if [[ -f /data/adb/.nanodroid-patcher ]]; then
echo " ++ /system/.nanodroid-patcher exists"
echo " ++ assuming ROM is already patched"
exit 0
fi
install_path=""
if [[ -d /magisk/NanoDroid ]]; then
echo "NanoDroid detected"
install_path="/magisk/NanoDroid/system"
mkdir -p "${install_path}"
elif [[ -d /magisk/NanoDroid_microG ]]; then
echo "NanoDroid microG detected"
install_path="/magisk/NanoDroid_microG/system"
mkdir -p "${install_path}"
else
echo "backing up services.jar to /sdcard/nanodroid_backups"
mkdir -p /sdcard/nanodroid_backups
cp /tmp/services.jar /sdcard/nanodroid_backups
echo "using ROM as destination"
install_path="/system"
echo /system/framework/services.jar >> \
/system/.nanodroid-list
fi
echo "install to \"${install_path}\""
cp /tmp/services.jar "${install_path}/framework" || exit 1
touch /data/adb/.nanodroid-patcher
if (is_mounted /magisk); then
echo "unmount /magisk"
umount_magisk
shrink_magisk_img
fi
echo "unmount /system"
umount /system
}
case ${1} in
*mount )
mount_partitions || exit 1
;;
if [[ -f /data/adb/magisk.img ]]; then
MAGISK_IMG=/data/adb/magisk.img
elif [[ -f /data/magisk.img ]]; then
MAGISK_IMG=/data/magisk.img
fi
if [[ -f ${MAGISK_IMG} ]]; then
grow_magisk_img
echo "magisk found: mount to /magisk"
mount_magisk
fi
if [[ -f /data/adb/.nanodroid-patcher ]]; then
echo " ++ /system/.nanodroid-patcher exists"
echo " ++ assuming ROM is already patched"
exit 0
fi
install_path=""
if [[ -d /magisk/NanoDroid ]]; then
echo "NanoDroid detected"
install_path="/magisk/NanoDroid/system"
mkdir -p "${install_path}"
elif [[ -d /magisk/NanoDroid_microG ]]; then
echo "NanoDroid microG detected"
install_path="/magisk/NanoDroid_microG/system"
mkdir -p "${install_path}"
else
echo "backing up services.jar to /sdcard/nanodroid_backups"
mkdir -p /sdcard/nanodroid_backups
cp /tmp/services.jar /sdcard/nanodroid_backups
echo "using ROM as destination"
install_path="/system"
echo /system/framework/services.jar >> \
/system/.nanodroid-list
fi
echo "install to \"${install_path}\""
cp /tmp/services.jar "${install_path}/framework" || exit 1
touch /data/adb/.nanodroid-patcher
if (is_mounted /magisk); then
echo "unmount /magisk"
umount_magisk
shrink_magisk_img
fi
echo "unmount /system"
umount /system
*patch )
patch_system || exit 1
;;
esac

Loading…
Cancel
Save