mirror of
https://github.com/izzy2lost/AM2R-Autopatcher-Android.git
synced 2026-06-19 01:20:10 -07:00
Update patcher.sh
This commit is contained in:
+30
-40
@@ -1,23 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on any error to avoid showing everything was successful even though it wasn't
|
||||
set -e
|
||||
|
||||
VERSION="15_5"
|
||||
OUTPUT="am2r_${VERSION}"
|
||||
DATA_FOLDER="data"
|
||||
REPO_URL="https://github.com/izzy2fancy/AM2R-Autopatcher-Android"
|
||||
BRANCH="main"
|
||||
PATCH_FOLDER="data"
|
||||
|
||||
# Cleanup previous directories and files
|
||||
cleanup_directories() {
|
||||
local directories=("assets" "AM2RWrapper" "$DATA_FOLDER" "HDR_HQ_in-game_music")
|
||||
local directories=("assets" "AM2RWrapper" "data" "HDR_HQ_in-game_music" "data.zip" "HDR_HQ_in-game_music.zip")
|
||||
for dir in "${directories[@]}"; do
|
||||
if [ -d "$dir" ]; then
|
||||
if [ -d "$dir" ] || [ -f "$dir" ]; then
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cleanup_directories
|
||||
|
||||
echo "-------------------------------------------"
|
||||
echo ""
|
||||
echo "AM2R 1.5.5 Shell Autopatching Utility"
|
||||
@@ -31,27 +32,21 @@ echo "-------------------------------------------"
|
||||
yes | pkg install termux-am zip unzip xdelta3
|
||||
yes | termux-setup-storage
|
||||
|
||||
# Check and install apkmod if not installed
|
||||
# Check if apkmod is installed, if not install it. I only use this for signing 'cause it's the only way I found this to work
|
||||
if ! [ -f /data/data/com.termux/files/usr/bin/apkmod ]; then
|
||||
wget https://raw.githubusercontent.com/Hax4us/Apkmod/master/setup.sh
|
||||
bash setup.sh
|
||||
rm -f setup.sh
|
||||
fi
|
||||
|
||||
# Clone the repository
|
||||
git archive --remote="${REPO_URL}" --format=zip --output="${DATA_FOLDER}.zip" "${BRANCH}:${PATCH_FOLDER}"
|
||||
# Download the patch data
|
||||
wget https://github.com/izzy2fancy/AM2R-Autopatcher-Android/releases/download/1.0/data.zip
|
||||
yes | unzip data.zip -d ./
|
||||
|
||||
# Extract the downloaded patch data
|
||||
unzip -q "${DATA_FOLDER}.zip" -d "${DATA_FOLDER}"
|
||||
|
||||
# Remove the downloaded zip file
|
||||
rm "${DATA_FOLDER}.zip"
|
||||
|
||||
set -
|
||||
#check for AM2R_11.zip in downloads
|
||||
# Check for AM2R_11.zip in downloads
|
||||
if [ -f ~/storage/downloads/AM2R_11.zip ]; then
|
||||
echo "AM2R_11.zip found! Extracting to ${OUTPUT}"
|
||||
#extract the content to the am2r_xx folder
|
||||
# Extract the content to the am2r_xx folder
|
||||
unzip -q ~/storage/downloads/AM2R_11.zip -d "${OUTPUT}"
|
||||
else
|
||||
echo -e "\033[0;31mAM2R_11 not found. Place AM2R_11.zip (case sensitive) into your Downloads folder and try again."
|
||||
@@ -60,20 +55,16 @@ else
|
||||
fi
|
||||
|
||||
echo "Applying Android patch..."
|
||||
xdelta3 -dfs "${OUTPUT}"/data.win data/droid.xdelta "${OUTPUT}"/game.droid
|
||||
#cp data/android/AM2RWrapper.apk utilities/android/
|
||||
xdelta3 -dfs "${OUTPUT}"/data.win data/droid.xdelta "${OUTPUT}"/game.droid
|
||||
|
||||
#delete unnecessary files
|
||||
# Delete unnecessary files
|
||||
rm "${OUTPUT}"/D3DX9_43.dll "${OUTPUT}"/AM2R.exe "${OUTPUT}"/data.win
|
||||
|
||||
#cp -RTp "${OUTPUT}"/ utilities/android/assets/
|
||||
if [ -f data/android/AM2R.ini ]; then
|
||||
cp -p data/android/AM2R.ini "${OUTPUT}"/
|
||||
fi
|
||||
|
||||
|
||||
# Music
|
||||
#mkdir -p utilities/android/assets/lang
|
||||
cp data/files_to_copy/*.ogg "${OUTPUT}"/
|
||||
|
||||
echo ""
|
||||
@@ -87,51 +78,50 @@ echo ""
|
||||
if [ "$INPUT" = "y" ]; then
|
||||
echo "Downloading HQ music..."
|
||||
wget https://github.com/izzy2fancy/AM2R-Autopatcher-Android/releases/download/2.0/HDR_HQ_in-game_music.zip
|
||||
yes | unzip HDR_HQ_in-game_music.zip -d ./
|
||||
yes | unzip HDR_HQ_in-game_music.zip -d ./
|
||||
echo "Copying HQ music..."
|
||||
cp -f HDR_HQ_in-game_music/*.ogg "${OUTPUT}"/
|
||||
rm -rf HDR_HQ_in-game_music/
|
||||
fi
|
||||
|
||||
echo "Updating lang folder..."
|
||||
#remove old lang
|
||||
# Remove old lang
|
||||
rm -R "${OUTPUT}"/lang/
|
||||
#install new lang
|
||||
# Install new lang
|
||||
cp -RTp data/files_to_copy/lang/ "${OUTPUT}"/lang/
|
||||
|
||||
echo "Renaming music to lowercase..."
|
||||
#I can't figure out a better way to mass rename files to lowercase
|
||||
#so zipping them without compression and extracting them as all lowercase it is
|
||||
#music needs to be all lowercase
|
||||
# Zip them without compression and extracting them as all lowercase
|
||||
# Music needs to be all lowercase
|
||||
zip -0qr temp.zip "${OUTPUT}"/*.ogg
|
||||
rm "${OUTPUT}"/*.ogg
|
||||
unzip -qLL temp.zip
|
||||
rm temp.zip
|
||||
|
||||
echo "Packaging APK..."
|
||||
#decompile the apk
|
||||
# Decompile the apk
|
||||
apkmod -d -i data/android/AM2RWrapper.apk -o AM2RWrapper
|
||||
#copy
|
||||
# Copy
|
||||
mv "${OUTPUT}" assets
|
||||
cp -Rp assets AM2RWrapper
|
||||
#edited yaml thing to not compress ogg's
|
||||
# Edited yaml thing to not compress ogg's
|
||||
echo "Editing apktool.yml..."
|
||||
sed -i "s/doNotCompress:/doNotCompress:\n- ogg/" AM2RWrapper/apktool.yml
|
||||
#build
|
||||
# check if aapt2 exists, if not use aapt instead
|
||||
# Build
|
||||
# Check if aapt2 exists, if not use aapt instead
|
||||
if [ -f /usr/bin/aapt2 ]; then
|
||||
apkmod -r -i AM2RWrapper -o AM2R-"${VERSION}".apk
|
||||
apkmod -r -i AM2RWrapper -o "AM2R-${VERSION}.apk"
|
||||
else
|
||||
apkmod -a -r -i AM2RWrapper -o AM2R-"${VERSION}".apk
|
||||
apkmod -a -r -i AM2RWrapper -o "AM2R-${VERSION}.apk"
|
||||
fi
|
||||
#Sign apk
|
||||
apkmod -s -i AM2R-"${VERSION}".apk -o AM2R-"${VERSION}"-signed.apk
|
||||
# Sign apk
|
||||
apkmod -s -i "AM2R-${VERSION}.apk" -o "AM2R-${VERSION}-signed.apk"
|
||||
|
||||
# Cleanup
|
||||
rm -R assets/ AM2RWrapper/ data/ AM2R-"${VERSION}".apk
|
||||
rm -R assets/ AM2RWrapper/ data/ "AM2R-${VERSION}.apk"
|
||||
|
||||
# Move signed APK
|
||||
mv AM2R-"${VERSION}"-signed.apk ~/storage/downloads/AM2R-"${VERSION}"-signed.apk
|
||||
mv "AM2R-${VERSION}-signed.apk" ~/storage/downloads/AM2R-"${VERSION}"-signed.apk
|
||||
|
||||
echo ""
|
||||
echo -e "\033[0;32mThe operation was completed successfully and the APK can be found in your Downloads folder as \"AM2R-${VERSION}-signed.apk\"."
|
||||
|
||||
Reference in New Issue
Block a user