-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathyocto-entrypoint.sh
executable file
·245 lines (210 loc) · 5.8 KB
/
yocto-entrypoint.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/usr/bin/env bash
SUPPORTED_MACHINES_ROCKO=" \
imx6qdlsabresd \
raspberrypi3 \
"
SUPPORTED_MACHINES_THUD=" \
imx8mqevk \
stm32mp1-disco \
"
SUPPORTED_MACHINES_WARRIOR=" \
imx8mqevk \
"
SUPPORTED_MACHINES_DUNFELL=" \
imx8mqevk \
"
SUPPORTED_FULLMETALUPATE=" \
dev \
latest-release \
"
yocto_sync()
{
local MACHINE="$1"
local YOCTO="$2"
local FULLMETALUPDATE="$3"
sudo mkdir -p "${DATADIR}/yocto/"
sudo chown docker:docker "${DATADIR}/yocto/"
cd "${DATADIR}/yocto"
case "${MACHINE}" in
"imx8mqevk")
BRANCH_REPO="imx"
;;
"imx6qdlsabresd")
BRANCH_REPO="imx"
;;
"raspberrypi3")
BRANCH_REPO="raspberrypi"
;;
"stm32mp1-disco")
BRANCH_REPO="stm32mp1"
;;
*)
return 1
;;
esac
echo "N" | repo init -u https://github.com/FullMetalUpdate/manifest -b "${YOCTO}/${BRANCH_REPO}" -m "${FULLMETALUPDATE}.xml"
repo sync --force-sync
}
is_in_list()
{
local key="$1"
local list="$2"
for item in $list; do
if [ "$item" = "$key" ]; then
return 0
fi
done
return 1
}
is_yocto_supported()
{
local MACHINE="$1"
local YOCTO="$2"
case "${YOCTO}" in
"rocko")
if ! is_in_list "$MACHINE" "$SUPPORTED_MACHINES_ROCKO"; then
echo "$MACHINE is not supported by FullMetalUpdate by the Yocto version of Rocko: $SUPPORTED_MACHINES_ROCKO"
fi
;;
"thud")
if ! is_in_list "$MACHINE" "$SUPPORTED_MACHINES_THUD"; then
echo "$MACHINE is not supported by FullMetalUpdate for the Yocto version of Thud: $SUPPORTED_MACHINES_THUD"
fi
;;
"warrior")
if ! is_in_list "$MACHINE" "$SUPPORTED_MACHINES_WARRIOR"; then
echo "$MACHINE is not supported by FullMetalUpdate for the Yocto version of Warrior: $SUPPORTED_MACHINES_WARRIOR"
fi
;;
"dunfell")
if ! is_in_list "$MACHINE" "$SUPPORTED_MACHINES_DUNFELL"; then
echo "$MACHINE is not supported by FullMetalUpdate for the Yocto version of Dunfell: $SUPPORTED_MACHINES_DUNFELL"
fi
;;
*)
return 1
;;
esac
}
is_fullmetalupdate_supported()
{
local FULLMETALUPDATE="$1"
is_in_list "$FULLMETALUPDATE" "$SUPPORTED_FULLMETALUPATE"
}
show_usage()
{
echo "Usage: StartBuild.sh command [args]"
echo "Commands:"
echo " sync <machine> <yocto_version> <FullMetalUpdate_version>"
echo " Sync Yocto and Full Metal Update versions"
echo " E.g. sync imx6qdlsabresd rocko v1.0"
echo
echo " all"
echo " Build Full Metal Update OS and containers images"
echo
echo " fullmetalupdate-containers"
echo " Build Full Metal Update containers image"
echo
echo " fullmetalupdate-os"
echo " Build Full Metal Update OS image"
echo
echo " build-container <image>"
echo " Build Full Metal Update container image <image>"
echo
echo " package-wic"
echo " Build the .wic SD Card image"
echo
echo " bash [distro]"
echo " Start an interactive bash shell in the build container"
echo " Optional: [distro] to use"
echo " E.g. fullmetalupdate-os, fullmetalupdate-containers"
echo
echo " help"
echo " Show this text"
echo
exit 1
}
main()
{
if [ $# -lt 1 ]; then
show_usage
fi
if [ ! -d "${DATADIR}/yocto/sources" ] && [ "$1" != "sync" ]; then
echo "The directory 'yocto/sources' does not yet exist. Use the 'sync' command"
show_usage
fi
case "$1" in
all)
cd "${DATADIR}/yocto"
TEMPLATECONF=$PWD/sources/meta-fullmetalupdate-extra/conf/$1
source sources/poky/oe-init-build-env build
DISTRO=fullmetalupdate-containers bitbake fullmetalupdate-containers-package -k
DISTRO=fullmetalupdate-os bitbake fullmetalupdate-os-package -k
;;
sync)
shift; set -- "$@"
if [ $# -ne 3 ]; then
echo "sync command accepts only 3 arguments"
show_usage
fi
if ! is_yocto_supported "$1" "$2"; then
echo "$2 is not a supported yocto version: $SUPPORTED_YOCTO"
show_usage
fi
if ! is_fullmetalupdate_supported "$3"; then
echo "$3 is not a supported version: $SUPPORTED_FULLMETALUPATE"
show_usage
fi
yocto_sync $@
cd "${DATADIR}/yocto"
export TEMPLATECONF=$PWD/sources/meta-fullmetalupdate-extra/conf/$1
cp -v $TEMPLATECONF/* $PWD/sources/meta-fullmetalupdate-extra/conf/
source sources/poky/oe-init-build-env build
;;
fullmetalupdate-containers)
cd "${DATADIR}/yocto"
source sources/poky/oe-init-build-env build
DISTRO=fullmetalupdate-containers bitbake fullmetalupdate-containers-package -k
;;
fullmetalupdate-os)
cd "${DATADIR}/yocto"
source sources/poky/oe-init-build-env build
if [ ! -d "${DATADIR}/yocto/build/tmp/fullmetalupdate-containers/deploy/containers" ]; then
DISTRO=fullmetalupdate-containers bitbake fullmetalupdate-containers-package -k
fi
DISTRO=fullmetalupdate-os bitbake fullmetalupdate-os-package -k
;;
build-container)
shift; set -- "$@"
if [ $# -ne 1 ]; then
echo "build-container command accepts only 1 argument"
show_usage
fi
cd "${DATADIR}/yocto"
source sources/poky/oe-init-build-env build
DISTRO=fullmetalupdate-containers bitbake $1 -k
;;
package-wic)
cd "${DATADIR}/yocto"
source sources/poky/oe-init-build-env build
DISTRO=fullmetalupdate-os bitbake fullmetalupdate-os-package -c image_wic -f
DISTRO=fullmetalupdate-os bitbake fullmetalupdate-os-package -k
;;
bash)
cd "${DATADIR}/yocto"
source sources/poky/oe-init-build-env build
if [ ! -z $2 ]; then
DISTRO=$2 bash
else
bash
fi
;;
help)
show_usage
;;
*)
echo "Command not supported: $1"
show_usage
esac
}
main $@