blob: bd23ccfe017ccf9e194daf8c7aa5b3768ffb85c5 (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#!/usr/bin/env bash
set -euo pipefail
# Build Fluorine Manager using Docker.
#
# Usage:
# ./build.sh # Build portable .tar.gz (default)
# ./build.sh tarball # Build portable .tar.gz only
# ./build.sh installer # Build self-extracting .bin installer only
# ./build.sh all # Build tarball + installer
# ./build.sh shell # Drop into the build container for debugging
#
# Prerequisites: Docker or Podman
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Auto-detect container runtime
if command -v podman >/dev/null 2>&1; then
DOCKER=podman
elif command -v docker >/dev/null 2>&1; then
DOCKER=docker
else
echo "ERROR: Neither podman nor docker found in PATH"
exit 1
fi
IMAGE_NAME="fluorine-builder"
CONTAINER_NAME="fluorine-build-$$"
cd "${SCRIPT_DIR}"
# Determine build mode from first argument
BUILD_MODE="${1:-tarball}"
case "${BUILD_MODE}" in
tarball|installer|all|shell) ;;
*)
echo "Usage: ./build.sh [tarball|installer|all|shell]"
echo ""
echo " tarball Build portable .tar.gz"
echo " installer Build self-extracting .bin installer"
echo " all Build tarball + installer"
echo " shell Drop into build container"
exit 1
;;
esac
echo "=== Ensuring build image is up to date ==="
${DOCKER} build -t "${IMAGE_NAME}" docker/
# Persistent ccache directory for faster rebuilds.
CCACHE_DIR="${HOME}/.cache/fluorine-ccache"
mkdir -p "${CCACHE_DIR}"
if [ "${BUILD_MODE}" = "shell" ]; then
echo "=== Dropping into build container shell ==="
exec ${DOCKER} run --rm -it \
-v "${SCRIPT_DIR}:/src:rw" \
-v "${CCACHE_DIR}:/ccache:rw" \
-e CCACHE_DIR=/ccache \
-w /src \
--device /dev/fuse \
--cap-add SYS_ADMIN \
"${IMAGE_NAME}" \
bash
fi
echo "=== Starting build (mode: ${BUILD_MODE}) ==="
# BUILD_JOBS controls parallelism (override with `BUILD_JOBS=N ./build.sh`).
# Defaults to all available cores.
BUILD_JOBS="${BUILD_JOBS:-$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)}"
${DOCKER} run --rm \
-v "${SCRIPT_DIR}:/src:rw" \
-v "${CCACHE_DIR}:/ccache:rw" \
-e CCACHE_DIR=/ccache \
-e BUILD_MODE="${BUILD_MODE}" \
-e BUILD_JOBS="${BUILD_JOBS}" \
-w /src \
--device /dev/fuse \
--cap-add SYS_ADMIN \
--name "${CONTAINER_NAME}" \
"${IMAGE_NAME}" \
bash /src/docker/build-inner.sh
echo ""
echo "=== Done ==="
echo "Build outputs:"
ls -ldh build/fluorine-manager build/fluorine-manager.bin 2>/dev/null || echo " (none found)"
echo "Staging: build/staging/"
|