Skip to content

Instantly share code, notes, and snippets.

@mzyy94
Created September 10, 2020 18:35
Show Gist options
  • Save mzyy94/fc1e5cbed5c6814777e5938351a5bed1 to your computer and use it in GitHub Desktop.
Save mzyy94/fc1e5cbed5c6814777e5938351a5bed1 to your computer and use it in GitHub Desktop.
./createpatchedboot.sh "JOYING FIRMWARE.zip" magisk_patched.img ./output/
#!/bin/sh
UPDATE_FILE="${1}"
PATCHED_BOOT="${2}"
OUTPUT_DIR="${3:-./out}"
CWD=$(cd $(dirname $0) && pwd)
OUTPUT_DIR="$CWD/$OUTPUT_DIR/"
OTA_PACKAGE="6521_1.zip"
UPDATER="lsec6521update"
SCRIPT_PATH="META-INF/com/google/android/updater-script"
TMP_FILE=$(mktemp)
TMP_DIR=$(mktemp -d)
OTA_DIR=$TMP_DIR/ota
set -eux
unzip "$UPDATE_FILE" $OTA_PACKAGE $UPDATER -d $TMP_DIR
unzip "$TMP_DIR/$OTA_PACKAGE" "META-INF/**/*" -x "**/nvmerge*" -d $OTA_DIR
rm "$TMP_DIR/$OTA_PACKAGE"
cp $PATCHED_BOOT $OTA_DIR/
cd $OTA_DIR
mv ./$SCRIPT_PATH $TMP_FILE
awk "NR<=2 || /boot.img|progress/" $TMP_FILE | sed -e "s/boot.img/$(basename $PATCHED_BOOT)/" > ./$SCRIPT_PATH
zip -r "$TMP_DIR/$OTA_PACKAGE" *
if [ ! -d "$OUTPUT_DIR" ]; then
mkdir "$OUTPUT_DIR"
fi
mv ../$OTA_PACKAGE ../$UPDATER "$OUTPUT_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment