-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathandre-apk.sh
38 lines (30 loc) · 1 KB
/
andre-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
#!/bin/sh
argv0="$0"
msg() { printf -- '%s: %s\n' "${argv0##*/}" "$@" 1>&2; }
err() { msg "$@"; exit 1; }
[ -z "$1" ] && err 'usage: <apk>'
pkgfile="$(realpath "$1")"
arch="$(file ./andre | awk -F', ' '{print $2}')"
case "$arch" in
'Intel 80386')
arch="x86"
;;
'ARM')
arch="armeabi-v7a"
;;
*)
err "dont know how to convert from elf arch '$arch' to android arch"
;;
esac
pkgname="$(aapt2 dump --file AndroidManifest.xml "$1" | sed -nr 's/.*A: package="([^ "]+).*/\1/p')"
[ -z "$pkgname" ] && err "not a valid apk (missing package name)"
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
unzip "$1" -d "$tmpdir"
export ANDROID_PACKAGE_CODE_PATH="$pkgfile"
export ANDROID_PACKAGE_NAME="$pkgname"
# TODO: when we have first release, make this follow XDG spec
export ANDROID_EXTERNAL_FILES_DIR="$PWD/local/data/$pkgname/files"
export ANDROID_EXTERNAL_OBB_DIR="$PWD/local/data/$pkgname/obb"
# XXX: We only work with unity stuff for now
./andre "$tmpdir/lib/$arch/libunity.so"