diff --git a/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot b/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot index 858de050..2920f0a7 100644 --- a/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot +++ b/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot @@ -56,6 +56,16 @@ npm --version node --version npm install +# `npm install` rewrites the tracked app/package-lock.json. build_app.sh (below) +# stamps build/.build-stamp from that working tree, but on-device repair.sh runs +# `git reset --hard` before it stamps -- reverting the lock -- so a stamp baked +# against the dirty lock can never match on first boot and the box rebuilds the app. +# Reset to HEAD here, exactly as repair.sh does, so the baked stamp represents +# committed source. Only the lock is reverted; build/, node_modules, and the venvs +# are untracked and survive. The repo is cloned and reset as root (same owner), +# so no safe.directory config is needed here. +git -C /opt/wrolpi reset --hard HEAD + # Build the React production bundle. Without this, /opt/wrolpi/app/build/ # does not exist and wrolpi-app.service (`serve build -l 3000 ...`) returns # 404 for every request. Baking the build into the squashfs means the diff --git a/pi-gen/stage2/04-wrolpi/03-run-chroot.sh b/pi-gen/stage2/04-wrolpi/03-run-chroot.sh index ed2547c9..9affc7f8 100755 --- a/pi-gen/stage2/04-wrolpi/03-run-chroot.sh +++ b/pi-gen/stage2/04-wrolpi/03-run-chroot.sh @@ -63,6 +63,15 @@ echo "Controller pre-installed" # Install webapp. (cd /opt/wrolpi/app && npm install) +# `npm install` rewrites the tracked app/package-lock.json. build_app.sh (below) +# stamps build/.build-stamp from that working tree, but on-device repair.sh runs +# `git reset --hard` before it stamps -- reverting the lock -- so a stamp baked +# against the dirty lock can never match on first boot and the Pi rebuilds the app +# (the exact OOM-prone step this bake-in avoids). Reset to HEAD here, exactly as +# repair.sh does, so the baked stamp represents committed source. Only the lock is +# reverted; build/, node_modules, and the venvs are untracked and survive. +git -C /opt/wrolpi reset --hard HEAD + # Build the React production bundle now, so it is baked into the image. Without # this the Pi would build on first boot -- a multi-minute, memory-hungry step # that can OOM on a 2GB Pi. build_app.sh stamps the output so the on-device