One-command installer + guided setup: role detection, self-flying sign test v2
- install.lua: single entry point -- detects role from peripherals (flight sensors = autopilot, monitor = cockpit), installs, cleans legacy/removed files, then hands off straight into setup/standby. Ship state (sides/calib/target/settings) is never shipped; existing profiles can be kept or reset on re-install. - Sign test v2: fully self-driving -- staircase power search (learns hover), closed-loop climb, both-direction verification with auto- escalating nudge, controlled descent. Never freefalls, also not on Ctrl+T or abort. - Setup wizard (ap setup): wiring pulse-walk + sign test in one guided flow; offered automatically on first boot without a profile. - New launcher 'ap' (stabilizeV2 kept as case-safe identical aliases; removes Windows-host case-collision recursion risk). - build.sh: repo is source of truth; LC_ALL=C sorted manifests; optional --from-world/--to-world dev sync with exclude lists. - Removed legacy v1 files and per-ship state from the repo/manifest (26 -> 17 files in the autopilot role). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
91
build.sh
91
build.sh
@@ -1,39 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
# build.sh -- mirror the live CC autopilot from the singleplayer world into this
|
||||
# repo and regenerate the per-role manifests that install.lua consumes.
|
||||
# build.sh -- regenerer per-rolle-manifester fra files/ (REPOET er kilden installeren serverer).
|
||||
# Vanlig flyt etter kodeendring: ./build.sh && git commit -am "sync" && git push
|
||||
#
|
||||
# Run this whenever you change the Lua locally and want the server installer to
|
||||
# pick it up: ./build.sh && git commit -am "sync" && git push
|
||||
# Valgfri synk mot singleplayer-verdenen (dev-miljoeet):
|
||||
# ./build.sh --from-world [computer-dir] # verden -> files/ (kun kode; state/legacy filtreres)
|
||||
# ./build.sh --to-world [computer-dir] # files/ -> verden (kun kode; roerer aldri state)
|
||||
set -euo pipefail
|
||||
|
||||
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SRC_DEFAULT="/home/stian/.local/share/ModrinthApp/profiles/Modda wii/saves/New World/computercraft/computer"
|
||||
SRC="${1:-$SRC_DEFAULT}"
|
||||
WORLD_DEFAULT="/home/stian/.local/share/ModrinthApp/profiles/Modda wii/saves/New World/computercraft/computer"
|
||||
|
||||
# role name -> source computer id in the world
|
||||
# rolle -> computer-id i verdenen
|
||||
declare -A ROLE_SRC=(
|
||||
[autopilot]=0 # maskinrom: startup -> stabilizeV2 -> autopilot/main
|
||||
[autopilot]=0 # maskinrom: startup -> ap boot -> wizard/standby
|
||||
[cockpit]=4 # pilot-hus: startup -> cockpit
|
||||
)
|
||||
|
||||
if [ ! -d "$SRC" ]; then
|
||||
echo "error: world computer dir not found: $SRC" >&2
|
||||
echo "pass the path as arg 1 if the world moved." >&2
|
||||
exit 1
|
||||
fi
|
||||
# per-skip tilstand + utdaterte verktoey: shippes ALDRI (installeren rydder dem ogsaa)
|
||||
EXCLUDES=(calib.txt sides.txt target.txt settings.txt scan.txt pid_gains.txt
|
||||
stabilize.lua diag.lua probe.lua scan.lua manifest)
|
||||
# rolle-spesifikt: cockpit-koden hoerer ikke hjemme paa autopilot-PCen
|
||||
declare -A ROLE_EXCLUDES=(
|
||||
[autopilot]="cockpit.lua pilot_startup.lua"
|
||||
[cockpit]=""
|
||||
)
|
||||
|
||||
is_excluded() { # $1=rolle $2=relativ sti
|
||||
local base x; base="$(basename "$2")"
|
||||
case "$base" in *.log|*.old|.installed_*) return 0;; esac
|
||||
for x in "${EXCLUDES[@]}"; do [ "$base" = "$x" ] && return 0; done
|
||||
for x in ${ROLE_EXCLUDES[$1]}; do [ "$base" = "$x" ] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
mode="${1:-manifests}"
|
||||
world="${2:-$WORLD_DEFAULT}"
|
||||
|
||||
case "$mode" in
|
||||
manifests) ;;
|
||||
--from-world|--to-world)
|
||||
if [ ! -d "$world" ]; then
|
||||
echo "error: world computer dir not found: $world" >&2
|
||||
echo "pass the path as arg 2 if the world moved." >&2
|
||||
exit 1
|
||||
fi
|
||||
for role in "${!ROLE_SRC[@]}"; do
|
||||
id="${ROLE_SRC[$role]}"
|
||||
src="$world/$id"; dst="$REPO/files/$role"
|
||||
if [ "$mode" = "--from-world" ]; then from="$src"; to="$dst"; else from="$dst"; to="$src"; fi
|
||||
if [ ! -d "$from" ]; then
|
||||
echo "warn: source dir missing for role '$role' ($from), skipping" >&2
|
||||
continue
|
||||
fi
|
||||
while IFS= read -r rel; do
|
||||
if ! is_excluded "$role" "$rel"; then
|
||||
mkdir -p "$to/$(dirname "$rel")"
|
||||
cp "$from/$rel" "$to/$rel"
|
||||
fi
|
||||
done < <(cd "$from" && find . -type f | sed 's|^\./||')
|
||||
echo "synced role '$role' ($mode)"
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "usage: ./build.sh [--from-world|--to-world] [computer-dir]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# manifester: nylinje-separerte relative stier. LC_ALL=C sort er VIKTIG: locale-avhengig
|
||||
# (case-insensitiv) sortering kan stokke om case-varianter og gi udefinert install-rekkefoelge.
|
||||
for role in "${!ROLE_SRC[@]}"; do
|
||||
id="${ROLE_SRC[$role]}"
|
||||
dst="$REPO/files/$role"
|
||||
if [ ! -d "$SRC/$id" ]; then
|
||||
echo "warn: computer $id (role $role) missing in world, skipping" >&2
|
||||
continue
|
||||
fi
|
||||
rm -rf "$dst"
|
||||
cp -r "$SRC/$id" "$dst"
|
||||
# Manifest = newline-separated relative paths, sorted, excluding the manifest itself.
|
||||
( cd "$dst" && find . -type f ! -name manifest | sed 's|^\./||' | sort ) > "$dst/manifest"
|
||||
echo "role '$role' <- computer $id : $(wc -l < "$dst/manifest") files"
|
||||
[ -d "$dst" ] || continue
|
||||
while IFS= read -r rel; do
|
||||
is_excluded "$role" "$rel" || printf '%s\n' "$rel"
|
||||
done < <(cd "$dst" && find . -type f ! -name manifest | sed 's|^\./||' | LC_ALL=C sort) > "$dst/manifest"
|
||||
echo "role '$role': $(wc -l < "$dst/manifest") files"
|
||||
done
|
||||
|
||||
echo "done. files/ and manifests regenerated."
|
||||
echo "done. manifests regenerated."
|
||||
|
||||
Reference in New Issue
Block a user