-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker.sh
More file actions
executable file
·40 lines (36 loc) · 1.37 KB
/
Copy pathdocker.sh
File metadata and controls
executable file
·40 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
# Build AmiPart using the Bebbo amiga-gcc toolchain via Docker.
#
# Usage:
# ./docker.sh # build (forwards to: make TOOLCHAIN=bebbo)
# ./docker.sh clean # clean
# ./docker.sh <make-args> # any extra args are forwarded to make
#
# Environment overrides:
# IMAGE=... docker image (default: trixitron/m68k-amigaos-gcc)
# AMIGA=... toolchain path inside the container (default: /opt/amiga)
set -euo pipefail
IMAGE=${IMAGE:-trixitron/m68k-amigaos-gcc}
AMIGA=${AMIGA:-/opt/amiga}
TTY_ARG=()
[ -t 0 ] && [ -t 1 ] && TTY_ARG=(-it)
# Run as root inside the container — the trixitron image has its NDK headers
# locked to root (-rw------- root:root). Docker Desktop on macOS/Windows
# handles host-user ownership mapping automatically. On Linux, the bind-mount
# preserves container ownership, so chown build artifacts back at the end.
if [ "$(uname -s)" = "Linux" ]; then
INNER='make TOOLCHAIN=bebbo AMIGA="$AMIGA" "$@"; rc=$?; chown -R "$CHOWN_TO" /work; exit $rc'
exec docker run --rm "${TTY_ARG[@]}" \
-e "AMIGA=$AMIGA" \
-e "CHOWN_TO=$(id -u):$(id -g)" \
-v "$PWD":/work \
-w /work \
"$IMAGE" \
bash -c "$INNER" bash "$@"
else
exec docker run --rm "${TTY_ARG[@]}" \
-v "$PWD":/work \
-w /work \
"$IMAGE" \
make TOOLCHAIN=bebbo AMIGA="$AMIGA" "$@"
fi