Package the models on every platform, not just the phone

The Android bundling landed the weights under that platform's asset directory,
which was the wrong home the moment a second packager wanted them. `makepkg -si`
produced a desktop install with no model at all — the same "no face model is
installed" the phone used to show, for the same reason: nothing put the files
anywhere the app looks.

So `models/face/` at the root is the one copy, and both packagers read it:
assemble-apk.sh bundles it as APK assets, and the PKGBUILD installs it to
/usr/share/darkroom/models. Both refuse an LFS pointer rather than shipping a
130-byte file that fails inside the graph loader on a user's machine.

`face_models` now searches three places, most specific first: the account's own
directory, the shared user directory, then $XDG_DATA_DIRS. So a packaged pair is
found automatically and a pair the user placed by hand still outranks it — which
is what keeps a deliberate choice of weights from being overridden by an
upgrade.

$XDG_DATA_DIRS rather than a hard-coded /usr/share: that is the variable a
distribution, a prefix install or a Nix-style store already sets to say where
its data went, and its documented default is exactly the two paths that would
otherwise have been hard-coded. Empty on Android, which has no such directories
— there the APK's copy is unpacked into the shared user directory instead,
because an asset inside a package is not a path anything can read from.

Verified: the APK still carries both models at assets/models/, the PKGBUILD
parses and installs from the new path, 467 tests pass.

Includes the pkgver 0.6.0 → 0.7.0 bump that was already sitting uncommitted in
the working tree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-27 18:05:23 +02:00
co-authored by Claude Opus 5
parent 725f7bf77f
commit 2d95807542
9 changed files with 101 additions and 45 deletions
+2 -2
View File
@@ -42,8 +42,8 @@ the runner host's cached registry credentials.
## Face models
`package.sh` bundles `apps/darkroom-android/android/assets/models/` into the APK, and the entry point
unpacks it on first launch. **The models are in LFS**, so a clone without `git lfs pull` has 130-byte
`package.sh` bundles `models/face/` into the APK, and the entry point unpacks it on first launch.
That directory is shared with the Arch package rather than owned by this platform. **The models are in LFS**, so a clone without `git lfs pull` has 130-byte
pointers there; the build detects that and stops rather than shipping them.
This exists because Android offers no other route to a model: the directory the app reads from is
+9 -7
View File
@@ -155,31 +155,33 @@ cp "${DEX}" "${OUT}/staging/classes.dex"
# The face models. Android has no other route to one — app-private storage is
# not user-reachable and the in-app fetch is unbuilt (docs/faces.md §2.2a) — so
# they go in the APK and `android_main` unpacks them on first launch.
# they go in the APK and `android_main` unpacks them on first launch. The
# source is `models/face/`, shared with the Arch package rather than living
# under this one platform's directory.
#
# Through the staging directory rather than aapt2's `-A`: the .so and the dex
# already go in with `zip` below, and one mechanism for "extra files in the
# APK" is easier to follow than two.
ASSETS="${REPO}/apps/darkroom-android/android/assets"
ASSETS="${REPO}/models/face"
# Cleared first: a previous run that died between staging and cleanup would
# otherwise leave models in the APK that are no longer in the tree.
rm -rf "${OUT}/staging/assets"
if compgen -G "${ASSETS}/models/*.onnx" >/dev/null; then
if compgen -G "${ASSETS}/*.onnx" >/dev/null; then
# An LFS pointer is ~130 bytes and looks exactly like a model to `cp`. Left
# unchecked it reaches the device and fails inside tract, which reports a
# broken graph rather than a clone that needs `git lfs pull`. Same guard
# dr-segment's build script applies to yolo26n-seg.onnx, and the same
# reason.
for m in "${ASSETS}"/models/*.onnx; do
for m in "${ASSETS}"/*.onnx; do
if [[ "$(stat -c%s "${m}")" -lt 100000 ]]; then
echo "error: $(basename "${m}") is $(stat -c%s "${m}") bytes — an LFS pointer, not a model." >&2
echo " run: git lfs pull" >&2
exit 1
fi
done
mkdir -p "${OUT}/staging/assets"
cp -r "${ASSETS}/models" "${OUT}/staging/assets/"
echo " assets: $(ls "${ASSETS}/models" | tr '\n' ' ')"
mkdir -p "${OUT}/staging/assets/models"
cp "${ASSETS}"/*.onnx "${OUT}/staging/assets/models/"
echo " assets: $(ls "${ASSETS}" | grep '\.onnx$' | tr '\n' ' ')"
else
echo " assets: no face models found (face indexing will be off on the device)"
fi