@@ -201,6 +201,26 @@ isoneof() {
201
201
return 1
202
202
}
203
203
204
+ merge_splits () {
205
+ local bundle=$1 output=$2
206
+ gh_dl " $TEMP_DIR /apkeditor.jar" " https://github.com/REAndroid/APKEditor/releases/download/V1.3.9/APKEditor-1.3.9.jar" > /dev/null || return 1
207
+ if ! OP=$( java -jar " $TEMP_DIR /apkeditor.jar" merge -i " ${bundle} " -o " ${bundle} .mzip" -clean-meta -f 2>&1 ) ; then
208
+ epr " $OP "
209
+ return 1
210
+ fi
211
+ # this is required because of apksig
212
+ mkdir " ${bundle} -zip"
213
+ unzip -qo " ${bundle} .mzip" -d " ${bundle} -zip"
214
+ cd " ${bundle} -zip" || abort
215
+ zip -0rq " ../../${bundle} .zip" .
216
+ cd ../.. || abort
217
+ pr " Merging splits"
218
+ patch_apk " ${bundle} .zip" " ${output} " " --exclusive" " ${args[cli]} " " ${args[ptjar]} "
219
+ local ret=$?
220
+ rm -r " ${bundle} -zip" " ${bundle} .zip" " ${bundle} .mzip" || :
221
+ return $ret
222
+ }
223
+
204
224
# -------------------- apkmirror --------------------
205
225
apk_mirror_search () {
206
226
local resp=" $1 " dpi=" $2 " arch=" $3 " apk_bundle=" $4 "
@@ -240,15 +260,8 @@ dl_apkmirror() {
240
260
url=$( echo " $resp " | $HTMLQ --base https://www.apkmirror.com --attribute href " a.btn" ) || return 1
241
261
url=$( req " $url " - | $HTMLQ --base https://www.apkmirror.com --attribute href " span > a[rel = nofollow]" ) || return 1
242
262
if [ " $is_bundle " = true ]; then
243
- gh_dl " $TEMP_DIR /apkeditor.jar" " https://github.com/REAndroid/APKEditor/releases/latest/download/APKEditor-1.3.9.jar" > /dev/null || return 1
244
263
req " $url " " ${output} .apkm"
245
- java -jar " $TEMP_DIR /apkeditor.jar" merge -i " ${output} .apkm" -o " ${output} .zip" -clean-meta -f || return 1
246
- mkdir " ${output} -zip" || :
247
- unzip -qo " ${output} .zip" -d " ${output} -zip"
248
- cd " ${output} -zip" || abort
249
- zip -FS0rq " ../../${output} " .
250
- cd ../.. || abort
251
- rm -r " ${output} -zip" " ${output} .apkm" " ${output} .zip"
264
+ merge_splits " ${output} .apkm" " ${output} "
252
265
else
253
266
req " $url " " ${output} "
254
267
fi
@@ -334,8 +347,10 @@ patch_apk() {
334
347
--keystore-entry-password=123456789 --keystore-password=123456789 --signer=jhc --keystore-entry-alias=jhc --options=options.json"
335
348
if [ " $OS " = Android ]; then cmd+=" --custom-aapt2-binary=${AAPT2} " ; fi
336
349
pr " $cmd "
337
- eval " $cmd "
338
- [ -f " $patched_apk " ]
350
+ if eval " $cmd " ; then [ -f " $patched_apk " ]; else
351
+ rm " $patched_apk " 2> /dev/null || :
352
+ return 1
353
+ fi
339
354
}
340
355
341
356
check_sig () {
0 commit comments