forked from R9TRH/redwood-recovery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09f1729
commit d8de4d4
Showing
8 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#MAGISK |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#MAGISK |
Binary file not shown.
Binary file not shown.