-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_for_ultimaker.sh
executable file
·188 lines (166 loc) · 3.98 KB
/
build_for_ultimaker.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
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
#!/bin/sh
#
# SPDX-License-Identifier: AGPL-3.0+
#
# Copyright (C) 2019 Ultimaker B.V.
#
set -eu
LOCAL_REGISTRY_IMAGE="qt5-ultimaker"
ARCH="${ARCH:-arm64}" # armhf or x86_64, or arm64
UM_ARCH="${UM_ARCH:-imx8m}" # Empty string, sun7i for R1, or imx6dl for R2, or imx8m for colorado
SRC_DIR="$(pwd)"
PREFIX="/usr"
RELEASE_VERSION="${RELEASE_VERSION:-5.12.3}"
DOCKER_WORK_DIR="/docker_workdir"
BUILD_DIR_TEMPLATE="_build"
BUILD_DIR="${BUILD_DIR_TEMPLATE}_${ARCH}_${UM_ARCH}"
run_linters="yes"
run_env_check="yes"
update_docker_image()
{
echo "Building local Docker build environment."
docker build ./docker_env -t "${LOCAL_REGISTRY_IMAGE}"
}
run_in_docker()
{
docker run \
--privileged \
--cap-add=ALL \
--security-opt seccomp:unconfined \
--rm \
-it \
-u "$(id -u)" \
-e "BUILD_DIR=${DOCKER_WORK_DIR}/${BUILD_DIR}" \
-e "ARCH=${ARCH}" \
-e "PREFIX=${PREFIX}" \
-e "RELEASE_VERSION=${RELEASE_VERSION}" \
-e "MAKEFLAGS=-j$(($(getconf _NPROCESSORS_ONLN) - 1))" \
-e "CCACHE_DIR=${DOCKER_WORK_DIR}/tools/ccache" \
-v "${SRC_DIR}:${DOCKER_WORK_DIR}" \
-w "${DOCKER_WORK_DIR}" \
"${LOCAL_REGISTRY_IMAGE}" \
"${@}"
}
shell_in_docker()
{
docker run \
--privileged \
--cap-add=ALL \
--security-opt seccomp:unconfined \
--rm \
-it \
-u "$(id -u)" \
-e "BUILD_DIR=${DOCKER_WORK_DIR}/${BUILD_DIR}" \
-e "ARCH=${ARCH}" \
-e "PREFIX=${PREFIX}" \
-e "RELEASE_VERSION=${RELEASE_VERSION}" \
-e "MAKEFLAGS=-j$(($(getconf _NPROCESSORS_ONLN) - 1))" \
-e "CCACHE_DIR=${DOCKER_WORK_DIR}/tools/ccache" \
-v "${SRC_DIR}:${DOCKER_WORK_DIR}" \
-w "${DOCKER_WORK_DIR}" \
"${LOCAL_REGISTRY_IMAGE}" \
"/bin/bash"
}
update_modules()
{
git submodule update --init --recursive --depth 1
cd "${SRC_DIR}/qtbase"
for patch in "${SRC_DIR}/patches/qtbase/"*.patch; do
if git apply --check "${patch}" > /dev/null 2>&1; then
git apply "${patch}"
fi
done
cd "${SRC_DIR}/qtdeclarative"
for patch in "${SRC_DIR}/patches/qtdeclarative/"*.patch; do
if git apply --check "${patch}" > /dev/null 2>&1; then
git apply "${patch}"
fi
done
cd "${SRC_DIR}"
}
run_shellcheck()
{
docker run \
--rm \
-v "$(pwd):${DOCKER_WORK_DIR}" \
-w "${DOCKER_WORK_DIR}" \
"registry.hub.docker.com/koalaman/shellcheck-alpine:stable" \
"docker_env/run_shellcheck.sh"
}
env_check()
{
run_in_docker "./docker_env/buildenv_check.sh"
}
run_build()
{
run_in_docker "./build.sh" "${@}"
}
run_linters()
{
run_shellcheck
}
deliver_pkg()
{
cp "${SRC_DIR}/${BUILD_DIR}/"*"deb" "${SRC_DIR}"
}
run_tests()
{
echo "There are no tests available for this repository."
}
usage()
{
echo "Usage: ${0} [OPTIONS]"
echo " -c Clean the workspace"
echo " -C Skip run of build environment checks"
echo " -l Skip running the shellcheck linter"
echo " -h Print usage"
echo
echo "Other options will be passed on to build.sh"
echo "Run './build.sh -h' for more information."
}
while getopts ":cCslh" options; do
case "${options}" in
c)
run_build "${@}"
exit 0
;;
C)
run_env_check="no"
;;
s)
shell_in_docker
exit 0
;;
h)
usage
exit 0
;;
l)
run_linters="no"
;;
:)
echo "Option -${OPTARG} requires an argument."
exit 1
;;
?)
echo "Invalid option: -${OPTARG}"
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
if ! command -V docker; then
echo "Docker not found, docker-less builds are not supported."
exit 1
fi
update_docker_image
if [ "${run_env_check}" = "yes" ]; then
env_check
fi
if [ "${run_linters}" = "yes" ]; then
run_linters
fi
update_modules
run_build "${@}"
deliver_pkg
exit 0