-
Notifications
You must be signed in to change notification settings - Fork 40
/
patch-apk.sh
executable file
·240 lines (217 loc) · 8.92 KB
/
patch-apk.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
# alias to display [Done] in green
display_done() {
printf "\e[1;32m[Done]\e[0m\n"
}
# alias to display text in cyan
display_cyan() {
printf "\e[1;36m%s\e[0m" "$1"
}
# alias to display text in light red
display_light_red() {
printf "\e[1;91m%s\e[0m" "$1"
}
# start of script
clear
printf "\e[1;91m==========================\n"
printf " NetherSX2 Patcher v1.9\n"
printf "==========================\e[0m\n"
# Check if the NetherSX2 APK exists and if it's named
if [ ! -f "15210-v1.5-4248.apk" ]; then
wget https://github.com/Trixarian/NetherSX2-patch/releases/download/0.0/15210-v1.5-4248.apk
if [ ! $? -eq 0 ]; then
printf "Failed to download unmodified APK!\n"
exit 1
fi
fi
if [ ! -f "15210-v1.5-4248-noads.apk" ]; then
xdelta3 -d -f -s 15210-v1.5-4248.apk lib/patch.xdelta 15210-v1.5-4248-noads.apk
if [ ! $? -eq 0 ]; then
printf "Failed to apply nethersx2 patch to APK!\n"
exit 1
fi
fi
if [ "$(md5sum "15210-v1.5-4248-noads.apk" | awk '{print $1}')" = "c98b0e4152d3b02fbfb9f62581abada5" ]; then
printf "\e[0;31mError: Incorrect APK provided! Original unpatched APK should not be renamed -noads.\n"
printf "Please provide a copy of NetherSX2 named 15210-v1.5-4248-noads.apk!\e[0m\n"
exit 1
fi
cp 15210-v1.5-4248-noads.apk 15210-v1.5-4248-patched.apk
if command -v "aapt" >/dev/null 2>&1; then
# Ad Services Cleanup
display_cyan "Removing the "
display_light_red "Ad Services leftovers... "
aapt r 15210-v1.5-4248-patched.apk user-messaging-platform.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-tasks.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-measurement-sdk-api.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-measurement-base.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-basement.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-base.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-appset.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-ads.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-ads-lite.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-ads-identifier.properties > /dev/null 2>&1
aapt r 15210-v1.5-4248-patched.apk play-services-ads-base.properties > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
else
printf "\e[1;32m[Already removed]\e[0m\n"
fi
# Updates the FAQ to show that we're using the latest version of NetherSX2
display_cyan "Updating the "
display_light_red "FAQ... "
aapt r 15210-v1.5-4248-patched.apk assets/faq.html
aapt a 15210-v1.5-4248-patched.apk assets/faq.html > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
# Updates to Latest GameDB with features removed that are not supported by the libemucore.so from March 13th
display_cyan "Updating the "
display_light_red "GameDB... "
aapt r 15210-v1.5-4248-patched.apk assets/GameIndex.yaml
aapt a 15210-v1.5-4248-patched.apk assets/GameIndex.yaml > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
# Updates the Game Controller Database
display_cyan "Updating the "
display_light_red "Controller Database... "
aapt r 15210-v1.5-4248-patched.apk assets/game_controller_db.txt
aapt a 15210-v1.5-4248-patched.apk assets/game_controller_db.txt > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
# Updates the Widescreen Patches
display_cyan "Updating the "
display_light_red "Widescreen Patches... "
aapt r 15210-v1.5-4248-patched.apk assets/cheats_ws.zip
aapt a 15210-v1.5-4248-patched.apk assets/cheats_ws.zip > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
# Updates the No-Interlacing Patches
display_cyan "Updating the "
display_light_red "No-Interlacing Patches... "
aapt r 15210-v1.5-4248-patched.apk assets/cheats_ni.zip
aapt a 15210-v1.5-4248-patched.apk assets/cheats_ni.zip > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
# Fixes License Compliancy Issue
display_cyan "Fixing the "
display_light_red "License Compliancy Issue... "
aapt r 15210-v1.5-4248-patched.apk assets/3rdparty.html
aapt a 15210-v1.5-4248-patched.apk assets/3rdparty.html > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
# Adds the placeholder file that makes RetroAchievements Notifications work
display_cyan "Fixing the "
display_light_red "RetroAchievements Notifications... "
aapt r 15210-v1.5-4248-patched.apk assets/placeholder.png > /dev/null 2>&1
aapt a 15210-v1.5-4248-patched.apk assets/placeholder.png > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
else
chmod +x lib/aapt
display_cyan "Removing the "
display_light_red "Ad Services leftovers... "
lib/aapt r 15210-v1.5-4248-patched.apk user-messaging-platform.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-tasks.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-measurement-sdk-api.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-measurement-base.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-basement.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-base.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-appset.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-ads.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-ads-lite.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-ads-identifier.properties > /dev/null 2>&1
lib/aapt r 15210-v1.5-4248-patched.apk play-services-ads-base.properties > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
else
printf "\e[1;32m[Already removed]\e[0m\n"
fi
display_cyan "Updating the "
display_light_red "FAQ... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/faq.html
lib/aapt a 15210-v1.5-4248-patched.apk assets/faq.html > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
display_cyan "Updating the "
display_light_red "GameDB... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/GameIndex.yaml
lib/aapt a 15210-v1.5-4248-patched.apk assets/GameIndex.yaml > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
display_cyan "Updating the "
display_light_red "Controller Database... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/game_controller_db.txt
lib/aapt a 15210-v1.5-4248-patched.apk assets/game_controller_db.txt > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
display_cyan "Updating the "
display_light_red "Widescreen Patches... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/cheats_ws.zip
lib/aapt a 15210-v1.5-4248-patched.apk assets/cheats_ws.zip > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
display_cyan "Updating the "
display_light_red "No-Interlacing Patches... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/cheats_ni.zip
lib/aapt a 15210-v1.5-4248-patched.apk assets/cheats_ni.zip > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
display_cyan "Fixing the "
display_light_red "License Compliancy Issue... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/3rdparty.html
lib/aapt a 15210-v1.5-4248-patched.apk assets/3rdparty.html > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
display_cyan "Fixing the "
display_light_red "RetroAchievements Notifications... "
lib/aapt r 15210-v1.5-4248-patched.apk assets/placeholder.png > /dev/null 2>&1
lib/aapt a 15210-v1.5-4248-patched.apk assets/placeholder.png > /dev/null 2>&1
if [ $? -eq 0 ]; then
display_done
fi
fi
# Resigns the APK before exiting
if command -v "apksigner" >/dev/null 2>&1; then
display_cyan "Resigning the "
display_light_red "NetherSX2 APK... "
apksigner sign --ks lib/android.jks --ks-pass pass:android_sign --key-pass pass:android_sign_alias 15210-v1.5-4248-patched.apk
if [ $? -eq 0 ]; then
display_done
fi
else
display_cyan "Resigning the "
display_light_red "NetherSX2 APK... "
java -jar lib/apksigner.jar sign --ks lib/android.jks --ks-pass pass:android_sign --key-pass pass:android_sign_alias 15210-v1.5-4248-patched.apk
if [ $? -eq 0 ]; then
display_done
fi
fi
# Alternate Key:
# if command -v "apksigner" >/dev/null 2>&1; then
# display_cyan "Resigning the "
# display_light_red "NetherSX2 APK... "
# apksigner sign --ks lib/public.jks --ks-pass pass:public 15210-v1.5-4248-patched.apk
# if [ $? -eq 0 ]; then
# display_done
# fi
# else
# display_cyan "Resigning the "
# display_light_red "NetherSX2 APK... "
# java -jar lib/apksigner.jar sign --ks lib/public.jks --ks-pass pass:public 15210-v1.5-4248-patched.apk
# if [ $? -eq 0 ]; then
# display_done
# fi
# fi