- Asset-Manifest mit Hash, Platzierung und Rig-Metadaten - tools/sync_assets.sh prueft Quelle und Ziel und kopiert aus dem Workbench-Archiv nach assets/external (gitignored) - Skater mit AutoRigPro geriggt: 226 Control-, 30 Deform-Bones - glTF-Export inkl. gebackenem Testclip, Godot-Import verifiziert - Manifest-Test mit 48 Assertions (1123 gesamt) - Phase-1-Exporte schliessen assets/external aus - Doku, Roadmap und Findings aktualisiert
195 lines
5.4 KiB
Bash
Executable file
195 lines
5.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Synchronisiert externe 3D-Assets aus dem Workbench-Archiv in das Godot-Projekt.
|
|
#
|
|
# Die Binärdateien werden nicht versioniert. Das Manifest
|
|
# rinkplanner/assets/asset_manifest.json beschreibt Quelle, Ziel, Hash und
|
|
# Metadaten. Nach dem Kopieren wird der Godot-Import angestoßen.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
PROJECT_DIR="$REPO_ROOT/rinkplanner"
|
|
MANIFEST="$PROJECT_DIR/assets/asset_manifest.json"
|
|
WORKBENCH="${RINKPLANNER_WORKBENCH:-$HOME/Documents/workbench_rinkplanner}"
|
|
GODOT="${GODOT:-/opt/godot/Godot_v4.7.2-stable_linux.x86_64}"
|
|
|
|
MODE="check"
|
|
FORCE=0
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Aufruf: tools/sync_assets.sh [--check|--sync] [--force]
|
|
|
|
--check Prüft nur, ob die Ziele vorhanden und hashes korrekt sind (Standard).
|
|
--sync Kopiert fehlende Assets und importiert sie in Godot.
|
|
--force Überschreibt vorhandene Ziele mit abweichendem Hash (nur mit --sync).
|
|
|
|
Umgebung:
|
|
RINKPLANNER_WORKBENCH Pfad zum Workbench-Archiv
|
|
(Standard: ~/Documents/workbench_rinkplanner)
|
|
GODOT Godot-Binary für den Import
|
|
EOF
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--check) MODE="check" ;;
|
|
--sync) MODE="sync" ;;
|
|
--force) FORCE=1 ;;
|
|
-h|--help) usage; exit 0 ;;
|
|
*) echo "Unbekannte Option: $1" >&2; usage >&2; exit 2 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [[ ! -f "$MANIFEST" ]]; then
|
|
echo "Manifest nicht gefunden: $MANIFEST" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$FORCE" -eq 1 && "$MODE" != "sync" ]]; then
|
|
echo "--force ist nur zusammen mit --sync sinnvoll." >&2
|
|
exit 2
|
|
fi
|
|
|
|
mapfile -t rows < <(python3 - "$MANIFEST" <<'PY'
|
|
import json
|
|
import sys
|
|
|
|
with open(sys.argv[1], encoding="utf-8") as handle:
|
|
document = json.load(handle)
|
|
|
|
for asset in document.get("assets", []):
|
|
print("\t".join([
|
|
asset["id"],
|
|
asset["source"],
|
|
asset["target"],
|
|
asset["sha256"],
|
|
str(asset["bytes"]),
|
|
]))
|
|
PY
|
|
)
|
|
|
|
if [[ ${#rows[@]} -eq 0 ]]; then
|
|
echo "Keine Assets im Manifest." >&2
|
|
exit 1
|
|
fi
|
|
|
|
problems=0
|
|
copied=0
|
|
|
|
check_asset() {
|
|
local source_path="$1"
|
|
local target_path="$2"
|
|
local expected_sha="$3"
|
|
local expected_bytes="$4"
|
|
|
|
if [[ ! -f "$source_path" ]]; then
|
|
echo " FEHLT (Quelle): $source_path" >&2
|
|
return 1
|
|
fi
|
|
|
|
local actual_bytes actual_sha
|
|
actual_bytes="$(stat -c '%s' "$source_path")"
|
|
actual_sha="$(sha256sum "$source_path" | cut -d' ' -f1)"
|
|
if [[ "$actual_bytes" != "$expected_bytes" || "$actual_sha" != "$expected_sha" ]]; then
|
|
echo " HASH-FEHLER (Quelle): $source_path" >&2
|
|
echo " erwartet: $expected_bytes Bytes / $expected_sha" >&2
|
|
echo " gefunden: $actual_bytes Bytes / $actual_sha" >&2
|
|
return 1
|
|
fi
|
|
|
|
if [[ ! -f "$target_path" ]]; then
|
|
echo " FEHLT (Ziel): $target_path" >&2
|
|
return 1
|
|
fi
|
|
|
|
actual_bytes="$(stat -c '%s' "$target_path")"
|
|
actual_sha="$(sha256sum "$target_path" | cut -d' ' -f1)"
|
|
if [[ "$actual_bytes" != "$expected_bytes" || "$actual_sha" != "$expected_sha" ]]; then
|
|
echo " HASH-FEHLER (Ziel): $target_path" >&2
|
|
echo " erwartet: $expected_bytes Bytes / $expected_sha" >&2
|
|
echo " gefunden: $actual_bytes Bytes / $actual_sha" >&2
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
for row in "${rows[@]}"; do
|
|
IFS=$'\t' read -r asset_id relative_source relative_target expected_sha expected_bytes <<< "$row"
|
|
source_path="$WORKBENCH/$relative_source"
|
|
target_path="$PROJECT_DIR/$relative_target"
|
|
|
|
echo "[$asset_id]"
|
|
|
|
if [[ "$MODE" == "check" ]]; then
|
|
if check_asset "$source_path" "$target_path" "$expected_sha" "$expected_bytes"; then
|
|
echo " OK"
|
|
else
|
|
problems=$((problems + 1))
|
|
fi
|
|
continue
|
|
fi
|
|
|
|
if [[ ! -f "$source_path" ]]; then
|
|
echo " FEHLT (Quelle): $source_path" >&2
|
|
problems=$((problems + 1))
|
|
continue
|
|
fi
|
|
|
|
source_bytes="$(stat -c '%s' "$source_path")"
|
|
source_sha="$(sha256sum "$source_path" | cut -d' ' -f1)"
|
|
if [[ "$source_bytes" != "$expected_bytes" || "$source_sha" != "$expected_sha" ]]; then
|
|
echo " HASH-FEHLER (Quelle): $source_path" >&2
|
|
echo " Manifest und Workbench-Datei passen nicht zusammen." >&2
|
|
problems=$((problems + 1))
|
|
continue
|
|
fi
|
|
|
|
if [[ -f "$target_path" ]]; then
|
|
target_sha="$(sha256sum "$target_path" | cut -d' ' -f1)"
|
|
if [[ "$target_sha" == "$expected_sha" ]]; then
|
|
echo " OK (bereits synchronisiert)"
|
|
continue
|
|
fi
|
|
if [[ "$FORCE" -ne 1 ]]; then
|
|
echo " ABWEICHUNG: $target_path" >&2
|
|
echo " Ziel hat einen anderen Hash. Mit --force überschreiben." >&2
|
|
problems=$((problems + 1))
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
mkdir -p "$(dirname "$target_path")"
|
|
cp "$source_path" "$target_path"
|
|
target_sha="$(sha256sum "$target_path" | cut -d' ' -f1)"
|
|
if [[ "$target_sha" != "$expected_sha" ]]; then
|
|
echo " KOPIERFEHLER: $target_path" >&2
|
|
problems=$((problems + 1))
|
|
continue
|
|
fi
|
|
|
|
echo " Kopiert: $relative_target"
|
|
copied=$((copied + 1))
|
|
done
|
|
|
|
if [[ "$problems" -gt 0 ]]; then
|
|
echo "" >&2
|
|
echo "$problems Asset(s) nicht in Ordnung." >&2
|
|
if [[ "$MODE" == "check" ]]; then
|
|
echo "Mit tools/sync_assets.sh --sync kopieren." >&2
|
|
fi
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$MODE" == "sync" && "$copied" -gt 0 ]]; then
|
|
if [[ -x "$GODOT" ]]; then
|
|
echo "Godot-Import..."
|
|
"$GODOT" --headless --path "$PROJECT_DIR" --import >/dev/null
|
|
else
|
|
echo "Godot-Binary nicht gefunden: $GODOT" >&2
|
|
echo "Assets liegen bereit, Import bitte manuell anstoßen." >&2
|
|
fi
|
|
fi
|
|
|
|
echo "Assets OK."
|