-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·45 lines (39 loc) · 1.06 KB
/
build.sh
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
#!/usr/bin/env bash
set -euo pipefail
first_valid_command () {
while (($# > 0)); do
if command -v "$1" &> /dev/null; then
printf "%s" "$1"
return 0
fi
shift
done
return 1
}
if ! ENGINE="$(first_valid_command podman docker)"; then
echo "Failed to find 'podman' or 'docker' command" 1>&2
exit 1
fi
BIN_DIR="$1"
# These shouldn't matter much since we're building a script only package
SDK_TAG="${2:-"mips_24kc-23.05.0"}"
SDK_REPO="${3:-"docker.io/openwrt/sdk"}"
build () {
local temp_dir="$1"
"$ENGINE" run --rm -u root \
-v .:/builder/package/slppsk-hostapd \
-v "$temp_dir":/builder/bin/ \
-ti "$SDK_REPO":"$SDK_TAG" \
bash -c 'make defconfig
make package/slppsk-hostapd/compile -j$(nproc)'
cp "$temp_dir"/packages/*/base/slppsk-hostapd_*_all.ipk "$BIN_DIR"
}
with_temp_dir () {
local temp_dir ret=0 cmd="$1"
shift
temp_dir="$(mktemp -d)"
"$cmd" "$temp_dir" "$@" || ret=$?
rm -rf "$temp_dir"
return $ret
}
with_temp_dir build