-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild
More file actions
executable file
·112 lines (98 loc) · 2.7 KB
/
build
File metadata and controls
executable file
·112 lines (98 loc) · 2.7 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
#!/usr/bin/env bash
set -eufo pipefail
container_image=localhost/builder
container_engine=podman
target_dir=.build
container_run_opts=(
--security-opt seccomp=unconfined
--security-opt apparmor=unconfined
--security-opt label=disable
--read-only
)
use_kms=0
resolve_cname=0
while [ $# -gt 0 ]; do
case "$1" in
--container-image)
container_image="$2"
shift 2
;;
--container-engine)
container_engine="$2"
shift 2
;;
--container-run-opts)
declare -a "container_run_opts=($2)"
shift 2
;;
--kms)
use_kms=1
shift
;;
--print-container-image)
printf '%s\n' "$container_image"
exit 0
;;
--resolve-cname)
resolve_cname=1
shift
;;
--target)
target_dir="$2"
shift 2
;;
*)
break
;;
esac
done
container_mount_opts=(
-v "$PWD/features:/builder/features:ro"
-v "$PWD/keyring.gpg:/builder/keyring.gpg:ro"
-v "$PWD/$target_dir:/builder/.build"
)
if [ "$container_image" = localhost/builder ]; then
dir="$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")"
"$container_engine" build -t "$container_image" "$dir"
fi
[ -e get_repo ] && repo="$(./get_repo)" || repo="http://deb.debian.org/debian"
if [ -e get_commit ]
then
commit="$(./get_commit)"
else
pushd $(dirname "${BASH_SOURCE[0]}")
if [ -z "$(git status --porcelain 2> /dev/null)" ]
then
commit=$(git rev-parse HEAD 2> /dev/null)
else
commit="local"
fi
popd
fi
[ -e get_timestamp ] && timestamp="$(./get_timestamp)" || timestamp="0"
[ -e get_version ] && default_version="$(./get_version)" || default_version="bookworm"
[ -d $target_dir ] || mkdir $target_dir
if [ "$resolve_cname" = 1 ]; then
arch="$("$container_engine" run --rm "${container_run_opts[@]}" "${container_mount_opts[@]}" "$container_image" dpkg --print-architecture)"
cname="$("$container_engine" run --rm "${container_run_opts[@]}" "${container_mount_opts[@]}" "$container_image" /builder/parse_features --feature-dir /builder/features --default-arch "$arch" --default-version "$default_version" --cname "$1")"
short_commit="$(head -c 8 <<< "$commit")"
echo "$cname-$short_commit"
exit 0
fi
make_opts=(
REPO="$repo"
COMMIT="$commit"
TIMESTAMP="$timestamp"
DEFAULT_VERSION="$default_version"
)
if [ "$use_kms" = 1 ]; then
for e in AWS_DEFAULT_REGION AWS_REGION AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN; do
if [ -n "${!e-}" ]; then
make_opts+=("$e=${!e}")
fi
done
fi
if [ -d cert ]; then
container_mount_opts+=(-v "$PWD/cert:/builder/cert:ro")
fi
"$container_engine" run --rm "${container_run_opts[@]}" "${container_mount_opts[@]}" "$container_image" make --no-print-directory -C /builder "${make_opts[@]}" "$@"