From f72ac3f16f42c3f9b9d514430f2c649f437e3c3a Mon Sep 17 00:00:00 2001 From: Jon Goohs Date: Sun, 3 May 2026 01:46:19 -0700 Subject: [PATCH] chore(atak): pick newest APK by modtime in install_device.sh The previous `find ... | sort | tail` form selected APKs by lexicographic order, which silently mis-ranks versions where a higher-numbered build sorts before a lower one (e.g. v1.2.10 before v1.2.2). Switch to `ls -t` so the freshest build artifact is always installed, matching dev intent. Closes #104. --- atak/plugin/scripts/install_device.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/atak/plugin/scripts/install_device.sh b/atak/plugin/scripts/install_device.sh index b1612a7..1c1f4e2 100755 --- a/atak/plugin/scripts/install_device.sh +++ b/atak/plugin/scripts/install_device.sh @@ -3,11 +3,19 @@ set -euo pipefail cd "$(dirname "$0")/.." -APK="$(find app/build/outputs/apk/civ/release -maxdepth 1 -name '*.apk' -print 2>/dev/null | sort | tail -n 1)" +# Pick the newest APK by modification time so a freshly-rebuilt artifact is +# preferred over a stale-but-lexicographically-later leftover (e.g. v1.2.10 +# would lex-sort before v1.2.2 with the previous `sort | tail` form). `ls -t` +# is portable across macOS (BSD) and Jetson (GNU). +pick_latest_apk() { + ls -1t app/build/outputs/apk/civ/release/*.apk 2>/dev/null | head -n 1 +} + +APK="$(pick_latest_apk)" if [[ -z "$APK" || ! -f "$APK" ]]; then ./scripts/build_release.sh - APK="$(find app/build/outputs/apk/civ/release -maxdepth 1 -name '*.apk' -print | sort | tail -n 1)" + APK="$(pick_latest_apk)" fi adb install -r "$APK"