diff --git a/OFOX_flashable/META-INF/com/google/android/update-binary b/OFOX_flashable/META-INF/com/google/android/update-binary new file mode 100644 index 0000000..bc713ec --- /dev/null +++ b/OFOX_flashable/META-INF/com/google/android/update-binary @@ -0,0 +1,91 @@ +#!/sbin/sh +# TWRP A/B Installer Backend +# by osm0sis, Dees_Troy and topjohnwu + +OUTFD=/proc/self/fd/$2; +ZIPFILE="$3"; + +ui_print() { + if $BOOTMODE; then + echo "$1"; + else + echo -e "ui_print $1\nui_print" >> $OUTFD; + fi; +} +abort() { ui_print " "; ui_print "$1"; exit 1; } + +# detect Magisk app/booted flashing +BOOTMODE=false; +ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true; +$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true; + +ui_print "########################################"; +ui_print "# OFOX flashable installer for redwood #"; +ui_print "########################################"; +ui_print " "; + +# /dev/tmp is safe for both booted and recovery installs +tmp=/dev/tmp/twrp-install; +# target partition without the slot suffix +if [ -e /dev/block/bootdevice/by-name/recovery_b ]; then + target=/dev/block/bootdevice/by-name/recovery; +else + target=/dev/block/bootdevice/by-name/boot; +fi; +name=$(basename $target); + +ui_print "Unpacking the installer..."; +rm -rf $tmp; +mkdir -p $tmp; +unzip -o "$ZIPFILE" -d $tmp || abort "Failed to extract zip!"; + +cd $tmp; +recoverycpio=`(ls ramdisk-twrp.cpio || ls ramdisk-recovery.cpio) 2>/dev/null`; +recoveryimg=`(ls twrp*.img || ls TWRP*.img || ls recovery.img) 2>/dev/null`; +[ "$recoverycpio" ] || [ "$recoveryimg" ] || abort "No OFOX ramdisk/image found in zip!"; + +tool=$tmp/magiskboot; +chmod 755 $tool; + +ui_print " "; +for slot in _a _b; do + if [ "$recoverycpio" ]; then + ui_print "Running image patcher on $name$slot..."; + dd bs=1048576 if=$target$slot of=boot.img || abort "Failed to dump image!"; + $tool unpack -h boot.img || abort "Failed to unpack image!"; + + # kernel string want_initramfs -> skip_initramfs (Magisk) + $tool hexpatch kernel 77616E745F696E697472616D6673 736B69705F696E697472616D6673; + # kernel string trip_initramfs -> skip_initramfs (SuperSU) + $tool hexpatch kernel 747269705F696E697472616D6673 736B69705F696E697472616D6673; + + # boot.img header cmdline remove skip_override (flar2 patch) + sed -i "s|$(grep '^cmdline=' header | cut -d= -f2-)|$(grep '^cmdline=' header | cut -d= -f2- | sed -e 's/skip_override//' -e 's/ */ /g' -e 's/[ \t]*$//')|" header; + + cp -f $recoverycpio ramdisk.cpio; + $tool repack boot.img || abort "Failed to repack image!"; + $tool cleanup; + else + ui_print "Flashing image to $name$slot..."; + cp -f $recoveryimg new-boot.img; + fi; + + blockdev --setrw $target$slot; + cat new-boot.img /dev/zero > $target$slot 2>/dev/null || true; + rm -f new-boot.img; +done; + +if [ "$recoverycpio" ]; then + ui_print " "; + ui_print "Image patching complete!"; +fi; + +cd /; +rm -rf /dev/tmp; + +ui_print " "; +ui_print "Done installing OFOX!"; +if [ "$name" != "recovery" ]; then + ui_print " "; + ui_print "*** NOTE: MAGISK ERASED! REFLASH ***"; +fi; diff --git a/OFOX_flashable/META-INF/com/google/android/updater-script b/OFOX_flashable/META-INF/com/google/android/updater-script new file mode 100644 index 0000000..11d5c96 --- /dev/null +++ b/OFOX_flashable/META-INF/com/google/android/updater-script @@ -0,0 +1 @@ +#MAGISK diff --git a/OFOX_flashable/magiskboot b/OFOX_flashable/magiskboot new file mode 100644 index 0000000..724585a Binary files /dev/null and b/OFOX_flashable/magiskboot differ diff --git a/OFOX_flashable/ramdisk-recovery.cpio b/OFOX_flashable/ramdisk-recovery.cpio new file mode 100644 index 0000000..a0416fa Binary files /dev/null and b/OFOX_flashable/ramdisk-recovery.cpio differ diff --git a/TWRP_flashable/META-INF/com/google/android/update-binary b/TWRP_flashable/META-INF/com/google/android/update-binary new file mode 100644 index 0000000..e038fb9 --- /dev/null +++ b/TWRP_flashable/META-INF/com/google/android/update-binary @@ -0,0 +1,91 @@ +#!/sbin/sh +# TWRP A/B Installer Backend +# by osm0sis, Dees_Troy and topjohnwu + +OUTFD=/proc/self/fd/$2; +ZIPFILE="$3"; + +ui_print() { + if $BOOTMODE; then + echo "$1"; + else + echo -e "ui_print $1\nui_print" >> $OUTFD; + fi; +} +abort() { ui_print " "; ui_print "$1"; exit 1; } + +# detect Magisk app/booted flashing +BOOTMODE=false; +ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true; +$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true; + +ui_print "########################################"; +ui_print "# TWRP flashable installer for redwood #"; +ui_print "########################################"; +ui_print " "; + +# /dev/tmp is safe for both booted and recovery installs +tmp=/dev/tmp/twrp-install; +# target partition without the slot suffix +if [ -e /dev/block/bootdevice/by-name/recovery_b ]; then + target=/dev/block/bootdevice/by-name/recovery; +else + target=/dev/block/bootdevice/by-name/boot; +fi; +name=$(basename $target); + +ui_print "Unpacking the installer..."; +rm -rf $tmp; +mkdir -p $tmp; +unzip -o "$ZIPFILE" -d $tmp || abort "Failed to extract zip!"; + +cd $tmp; +recoverycpio=`(ls ramdisk-twrp.cpio || ls ramdisk-recovery.cpio) 2>/dev/null`; +recoveryimg=`(ls twrp*.img || ls TWRP*.img || ls recovery.img) 2>/dev/null`; +[ "$recoverycpio" ] || [ "$recoveryimg" ] || abort "No TWRP ramdisk/image found in zip!"; + +tool=$tmp/magiskboot; +chmod 755 $tool; + +ui_print " "; +for slot in _a _b; do + if [ "$recoverycpio" ]; then + ui_print "Running image patcher on $name$slot..."; + dd bs=1048576 if=$target$slot of=boot.img || abort "Failed to dump image!"; + $tool unpack -h boot.img || abort "Failed to unpack image!"; + + # kernel string want_initramfs -> skip_initramfs (Magisk) + $tool hexpatch kernel 77616E745F696E697472616D6673 736B69705F696E697472616D6673; + # kernel string trip_initramfs -> skip_initramfs (SuperSU) + $tool hexpatch kernel 747269705F696E697472616D6673 736B69705F696E697472616D6673; + + # boot.img header cmdline remove skip_override (flar2 patch) + sed -i "s|$(grep '^cmdline=' header | cut -d= -f2-)|$(grep '^cmdline=' header | cut -d= -f2- | sed -e 's/skip_override//' -e 's/ */ /g' -e 's/[ \t]*$//')|" header; + + cp -f $recoverycpio ramdisk.cpio; + $tool repack boot.img || abort "Failed to repack image!"; + $tool cleanup; + else + ui_print "Flashing image to $name$slot..."; + cp -f $recoveryimg new-boot.img; + fi; + + blockdev --setrw $target$slot; + cat new-boot.img /dev/zero > $target$slot 2>/dev/null || true; + rm -f new-boot.img; +done; + +if [ "$recoverycpio" ]; then + ui_print " "; + ui_print "Image patching complete!"; +fi; + +cd /; +rm -rf /dev/tmp; + +ui_print " "; +ui_print "Done installing TWRP!"; +if [ "$name" != "recovery" ]; then + ui_print " "; + ui_print "*** NOTE: MAGSIK ERASED! REFLASH ***"; +fi; diff --git a/TWRP_flashable/META-INF/com/google/android/updater-script b/TWRP_flashable/META-INF/com/google/android/updater-script new file mode 100644 index 0000000..11d5c96 --- /dev/null +++ b/TWRP_flashable/META-INF/com/google/android/updater-script @@ -0,0 +1 @@ +#MAGISK diff --git a/TWRP_flashable/magiskboot b/TWRP_flashable/magiskboot new file mode 100644 index 0000000..724585a Binary files /dev/null and b/TWRP_flashable/magiskboot differ diff --git a/TWRP_flashable/ramdisk-recovery.cpio b/TWRP_flashable/ramdisk-recovery.cpio new file mode 100644 index 0000000..12de56a Binary files /dev/null and b/TWRP_flashable/ramdisk-recovery.cpio differ