Created
June 27, 2025 20:52
-
-
Save vic1707/4b1541384dbbb71575fa42de07fde31c to your computer and use it in GitHub Desktop.
wiitool.bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IMAGE_NAME="localhost/wiittool" | |
CONTAINERFILE_CONTENT=' | |
FROM debian:bullseye-slim AS builder | |
RUN apt-get update && \ | |
apt-get install -y git build-essential libncurses-dev | |
RUN git clone https://github.com/Wiimm/wiimms-iso-tools.git /wit | |
WORKDIR /wit/project/ | |
RUN make STATIC=1 SYSTEM_LINUX=1 | |
FROM scratch AS export | |
COPY --from=builder /wit/project/bin/w* / | |
' | |
# Check if image exists, build if missing | |
ensure_image() { | |
if ! podman image exists "$IMAGE_NAME"; then | |
echo ">> Image $IMAGE_NAME not found. Building..." | |
echo "$CONTAINERFILE_CONTENT" | podman build -t "$IMAGE_NAME" -f - | |
podman image prune -f | |
echo ">> Build complete." | |
else | |
echo ">> Image already exists." | |
fi | |
} | |
wiittool() { | |
ensure_image | |
local tool="$1" | |
shift | |
podman run --rm -v "$PWD":/data -w /data "$IMAGE_NAME" "/${tool}" "$@" | |
} | |
wiittool "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment