Repository navigation
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·151 lines (133 loc) · 4.02 KB
/
Copy pathcompile.sh
File metadata and controls
executable file
·151 lines (133 loc) · 4.02 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${ROOT_DIR}/build/linux-usb-console"
OUT_DIR="${ROOT_DIR}/build/output"
DOCKER_IMAGE="wing-usb-console-builder:trixie"
DOCKER_CONFIG_DIR="${BUILD_DIR}/docker-config"
if [[ -n "${DOCKER_HOST:-}" ]]; then
DOCKER_HOST_URI="${DOCKER_HOST}"
elif [[ -S "${HOME}/.docker/run/docker.sock" ]]; then
DOCKER_HOST_URI="unix://${HOME}/.docker/run/docker.sock"
else
DOCKER_HOST_URI="unix:///var/run/docker.sock"
fi
LINUX_VER="6.6.30"
BUSYBOX_VER="1.38.0"
DROPBEAR_VER="2026.91"
DOOMGENERIC_REF="master"
HTOP_VER="3.3.0"
INCLUDE_DOOM="${INCLUDE_DOOM:-}"
UBOOT_IMX="${OUT_DIR}/u-boot-linux.imx"
OUTPUT_WINGFW="${OUT_DIR}/wing-compact-usb-console-linux.wingfw"
OMC_DIR="${ROOT_DIR}/software/omc"
OMC_BIN="${OMC_DIR}/build/wing/omc"
OMC_STAMP="${OMC_DIR}/build/wing/.wing-omc.inputs.sha256"
hash_file() {
local digest
if command -v sha256sum >/dev/null 2>&1; then
digest="$(sha256sum "$1")"
else
digest="$(shasum -a 256 "$1")"
fi
printf '%s\n' "${digest%% *}"
}
hash_stream() {
local digest
if command -v sha256sum >/dev/null 2>&1; then
digest="$(sha256sum)"
else
digest="$(shasum -a 256)"
fi
printf '%s\n' "${digest%% *}"
}
omc_input_signature() {
(
cd "${OMC_DIR}"
{
printf '%s\n' "Makefile"
printf '%s\n' "compile-docker.sh"
find src lib files -type f -print
} | LC_ALL=C sort | while IFS= read -r input_path; do
if [[ -f "${input_path}" ]]; then
printf '%s\n' "${input_path}"
hash_file "${input_path}"
fi
done
) | hash_stream
}
build_omc_if_needed() {
local current_signature previous_signature
current_signature="$(omc_input_signature)"
previous_signature=""
if [[ -f "${OMC_STAMP}" ]]; then
previous_signature="$(<"${OMC_STAMP}")"
fi
if [[ -f "${OMC_BIN}" && "${current_signature}" == "${previous_signature}" ]]; then
echo "[build] omc (wing target): unchanged, skipping compilation"
return
fi
echo "[build] omc (wing target)"
"${OMC_DIR}/compile-docker.sh" TARGET_WING
if [[ ! -f "${OMC_BIN}" ]]; then
echo "[error] omc build did not produce ${OMC_BIN}" >&2
exit 1
fi
mkdir -p "$(dirname "${OMC_STAMP}")"
printf '%s\n' "${current_signature}" > "${OMC_STAMP}"
}
mkdir -p "${BUILD_DIR}" "${OUT_DIR}" "${DOCKER_CONFIG_DIR}"
DOCKER_CONFIG="${DOCKER_CONFIG_DIR}" DOCKER_HOST="${DOCKER_HOST_URI}" DOCKER_BUILDKIT=0 \
docker build -t "${DOCKER_IMAGE}" - <<'DOCKERFILE'
FROM debian:trixie
ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg --add-architecture armhf \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bc \
bison \
bzip2 \
ca-certificates \
cpio \
curl \
device-tree-compiler \
flex \
gcc \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
libc6-dev \
libc6-dev-armhf-cross \
libcrypt-dev:armhf \
libncurses-dev:armhf \
libncurses-dev \
ncurses-dev:armhf \
ncurses-dev \
libssl-dev \
make \
patch \
pkg-config \
python3 \
u-boot-tools \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
DOCKERFILE
build_omc_if_needed
DOCKER_CONFIG="${DOCKER_CONFIG_DIR}" DOCKER_HOST="${DOCKER_HOST_URI}" \
docker run --rm \
-it \
-u "$(id -u):$(id -g)" \
-v "${ROOT_DIR}:/openwing" \
-w "/openwing" \
-e ROOT_DIR="/openwing" \
-e BUILD_DIR="/openwing/build/linux-usb-console" \
-e OUT_DIR="/openwing/build/output" \
-e LINUX_VER="${LINUX_VER}" \
-e BUSYBOX_VER="${BUSYBOX_VER}" \
-e DROPBEAR_VER="${DROPBEAR_VER}" \
-e DOOMGENERIC_REF="${DOOMGENERIC_REF}" \
-e INCLUDE_DOOM="${INCLUDE_DOOM}" \
-e HTOP_VER="${HTOP_VER}" \
-e UBOOT_IMX="/openwing/build/output/u-boot-linux.imx" \
-e OUTPUT_WINGFW="/openwing/build/output/wing-compact-usb-console-linux.wingfw" \
"${DOCKER_IMAGE}" \
./compile_step2.sh $@ # $@ -> pass all commandlinearguments to compile step 2