Last active
January 15, 2024 01:02
-
-
Save trippsanders/415ccc879af699cd13518a26399b3cf7 to your computer and use it in GitHub Desktop.
Bash script to patch Linux (Android X86-64 builds) to allow building on the nether roof
This file contains hidden or 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
| #!/bin/bash | |
| # Requires xxd and tr, both are probably installed as xxd is included with vim and tr is part of the GNU coreutils | |
| # Tested on 1.14.60, 1.16.10, 1.16.20, 1.16.40, 1.16.100, 1.17.41, 1.18.31, 1.19.41, 1.19.50, and 1.20.51. | |
| # Thanks to Max RM (@_max_rm) and AmyGrrl (@amygrrl) for the search bytes | |
| display_help() { | |
| echo "Usage: $0 [--backup] [--1.14.60-1.16.10] [--1.16.20-1.16.40] [--1.16.100-1.19.41] <source_file>" | |
| echo "Options:" | |
| echo " --backup Create a backup of the source binary." | |
| echo " --1.14.60-1.16.10 Patching Nether build limit for 1.14.60-1.16.10" | |
| echo " --1.16.20-1.16.40 Patching Nether build limit for 1.16.20-1.16.40." | |
| echo " --1.16.100-1.19.41 Patching Nether build limit for 1.16.100-1.19.41." | |
| echo " --help Display this help message." | |
| exit 0 | |
| } | |
| if [ "$#" -lt 1 ] || [ "$#" -gt 5 ]; then | |
| display_help | |
| fi | |
| backup_option=false | |
| fourteenDot60Todot10=false | |
| sixtenDot20To19Dot40=false | |
| sixtenDot100To19Dot41=false | |
| while [ "$#" -gt 0 ]; do | |
| case "$1" in | |
| --backup) | |
| backup_option=true | |
| shift | |
| ;; | |
| --1.14.60-1.16.10) | |
| fourteenDot60Todot10=true | |
| shift | |
| ;; | |
| --1.16.20-1.16.40) | |
| sixtenDot20To19Dot40=true | |
| shift | |
| ;; | |
| --1.16.100-1.19.41) | |
| sixtenDot100To19Dot41=true | |
| shift | |
| ;; | |
| --help) | |
| display_help | |
| ;; | |
| *) | |
| break | |
| ;; | |
| esac | |
| done | |
| if [ "$#" -ne 1 ]; then | |
| display_help | |
| fi | |
| source_file="$1" | |
| if [ ! -e "$source_file" ]; then | |
| echo "Error: Source file '$source_file' does not exist." | |
| exit 1 | |
| fi | |
| echo "This patcher uses the byte searching method, it should work for X86_64 builds on 1.14.60 and above." | |
| # Backup | |
| if [ "$backup_option" == true ]; then | |
| cp -p "$source_file" "$source_file.bak" | |
| echo "Binary backed up" | |
| fi | |
| # Search and patching | |
| if [ "$fourteenDot60Todot10" == "true" ]; then | |
| echo "Patching 4C2408B980000000 for 1.14.60 to 1.16.10" | |
| xxd -p "$source_file" | tr -d '\n' | sed "0,/4c2408b980000000/s//4c2408b900010000/" | xxd -r -p > "$source_file.tmp" | |
| elif [ "$sixtenDot20To19Dot40" == "true" ]; then | |
| echo "Patching 4989E1B980000000 for 1.16.20 to 1.16.40" | |
| xxd -p "$source_file" | tr -d '\n' | sed "0,/4989e1b980000000/s//4989e1b900010000/" | xxd -r -p > "$source_file.tmp" | |
| elif [ "$sixtenDot100To19Dot41" == "true" ]; then | |
| echo "Patching EAB900008000 for 1.16.100 to 1.19.41" | |
| xxd -p "$source_file" | tr -d '\n' | sed "0,/eab900008000/s//eab900000001/" | xxd -r -p > "$source_file.tmp" | |
| else | |
| echo "Patching 08B900008000 for 1.19.50 and newer" | |
| xxd -p "$source_file" | tr -d '\n' | sed "0,/08b900008000/s//08b900000001/" | xxd -r -p > "$source_file.tmp" | |
| fi | |
| mv "$source_file.tmp" "$source_file" | |
| echo "Patched" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment