-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild
executable file
·80 lines (71 loc) · 1.7 KB
/
build
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
#!/usr/bin/env bash
set -exufo pipefail
src_dir="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
container=
arch=amd64
skip_source=
skip_binary=
build=binary
build_dep_dir=
gl_package_build_debug=
while [ $# -gt 0 ]; do
case "$1" in
--container)
container="$2"
shift 2
;;
--arch)
arch="$2"
shift 2
;;
--source-only)
skip_binary=true
shift
;;
--binary-only)
skip_source=true
shift
;;
--build)
build="$2"
shift 2
;;
--build-dependencies)
build_dep_dir="$(realpath "$2")"
shift 2
;;
--debug)
gl_package_build_debug=true
shift
;;
*)
break
;;
esac
done
dir="$(realpath "$1")"
if [ -z "$container" ]; then
if [ -e "$dir/.container" ]; then
container="$(cat "$dir/.container")"
else
container=ghcr.io/gardenlinux/repo-debian-snapshot
fi
fi
mount_opts=(
-v "$src_dir/bin:/opt/package_build/bin"
-v "$dir:/opt/package_build/workdir"
)
if [ -n "$build_dep_dir" ]; then
mount_opts+=(-v "$build_dep_dir:/opt/package_build/workdir/build_dep")
fi
if [ -z "$skip_source" ]; then
if [ -z "$gl_package_build_debug" ]; then
podman run --security-opt seccomp=unconfined --arch "$arch" --rm "${mount_opts[@]}" -w "/opt/package_build/workdir" "$container" /opt/package_build/bin/source
else
echo "Starting package build container without --rm"
podman run --security-opt seccomp=unconfined --arch "$arch" "${mount_opts[@]}" -w "/opt/package_build/workdir" -e gl_package_build_debug=true "$container" /opt/package_build/bin/source
fi
fi
if [ -z "$skip_binary" ]; then
podman run --security-opt seccomp=unconfined --arch "$arch" --rm "${mount_opts[@]}" -w "/opt/package_build/workdir" "$container" /opt/package_build/bin/binary "$build"
fi