182 lines
4.6 KiB
Bash
Executable File
182 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# ------------------------------------------------------------------
|
||
# Build wrapper that runs the “Ravenous” container image with Podman.
|
||
#
|
||
# Usage:
|
||
# ./build.sh [--help | <mode>] [make‑options …]
|
||
#
|
||
# Modes
|
||
# simple (default) – just run `make -N Ravenous.tex`
|
||
# full – run all the steps in the original script
|
||
#
|
||
# The remaining arguments after the mode are forwarded verbatim to
|
||
# the `make` command inside the container.
|
||
#
|
||
# Example:
|
||
# ./build.sh full --verbose clean
|
||
# ------------------------------------------------------------------
|
||
|
||
set -euo pipefail
|
||
|
||
URL="https://proxy.dandaedre.com/gitea/Ravenous/podman_ravenous"
|
||
CONTAINER_IMAGE=${CONTAINER_IMAGE:-localhost/ravenous-podman:latest}
|
||
|
||
print_error() {
|
||
echo "Error: $1" >&2
|
||
echo "Please check the setup at:" >&2
|
||
echo "$URL" >&2
|
||
}
|
||
|
||
# ------------------------------------------------------------------
|
||
# Prerequisites Check
|
||
# ------------------------------------------------------------------
|
||
|
||
if ! command -v podman >/dev/null 2>&1; then
|
||
print_error "Podman is not installed."
|
||
exit 1
|
||
fi
|
||
|
||
if ! podman image inspect "$CONTAINER_IMAGE" > /dev/null 2>&1; then
|
||
print_error "Container image '$CONTAINER_IMAGE' is not installed."
|
||
exit 1
|
||
fi
|
||
|
||
echo "--- Prerequisites met ---"
|
||
|
||
# ------------------------------------------------------------------
|
||
# Argument parsing – first positional arg can be a mode or --help
|
||
# ------------------------------------------------------------------
|
||
|
||
MODE=simple # default mode
|
||
MAKE_ARGS=() # everything that ends up in the `make` call
|
||
|
||
while [[ $# -gt 0 ]]; do
|
||
case $1 in
|
||
--help)
|
||
cat <<'HELP'
|
||
Usage: ./build.sh [--help | <mode>] [make-options …]
|
||
|
||
Modes:
|
||
simple (default) – run a minimal build
|
||
clean – clean all build artifacts
|
||
player – build the player handbook
|
||
full – rerun a full build
|
||
|
||
Everything that follows the mode is forwarded verbatim to `make` inside
|
||
the container.
|
||
HELP
|
||
exit 0
|
||
;;
|
||
--full|full)
|
||
MODE=full
|
||
shift
|
||
;;
|
||
--player|player)
|
||
MODE=player
|
||
shift
|
||
;;
|
||
--clean|clean)
|
||
MODE=clean
|
||
shift
|
||
;;
|
||
*)
|
||
# All remaining arguments are passed straight to `make`
|
||
MAKE_ARGS+=("$@")
|
||
break
|
||
;;
|
||
esac
|
||
done
|
||
|
||
# ------------------------------------------------------------------
|
||
# Helper: run a command inside the container with podman and exit on error
|
||
# ------------------------------------------------------------------
|
||
|
||
run_podman() {
|
||
# Forward all podman flags (e.g., --no-cache) that the caller might want
|
||
local PODMAN_OPTS=()
|
||
while [[ $# -gt 0 ]]; do
|
||
case $1 in
|
||
--* )
|
||
PODMAN_OPTS+=("$1")
|
||
shift
|
||
;;
|
||
*)
|
||
break
|
||
;;
|
||
esac
|
||
done
|
||
|
||
podman run \
|
||
"${PODMAN_OPTS[@]}" \
|
||
--rm \
|
||
--tty \
|
||
-v "$(pwd)":/workspace \
|
||
"$CONTAINER_IMAGE" \
|
||
"$@"
|
||
}
|
||
|
||
# ------------------------------------------------------------------
|
||
# Build Logic Selection
|
||
# ------------------------------------------------------------------
|
||
|
||
case "$MODE" in
|
||
full)
|
||
echo ">>> Executing FULL build sequence (with args: ${MAKE_ARGS[@]})..."
|
||
|
||
run_podman tablegen -e all
|
||
|
||
mkdir -p ~/.local/share/fonts/
|
||
mkdir -p ./Images/Radar/
|
||
|
||
cp ./Ressources/lmroman8-regular.ttf ~/.local/share/fonts/
|
||
|
||
run_podman graphs load
|
||
run_podman graphs generate
|
||
|
||
# Pass user supplied make arguments *before* the target so that options
|
||
# or custom targets still work.
|
||
run_podman make "${MAKE_ARGS[@]}" -N Player_handbook.tex
|
||
run_podman make -t glossaries -N Player_handbook.tex
|
||
run_podman make "${MAKE_ARGS[@]}" -N Player_handbook.tex
|
||
|
||
run_podman make "${MAKE_ARGS[@]}" -N Ravenous.tex
|
||
run_podman make -t glossaries -N Ravenous.tex
|
||
run_podman make "${MAKE_ARGS[@]}" -N Ravenous.tex
|
||
|
||
;;
|
||
|
||
player)
|
||
|
||
echo ">>> Executing PLAYER build (with args: ${MAKE_ARGS[@]})..."
|
||
|
||
run_podman make "${MAKE_ARGS[@]}" -N Player_handbook.tex || exit $?
|
||
|
||
echo "--- Build Completed Successfully ---"
|
||
;;
|
||
clean)
|
||
|
||
echo ">>> Cleaning up directory..."
|
||
|
||
run_podman make -t clean Player_handbook.tex || exit $?
|
||
run_podman make -t clean Ravenous_build.tex || exit $?
|
||
run_podman graphs remove || exit $?
|
||
rm -f ./Ravenous_build.* ./Player_handbook_build.*
|
||
|
||
echo "--- Cleanup Completed Successfully ---"
|
||
;;
|
||
simple)
|
||
echo ">>> Executing SIMPLE build (with args: ${MAKE_ARGS[@]})..."
|
||
|
||
run_podman make "${MAKE_ARGS[@]}" -N Ravenous.tex || exit $?
|
||
|
||
echo "--- Build Completed Successfully ---"
|
||
;;
|
||
|
||
*)
|
||
print_error "Unknown mode: $MODE"
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
exit 0
|