feat(clone-app): detect-unity.sh — classify il2cpp/mono/none APKs
This commit is contained in:
parent
014c07c36e
commit
e3a29974f4
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
# Classify an APK/XAPK as a Unity build: il2cpp | mono | none.
|
||||
set -uo pipefail
|
||||
|
||||
APK="${1:-}"
|
||||
if [[ -z "$APK" || ! -f "$APK" ]]; then
|
||||
echo "ERROR: usage: detect-unity.sh <apk-or-xapk>" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
listing="$(unzip -Z1 "$APK" 2>/dev/null)" || {
|
||||
echo "ERROR: cannot read zip: $APK" >&2; exit 2; }
|
||||
|
||||
if grep -q 'global-metadata\.dat' <<<"$listing" \
|
||||
&& grep -qi 'libil2cpp\.so' <<<"$listing"; then
|
||||
echo il2cpp; exit 0
|
||||
fi
|
||||
if grep -Eq 'assets/bin/Data/Managed/.*\.dll' <<<"$listing"; then
|
||||
echo mono; exit 0
|
||||
fi
|
||||
echo none
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
SCRIPT="$HERE/../skills/clone-app/scripts/detect-unity.sh"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
fail=0
|
||||
check() {
|
||||
local desc="$1" expected="$2" actual="$3"
|
||||
if [[ "$expected" == "$actual" ]]; then echo "PASS: $desc"
|
||||
else echo "FAIL: $desc — expected '$expected' got '$actual'"; fail=1; fi
|
||||
}
|
||||
|
||||
# Build three fixture zips with python's zipfile (portable, no `zip` needed).
|
||||
mkzip() { python3 - "$1" "${@:2}" <<'PY'
|
||||
import sys, zipfile
|
||||
out = sys.argv[1]
|
||||
with zipfile.ZipFile(out, "w") as z:
|
||||
for entry in sys.argv[2:]:
|
||||
z.writestr(entry, "x")
|
||||
PY
|
||||
}
|
||||
|
||||
mkzip "$TMP/il2cpp.apk" "lib/arm64-v8a/libil2cpp.so" "assets/bin/Data/Managed/Metadata/global-metadata.dat"
|
||||
mkzip "$TMP/mono.apk" "assets/bin/Data/Managed/Assembly-CSharp.dll"
|
||||
mkzip "$TMP/plain.apk" "classes.dex" "AndroidManifest.xml"
|
||||
|
||||
check "il2cpp" "il2cpp" "$(bash "$SCRIPT" "$TMP/il2cpp.apk")"
|
||||
check "mono" "mono" "$(bash "$SCRIPT" "$TMP/mono.apk")"
|
||||
check "none" "none" "$(bash "$SCRIPT" "$TMP/plain.apk")"
|
||||
|
||||
bash "$SCRIPT" >/dev/null 2>&1; rc=$?
|
||||
check "usage exit 2" "2" "$rc"
|
||||
|
||||
exit $fail
|
||||
Loading…
Reference in New Issue