This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
forked from CapitalGrin/AzurLaneBiliBili-Perseus
-
Notifications
You must be signed in to change notification settings - Fork 14
/
patch_perseus.sh
executable file
·55 lines (44 loc) · 2.34 KB
/
patch_perseus.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Download apkeep
get_artifact_download_url () {
# Usage: get_download_url <repo_name> <artifact_name> <file_type>
local api_url="https://api.github.com/repos/$1/releases/latest"
local result=$(curl $api_url | jq ".assets[] | select(.name | contains(\"$2\") and contains(\"$3\") and (contains(\".sig\") | not)) | .browser_download_url")
echo ${result:1:-1}
}
# Artifacts associative array aka dictionary
declare -A artifacts
artifacts["apkeep"]="EFForg/apkeep apkeep-x86_64-unknown-linux-gnu"
artifacts["apktool.jar"]="iBotPeaches/Apktool apktool .jar"
# Fetch all the dependencies
for artifact in "${!artifacts[@]}"; do
if [ ! -f $artifact ]; then
echo "Downloading $artifact"
curl -L -o $artifact $(get_artifact_download_url ${artifacts[$artifact]})
fi
done
chmod +x apkeep
# Download Azur Lane
if [ ! -f "com.YoStarJP.AzurLane.apk" ]; then
echo "Get Azur Lane apk"
wget https://dl.dropboxusercontent.com/s/phovtt9p0ormdbb/%E3%82%A2%E3%82%BA%E3%83%BC%E3%83%AB%E3%83%AC%E3%83%BC%E3%83%B3.apk?dl=0 -O com.YoStarJP.AzurLane.apk -q
echo "apk downloaded !"
fi
# Download Perseus
if [ ! -d "Perseus" ]; then
echo "Downloading Perseus"
git clone https://github.com/Egoistically/Perseus
fi
echo "Decompile Azur Lane apk"
java -jar apktool.jar -q -f d com.YoStarJP.AzurLane.apk
echo "Copy Perseus libs"
cp -r Perseus/. com.YoStarJP.AzurLane/lib/
echo "Patching Azur Lane with Perseus"
oncreate=$(grep -n -m 1 'onCreate' com.YoStarJP.AzurLane/smali_classes2/com/unity3d/player/UnityPlayerActivity.smali | sed 's/[0-9]*\:\(.*\)/\1/')
sed -ir "s#\($oncreate\)#.method private static native init(Landroid/content/Context;)V\n.end method\n\n\1#" com.YoStarJP.AzurLane/smali_classes2/com/unity3d/player/UnityPlayerActivity.smali
sed -ir "s#\($oncreate\)#\1\n const-string v0, \"Perseus\"\n\n\ invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V\n\n invoke-static {p0}, Lcom/unity3d/player/UnityPlayerActivity;->init(Landroid/content/Context;)V\n#" com.YoStarJP.AzurLane/smali_classes2/com/unity3d/player/UnityPlayerActivity.smali
echo "Build Patched Azur Lane apk"
java -jar apktool.jar -q -f b com.YoStarJP.AzurLane -o build/com.YoStarJP.AzurLane.patched.apk
echo "Set Github Release version"
s=($(./apkeep -a com.YoStarJP.AzurLane -l))
echo "PERSEUS_VERSION=$(echo ${s[-1]})" >> $GITHUB_ENV