-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_for_ultimaker.sh
More file actions
executable file
·178 lines (155 loc) · 3.5 KB
/
build_for_ultimaker.sh
File metadata and controls
executable file
·178 lines (155 loc) · 3.5 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
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
#!/bin/bash
#
# Copyright (C) 2020 Ultimaker B.V.
#
set -eu
ARCH="${ARCH:-arm64}"
PREFIX="/usr"
RELEASE_VERSION="${RELEASE_VERSION:-999.999.999}"
DOCKER_WORK_DIR="/build"
INITRAMFS_SOURCE="${INITRAMFS_SOURCE:-initramfs/initramfs.lst}"
DEPMOD="${DEPMOD:-/sbin/depmod}"
rebuild_docker="no"
run_env_check="yes"
run_linters="yes"
run_tests="yes"
action="none"
env_check()
{
run_in_docker "./docker_env/buildenv_check.sh"
return
}
check_submodules()
{
echo "Checking if submodules are initialized..."
# If the submodules are not initialized, do it now.
# List the path of non initialized submodules:
non_init_submodules=$(git submodule status | grep '^-' | awk '{print $2}')
# If the list is not empty, intialize them:
if [ -n "${non_init_submodules}" ]; then
for submodule in ${non_init_submodules}; do
git submodule update --init --recursive "${submodule}"
done
fi
# Warn about submodules in a different commit:
different_commit_submodules=$(git submodule status | grep '^+' | awk '{print $2}')
if [ -n "${different_commit_submodules}" ]; then
echo "####### WARNING: The following submodules are checkedout in a different commit: #########"
echo "${different_commit_submodules}"
fi
}
run_build()
{
run_in_docker "./build.sh" "${@}"
}
run_tests()
{
echo "There are no tests available for this repository."
}
run_linters()
{
run_shellcheck
}
run_shellcheck()
{
docker run \
--rm \
-v "$(pwd):${DOCKER_WORK_DIR}" \
-w "${DOCKER_WORK_DIR}" \
"registry.hub.docker.com/koalaman/shellcheck-alpine:stable" \
"./run_shellcheck.sh"
}
usage()
{
echo "Usage: ${0} [OPTIONS]"
echo " -c Skip run of build environment checks"
echo " -h Print usage"
echo " -l Skip code linting"
echo " -t Skip tests"
echo
echo "Other options will be passed on to build.sh"
echo "Run './build.sh -h' for more information."
}
while getopts ":cdhlsta:" options; do
case "${options}" in
a)
action="${OPTARG}"
;;
c)
run_env_check="no"
;;
d)
rebuild_docker="yes"
;;
h)
usage
exit 0
;;
l)
run_linters="no"
;;
s)
run_env_check="no"
run_linters="no"
run_tests="no"
;;
t)
run_tests="no"
;;
:)
echo "Option -${OPTARG} requires an argument."
exit 1
;;
?)
echo "Invalid option: -${OPTARG}"
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
if ! command -V docker > /dev/null; then
echo "Docker not found, docker-less builds are not supported."
exit 1
fi
source ./make_docker.sh um-kernel
if [[ "${rebuild_docker}" == "yes" || "${action}" == "docker_build" ]]; then
DOCKER_IMAGE_NAME="${DOCKER_IMAGE_NAME:-um-kernel}"
DOCKER_IMAGE_VERSION="${DOCKER_IMAGE_VERSION:-latest}"
build_docker
fi;
case "${action}" in
shell)
run_in_docker bash
exit 0
;;
shellcheck)
run_shellcheck
exit 0
;;
build)
check_submodules
run_build
exit 0
;;
docker_build)
exit 0
;;
none)
;;
?)
echo "Invalid action: -${OPTARG}"
exit 1
;;
esac
if [ "${run_env_check}" = "yes" ]; then
env_check
fi
if [ "${run_linters}" = "yes" ]; then
run_linters
fi
if [ "${run_tests}" = "yes" ]; then
run_tests
fi
check_submodules
run_build "${@}"
exit 0