diff --git a/build.sh b/build.sh index e23b80c..f6eb101 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ set -euo pipefail URL="https://proxy.dandaedre.com/gitea/Ravenous/podman_ravenous" CONTAINER_IMAGE=${CONTAINER_IMAGE:-localhost/ravenous-podman:latest} +RAW=false # will be set to true when --raw is requested print_error() { echo "Error: $1" >&2 @@ -11,22 +12,6 @@ print_error() { 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 # ------------------------------------------------------------------ @@ -48,8 +33,11 @@ Modes: balance – show all the balancing data full – rerun a full build +Additional option: + raw – execute commands directly on the host using ravenous-tools instead of a Podman container + Everything that follows the mode is forwarded verbatim to `make` inside -the container. +the container (or run directly when --raw is used). HELP exit 0 ;; @@ -77,6 +65,11 @@ HELP MODE=balance shift ;; + --raw|raw) # raw mode: use ravenous-tools instead of a container + RAW=true + shift + ;; + *) # All remaining arguments are passed straight to `make` MAKE_ARGS+=("$@") @@ -84,12 +77,42 @@ HELP ;; esac done +# ------------------------------------------------------------------ +# Prerequisites Check +# ------------------------------------------------------------------ + +if [ "$RAW" = true ]; then + if ! command -v ravenous-tools >/dev/null 2>&1; then + echo "Error: ravenous-tools is not installed." >&2 + echo "Please install it or run without --raw." >&2 + exit 1 + fi +else + 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 +fi + +echo "--- Prerequisites met ---" # ------------------------------------------------------------------ # 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 + if [ "$RAW" = true ]; then + # In raw mode simply execute the command as it is. + ravenous-tools "$@" + return $? + fi + # Forward all podman flags (e.g., --no-cache) that the caller might want local PODMAN_OPTS=() while [[ $# -gt 0 ]]; do