This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
generated from n0k0m3/PerseusCI
-
Notifications
You must be signed in to change notification settings - Fork 5
/
patch_perseus.sh
executable file
·63 lines (50 loc) · 2.38 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
56
57
58
59
60
61
62
63
#!/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
download_azurlane () {
if [ ! -f "com.YoStarEN.AzurLane" ]; then
./apkeep -a com.YoStarEN.AzurLane .
fi
}
if [ ! -f "com.YoStarEN.AzurLane" ]; then
echo "Get Azur Lane apk"
download_azurlane
unzip -o com.YoStarEN.AzurLane.xapk -d AzurLane
cp AzurLane/com.YoStarEN.AzurLane.apk .
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.YoStarEN.AzurLane.apk
echo "Copy Perseus libs"
cp -r Perseus/. com.YoStarEN.AzurLane/lib/
echo "Patching Azur Lane with Perseus"
oncreate=$(grep -n -m 1 'onCreate' com.YoStarEN.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.YoStarEN.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.YoStarEN.AzurLane/smali_classes2/com/unity3d/player/UnityPlayerActivity.smali
echo "Build Patched Azur Lane apk"
java -jar apktool.jar -q -f b com.YoStarEN.AzurLane -o build/com.YoStarEN.AzurLane.patched.apk
echo "Set Github Release version"
s=($(./apkeep -a com.YoStarEN.AzurLane -l))
echo "PERSEUS_VERSION=$(echo ${s[-1]})" >> $GITHUB_ENV