diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary new file mode 100644 index 0000000..5b3a097 --- /dev/null +++ b/META-INF/com/google/android/update-binary @@ -0,0 +1,115 @@ +#!/sbin/sh + +export ZIPFILE="$3" +export OUTFD="/proc/self/fd/$2" +export TMP="/tmp" + +bb="$TMP/busybox-arm" +l="$TMP/bin" + +ui_print() { + echo "ui_print $1" > "$OUTFD"; + echo "ui_print" > "$OUTFD"; +} + +unzip -o "$ZIPFILE" "install.sh" -d "$TMP"; +unzip -o "$ZIPFILE" "magiskboot" -d "$TMP"; +unzip -o "$ZIPFILE" "libapjni.so" -d "$TMP"; +unzip -o "$ZIPFILE" "kpimg-android" -d "$TMP"; +unzip -o "$ZIPFILE" "kptools-android" -d "$TMP"; +unzip -o "$ZIPFILE" "superkey-here.txt" -d "$TMP"; + +cd "$TMP" + +# getprop +GETPROP=$(which getprop) +if [ -z "$GETPROP" ]; then + GETPROP=/system/bin/getprop + [ ! -e "$GETPROP" ] && GETPROP=/sbin/getprop + [ ! -e "$GETPROP" ] && GETPROP=$(which resetprop) +fi + +ARCH=$(uname -m) + +if [ "$ARCH" = "aarch64" ]; then + ui_print "ARCH is arm64..." +else + ui_print "Not is arm64, aborting..." + exit 1 +fi + +is_ab_device() { +local S="$($GETPROP "ro.boot.slot_suffix")" +local U="$($GETPROP "ro.build.ab_update")" + if [ -n "$S" -a "$U" = "true" ]; then + echo "1" + else + echo "0" + fi +} + +if [ "$(is_ab_device)" = "1" ]; then + slot_suffix=$($GETPROP ro.boot.slot_suffix) + dd if="/dev/block/by-name/boot$slot_suffix" of="$TMP/boot.img" +else + dd if=/dev/block/by-name/boot of="$TMP/boot.img" +fi + +if [ -f "$TMP/boot.img" ]; then + ui_print "get boot success" +else + ui_print "get boot failed" + exit 1 +fi + +cp "$TMP/boot.img" /sdcard/ + +ui_print "backup boot.img in sdcard" + +ui_print "unpacking.." + +./magiskboot unpack "$TMP/boot.img" || exit $? + +mv "$TMP/kernel" "$TMP/kernel.ori" + +SUPERKEY="$(cat "$TMP/superkey-here.txt")" + +if [ -z "$SUPERKEY" ]; then + ui_print "Superkey must not be empty." + exit 1 +fi + +ui_print "Your superkey is: $SUPERKEY" + +ui_print "Patching kernel" +./kptools-android -p "$TMP/kernel.ori" --skey "$SUPERKEY" --kpimg "$TMP/kpimg-android" --out "$TMP/kernel" + +if [ -f "$TMP/kernel" ]; then + ui_print "patch kernel success" +else + ui_print "patch kernel failed" + exit 1 +fi + +ui_print "Repacking boot image" +./magiskboot repack "$TMP/boot.img" + +if [ -f "$TMP/new-boot.img" ]; then + ui_print "repack boot success" +else + ui_print "repack boot failed" + exit 1 +fi + +ui_print "flashing..." + +if [ "$(is_ab_device)" = "1" ]; then + slot_suffix=$($GETPROP ro.boot.slot_suffix) + blockdev --setrw "/dev/block/by-name/boot$slot_suffix" + dd if=new-boot.img of="/dev/block/by-name/boot$slot_suffix" +else + blockdev --setrw /dev/block/by-name/boot + dd if=new-boot.img of=/dev/block/by-name/boot +fi + +ui_print "flash done" \ No newline at end of file diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script new file mode 100644 index 0000000..8582673 --- /dev/null +++ b/META-INF/com/google/android/updater-script @@ -0,0 +1 @@ +# Dummy file; update-binary is a shell script. diff --git a/README.md b/README.md index 3c5b0c1..3a8e764 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # kpatch-zip-flashable KernelPatch flashable zip in recovery + + +PUT YOUR SUPERKEY IN FILE "superkey-here.txt" AND JUST FLASH IN RECOVERY \ No newline at end of file diff --git a/kpimg-android b/kpimg-android new file mode 100644 index 0000000..c717e17 Binary files /dev/null and b/kpimg-android differ diff --git a/kptools-android b/kptools-android new file mode 100644 index 0000000..d0022c1 Binary files /dev/null and b/kptools-android differ diff --git a/libapjni.so b/libapjni.so new file mode 100644 index 0000000..5b1660c Binary files /dev/null and b/libapjni.so differ diff --git a/magiskboot b/magiskboot new file mode 100644 index 0000000..1b5d339 Binary files /dev/null and b/magiskboot differ diff --git a/superkey-here.txt b/superkey-here.txt new file mode 100644 index 0000000..e69de29