-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdocker-build-package
executable file
·202 lines (179 loc) · 5.93 KB
/
docker-build-package
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
#
# Copyright 2023 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
IMAGE_NAME_PREFIX=registry.gitlab.com/northern.tech/mender/mender-test-containers:mender-dist-packages-builder
declare -A mender_client_props=(
[recipe_name]="mender-client"
[src_url]="https://github.com/mendersoftware/mender"
[arch_indep]="false"
[commercial]="false"
)
declare -A mender_client4_props=(
[recipe_name]="mender-client4"
[src_url]="https://github.com/mendersoftware/mender"
[arch_indep]="false"
[commercial]="false"
)
declare -A mender_connect_props=(
[recipe_name]="mender-connect"
[src_url]="https://github.com/mendersoftware/mender-connect"
[arch_indep]="false"
[commercial]="false"
)
declare -A mender_configure_props=(
[recipe_name]="mender-configure"
[src_url]="https://github.com/mendersoftware/mender-configure-module"
[arch_indep]="true"
[commercial]="false"
)
declare -A mender_artifact_props=(
[recipe_name]="mender-artifact"
[src_url]="https://github.com/mendersoftware/mender-artifact"
[arch_indep]="false"
[commercial]="false"
)
declare -A mender_flash_props=(
[recipe_name]="mender-flash"
[src_url]="https://github.com/mendersoftware/mender-flash"
[arch_indep]="false"
[commercial]="false"
)
declare -A mender_monitor_props=(
[recipe_name]="mender-monitor"
[src_url]="https://${MENDER_PRIVATE_REPO_ACCESS_USER}:${MENDER_PRIVATE_REPO_ACCESS_TOKEN}@github.com/mendersoftware/monitor-client"
[arch_indep]="true"
[commercial]="true"
)
declare -A mender_gateway_props=(
[recipe_name]="mender-gateway"
[src_url]="https://${MENDER_PRIVATE_REPO_ACCESS_USER}:${MENDER_PRIVATE_REPO_ACCESS_TOKEN}@github.com/mendersoftware/mender-gateway"
[arch_indep]="false"
[commercial]="true"
)
declare -A mender_app_update_module_props=(
[recipe_name]="mender-app-update-module"
[src_url]="https://github.com/mendersoftware/app-update-module"
[arch_indep]="true"
[commercial]="false"
)
declare -A mender_setup_props=(
[recipe_name]="mender-setup"
[src_url]="https://github.com/mendersoftware/mender-setup"
[arch_indep]="false"
[commercial]="false"
)
declare -A mender_snapshot_props=(
[recipe_name]="mender-snapshot"
[src_url]="https://github.com/mendersoftware/mender-snapshot"
[arch_indep]="false"
[commercial]="false"
)
declare -a packages=(
mender_client_props
mender_client4_props
mender_connect_props
mender_configure_props
mender_artifact_props
mender_flash_props
mender_gateway_props
mender_monitor_props
mender_app_update_module_props
mender_setup_props
mender_snapshot_props
)
# Parse args
if [ $# -lt 5 ]; then
echo "usage: $0 build distro release arch package [version]"
exit 1
fi
BUILD="${1}"
DISTRO="${2}"
RELEASE="${3}"
ARCH="${4}"
RECIPE_NAME="${5}"
RECIPE_VERSION="${6:-master}"
SAVE_ORIG="$7"
# Look for the recipe
recipe_found=0
for recipe in "${packages[@]}"; do
recipe_name=$(eval echo \${$recipe[recipe_name]})
if [ "$recipe_name" = "$RECIPE_NAME" ]; then
recipe_found=1
src_url=$(eval echo \${$recipe[src_url]})
arch_indep=$(eval echo \${$recipe[arch_indep]})
commercial=$(eval echo \${$recipe[commercial]})
break
fi
done
if [ $recipe_found -eq 0 ]; then
echo "unrecognized package $RECIPE_NAME, supported are: $(for recipe in "${packages[@]}"; do echo -n "$(eval echo \${$recipe[recipe_name]}) "; done)"
exit 1
fi
# Extra check for commercial recipes
if [ $commercial = "true" -a -z "${MENDER_PRIVATE_REPO_ACCESS_TOKEN}" ]; then
echo "recipe $recipe_name requires MENDER_PRIVATE_REPO_ACCESS_TOKEN"
exit 1
fi
if [ "$arch_indep" = "true" -a "$ARCH" != "amd64" ]; then
# Architecture independent packages are built only on amd64 build host
echo "Not building arch independent package $recipe_name on architecture $ARCH"
exit 0
fi
echo "Building $recipe_name with arguments: $*"
output_dir="output/opensource/${DISTRO}-${RELEASE}-${ARCH}"
if [ $commercial = "true" ]; then
output_dir="output/commercial/${DISTRO}-${RELEASE}-${ARCH}"
fi
orig_dir="output/orig"
mkdir -p "${output_dir}" "${orig_dir}"
if [ "$arch_indep" = "true" -a "$ARCH" = "amd64" ]; then
# On amd64, build architecture independent packages.
BUILD_TYPE=all
elif [ "$arch_indep" = "false" -a "$ARCH" = "amd64" ]; then
# On amd64, build both architecture dependent and independent packages.
BUILD_TYPE=binary
else
# On others, build only architecture dependent packages.
BUILD_TYPE=any
fi
if [ "$commercial" != "true" -a "$ARCH" = "amd64" ]; then
echo "Including source packages in the build."
BUILD_TYPE="source,${BUILD_TYPE}"
fi
PLATFORM=""
if [ "$ARCH" = "armhf" -a "$DISTRO" = "raspberrypios" ]; then
PLATFORM="--platform=linux/arm/v6"
fi
echo
docker run --rm \
--volume $(pwd)/recipes:/recipes \
--volume $(pwd)/${output_dir}:/output \
--volume $(pwd)/${orig_dir}:/orig \
--volume $(pwd)/mender-deb-package:/script \
--env MENDER_PRIVATE_REPO_ACCESS_USER \
--env MENDER_PRIVATE_GPG_KEY_BUILD \
--env OVERRIDE_DEBIAN_SUFFIX \
${PLATFORM} \
${IMAGE_NAME_PREFIX}-${BUILD}-${DISTRO}-${RELEASE}-${ARCH}-${IMAGE_VERSION:-master} \
/script \
${recipe_name} \
${BUILD_TYPE} \
${src_url} \
${RECIPE_VERSION} \
${ARCH} \
${CI_PIPELINE_ID:-LOCAL} \
${SAVE_ORIG}
exit 0