#!/usr/bin/env bash # Build the boxsim image, staging the Visaton library and parts catalogue. # # Both live outside this repository, so they are copied into a staging directory # inside the build context first. Nothing proprietary is baked in: the Visaton # library is our own, and the catalogue is a plain text parts list. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" LIB_DIR="${BOXSIM_KICAD_LIB_DIR:-/home/magdev/workspaces/other/kicad-visaton-lib}" CATALOG="${BOXSIM_CATALOG:-$ROOT/boxsim_dl/BoxSim 2.1 DE (Stand 12.2025)/Weichenbauteile/Visatonteile.txt}" IMAGE="${IMAGE:-boxsim:0.1.0}" SYM="$LIB_DIR/symbols/Visaton.kicad_sym" FP="$LIB_DIR/footprints/Visaton.pretty" # A missing input must stop the build, never silently produce an image without # its library. for path in "$SYM" "$FP" "$CATALOG"; do if [[ ! -e "$path" ]]; then echo "build-image: required input missing: $path" >&2 exit 1 fi done # The library must already be in the current KiCad format, otherwise the symbols # cannot be embedded into a KiCad 10 schematic. version="$(sed -n 's/.*(version \([0-9]\+\)).*/\1/p' "$SYM" | head -1)" if [[ -z "$version" || "$version" -lt 20211014 ]]; then echo "build-image: $SYM is in the legacy format (version ${version:-none})." >&2 echo " Run: kicad-cli sym upgrade --force '$SYM'" >&2 exit 1 fi rm -rf stage mkdir -p stage cp "$SYM" stage/Visaton.kicad_sym cp "$CATALOG" stage/Visatonteile.txt cp -r "$FP" stage/footprints echo "staged: symbol library (version $version), catalogue, $(ls stage/footprints | wc -l) footprints" docker build -t "$IMAGE" . rm -rf stage echo "built $IMAGE"