-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdunfell-kick.sh
executable file
·303 lines (241 loc) · 9.28 KB
/
dunfell-kick.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash
BASE_DIR=${HOME}
BUILD_DIR=${BASE_DIR}/kick
LOG_DIR=${BUILD_DIR}/logs
DATE=$(date +%Y%m%d)
LOG=${LOG_DIR}/dunfell-${DATE}.log
LINUX_DIR=/src/linux
LINUX_BRANCHES="5.4 5.8 5.9"
ACTIVE_LINUX_BRANCH="5.9"
RPI_LINUX_BRANCHES="5.4"
ACTIVE_RPI_LINUX_BRANCH="5.4"
YOCTO_BRANCH="dunfell"
YOCTO_LAYERS="meta-openembedded meta-jumpnow meta-qt5 meta-raspberrypi meta-security"
BOARDS="atom bbb duovero odroid-c2 wandboard rpi rpi64"
BOARD_PREFIX=""
YOCTO_DIR=${BASE_DIR}/poky-${YOCTO_BRANCH}
YOCTO_COMMIT_LOG="${LOG_DIR}/commits-${DATE}"
update_linux_stable()
{
if [ ! -d ${LINUX_DIR}/linux-stable ]; then
echo "Directory not found: ${LINUX_DIR}/linux-stable" >> ${LOG}
exit 1
fi
cd ${LINUX_DIR}/linux-stable
for branch in ${LINUX_BRANCHES}
do
git checkout linux-${branch}.y >> ${LOG} 2>&1
git pull >> ${LOG} 2>&1
logfile=${LOG_DIR}/${branch}-${DATE}
git log | head -1 | awk '{ print $2 }' > ${logfile}
version=${branch}.$(grep SUBLEVEL Makefile | head -1 | awk '{ print $3 }')
echo ${version} >> ${logfile}
done
}
update_linux_rpi()
{
if [ ! -d ${LINUX_DIR}/linux-rpi ]; then
echo "Directory not found: ${LINUX_DIR}/linux-rpi" >> ${LOG}
exit 1
fi
cd ${LINUX_DIR}/linux-rpi
for branch in ${RPI_LINUX_BRANCHES}
do
git checkout rpi-${branch}.y >> ${LOG} 2>&1
git pull >> ${LOG} 2>&1
logfile=${LOG_DIR}/rpi-${branch}-${DATE}
git log | head -1 | awk '{ print $2 }' > ${logfile}
version=${branch}.$(grep SUBLEVEL Makefile | head -1 | awk '{ print $3 }')
echo ${version} >> ${logfile}
done
}
update_layer_repos()
{
if [ ! -d ${YOCTO_DIR} ]; then
echo "Directory not found: ${YOCTO_DIR}" >> ${LOG}
exit 1
fi
cd ${YOCTO_DIR}
echo "Checking poky-${YOCTO_BRANCH}" >> ${LOG}
git checkout ${YOCTO_BRANCH} >> ${LOG} 2>&1
git pull >> ${LOG} 2>&1
echo "poky $(git log --oneline | head -1 | awk '{ print $1; }')" > ${YOCTO_COMMIT_LOG}
for layer in ${YOCTO_LAYERS}
do
if [ ! -d ${layer} ]; then
echo "Path not found: ${layer}"
exit 1
fi
cd ${layer}
echo "Checking ${layer}" >> ${LOG}
git checkout ${YOCTO_BRANCH} >> ${LOG} 2>&1
git pull >> ${LOG} 2>&1
echo "${layer} $(git log --oneline | head -1 | awk '{ print $1; }')" >> ${YOCTO_COMMIT_LOG}
cd ..
done
}
check_kernels()
{
for board in ${BOARDS}; do
if [ ! -d "${BASE_DIR}/${BOARD_PREFIX}${board}/meta-${board}" ]; then
echo "Directory not found: ${BASE_DIR}/${BOARD_PREFIX}${board}/meta-${board}" >> ${LOG}
exit 1
fi
recipe_path="${BASE_DIR}/${BOARD_PREFIX}${board}/meta-${board}/recipes-kernel/linux"
if [ ! -d ${recipe_path} ]; then
echo "Directory not found: ${recipe_path}" >> ${LOG}
exit 1
fi
cd $recipe_path
if [ ${board} == "rpi" ] || [ ${board} == "rpi64" ]; then
for branch in ${RPI_LINUX_BRANCHES}
do
if [ -f linux-raspberrypi_${branch}.bbappend ]; then
latest_commit=$(cat ${LOG_DIR}/rpi-${branch}-${DATE} | head -1)
latest_version=$(cat ${LOG_DIR}/rpi-${branch}-${DATE} | tail -1)
current_commit=$(egrep '^SRCREV ' linux-raspberrypi_${branch}.bbappend | awk '{ print $3 }' | tr -d '"')
current_version=$(grep LINUX_VERSION linux-raspberrypi_${branch}.bbappend | awk '{ print $3 }' | tr -d '"')
if [ "${latest_commit}" == "${current_commit}" ]; then
echo "$board kernel $branch OK" >> ${LOG}
else
echo "$board kernel $branch STALE" >> ${LOG}
fi
fi
done
else
for branch in ${LINUX_BRANCHES}
do
if [ -f linux-stable_$branch.bb ]; then
latest_commit=$(cat ${LOG_DIR}/${branch}-${DATE} | head -1)
latest_version=$(cat ${LOG_DIR}/${branch}-${DATE} | tail -1)
current_commit=$(grep SRCREV linux-stable_${branch}.bb | awk '{ print $3 }' | tr -d '"')
current_version=$(grep PV linux-stable_${branch}.bb | awk '{ print $3 }' | tr -d '"')
if [ "${latest_commit}" == "${current_commit}" ]; then
echo "$board kernel $branch OK" >> ${LOG}
else
echo "$board kernel $branch STALE" >> ${LOG}
fi
fi
done
fi
done
}
update_meta_layer_readmes()
{
for board in ${BOARDS}
do
readme="${BASE_DIR}/${BOARD_PREFIX}${board}/meta-${board}/README.md"
commit=$(grep poky ${YOCTO_COMMIT_LOG})
grep -q -e "${commit}" ${readme}
if [ $? -eq 1 ]; then
echo "${board} poky UPDATED" >> ${LOG}
sed -i "s:^ poky.*: ${commit}:" ${readme}
fi
for layer in ${YOCTO_LAYERS}
do
grep -q ${layer} ${readme}
if [ $? -eq 0 ]; then
commit=$(grep ${layer} ${YOCTO_COMMIT_LOG})
grep -q -e "${commit}" ${readme}
if [ $? -eq 1 ]; then
echo "${board} ${layer} UPDATED" >> ${LOG}
sed -i "s:^ ${layer}.*: ${commit}:" ${readme}
fi
fi
done
done
}
update_meta_layer_kernels()
{
for board in ${BOARDS}
do
if [ ${board} == "rpi" ] || [ ${board} == "rpi64" ]; then
for branch in ${RPI_LINUX_BRANCHES}
do
recipe_path="${BASE_DIR}/${BOARD_PREFIX}${board}/meta-${board}/recipes-kernel/linux"
if [ -f ${recipe_path}/linux-raspberrypi_${branch}.bbappend ]; then
latest_commit=$(cat ${LOG_DIR}/rpi-${branch}-${DATE} | head -1)
latest_version=$(cat ${LOG_DIR}/rpi-${branch}-${DATE} | tail -1)
grep -q "${board} kernel ${branch} STALE" $LOG
if [ $? -eq 0 ]; then
echo "Updating recipe ${recipe_path}/linux-raspberrypi_${branch}.bbappend" >> ${LOG}
sed -i "s:^SRCREV =.*:SRCREV = \"${latest_commit}\":" ${recipe_path}/linux-raspberrypi_${branch}.bbappend
sed -i "s:^LINUX_VERSION.*:LINUX_VERSION = \"${latest_version}\":" ${recipe_path}/linux-raspberrypi_${branch}.bbappend
fi
fi
done
else
for branch in ${LINUX_BRANCHES}
do
latest_commit=$(cat ${LOG_DIR}/${branch}-${DATE} | head -1)
latest_version=$(cat ${LOG_DIR}/${branch}-${DATE} | tail -1)
grep -q "${board} kernel ${branch} STALE" $LOG
if [ $? -eq 0 ]; then
recipe_path="${BASE_DIR}/${BOARD_PREFIX}${board}/meta-${board}/recipes-kernel/linux"
echo "Updating recipe ${recipe_path}/linux-stable_${branch}.bb" >> ${LOG}
sed -i "s:^SRCREV.*:SRCREV = \"${latest_commit}\":" ${recipe_path}/linux-stable_${branch}.bb
sed -i "s:^PV.*:PV = \"${latest_version}\":" ${recipe_path}/linux-stable_${branch}.bb
fi
done
fi
done
}
rebuild_images()
{
for board in ${BOARDS}
do
if [ ${board} == "rpi" ] || [ ${board} == "rpi64" ]; then
branch=${ACTIVE_RPI_LINUX_BRANCH}
else
branch=${ACTIVE_LINUX_BRANCH}
fi
grep -q "${board} kernel ${branch} STALE" $LOG
if [ $? -eq 0 ]; then
echo "Rebuilding kernel and console image for ${board}" >> ${LOG}
result=$( source ${YOCTO_DIR}/oe-init-build-env ${BASE_DIR}/${BOARD_PREFIX}${board}/build && \
bitbake -c cleansstate console-image && \
bitbake -c cleansstate virtual/kernel && \
bitbake console-image && \
echo "Finished building console image for ${board}" >> ${LOG}; )
if [ $? -ne 0 ]; then
echo "Result $? : $result" >> ${LOG}
fi
else
# only building console images so don't rebuild if only meta-qt5 changes
grep "UPDATED" $LOG | grep -v meta-qt5 | grep -q "${board}"
if [ $? -eq 0 ]; then
echo "Rebuilding console image for ${board}" >> ${LOG}
result=$( source ${YOCTO_DIR}/oe-init-build-env ${BASE_DIR}/${BOARD_PREFIX}${board}/build && \
bitbake -c cleansstate console-image && \
bitbake console-image && \
echo "Finished building console image for ${board}" >> ${LOG}; )
if [ $? -ne 0 ]; then
echo "Result $? : $result" >> ${LOG}
fi
fi
fi
done
}
cleanup_old_logs()
{
# find ${LOG_DIR} -mtime +1 -delete
rm -f ${LOG_DIR}/*
}
########################################
# the main flow
########################################
mkdir -p ${LOG_DIR}
if [ ! -d ${LOG_DIR} ]; then
echo "Error creating kick log directory"
exit 1
fi
echo "kick start: $(date)" > ${LOG}
cleanup_old_logs
update_linux_stable
update_linux_rpi
update_layer_repos
check_kernels
update_meta_layer_readmes
update_meta_layer_kernels
rebuild_images
echo "kick done: $(date)" >> ${LOG}