blob: bc8a342e4a951e6084d535bc7c9a141cc1e7ee6c (
plain)
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
#! /bin/sh
# Example env variables and its values
# export board_types='panda'
# rootfs_type='nano'
set -xe
# set some defaults
# the : does nothing but the argument is evaluated so this works swell
#
: ${kernel_config:='packaged_kernel_config'}
: ${hwpack_type:='panda'}
: ${board_types:='panda'}
: ${rootfs_type:='nano'}
: ${submit_job:=1}
: ${upstream_git_tree:='git://git.linaro.org/kernel/linux-linaro-3.0.git'}
: ${upstream_git_branch:='master'}
: ${kernel_root:='kernel_root'}
: ${ubuntu_release:='natty'}
: ${git_publish_remote_repo_pull="git://github.com/jcrigby/packaged-linux-linaro-3.0-ci.git"} # read only
: ${git_publish_remote_repo_push="git@github.com:jcrigby/packaged-linux-linaro-3.0-ci.git"} # r/w
: ${git_publish_remote_branch="omap"}
: ${git_publish_keyfile:="default_git_publish_keyfile"}
: ${git_publish:=1}
lci_b_t=$(pwd)/lci-build-tools
: ${GIT_COMMITTER_NAME:="Linaro CI"}
: ${GIT_COMMITTER_EMAIL:= "<john.rigby@linaro.org>"}
: ${GIT_AUTHOR_NAME:="Linaro CI"}
: ${GIT_AUTHOR_EMAIL:= "<john.rigby@linaro.org>"}
: ${DEBFULLNAME:="Linaro CI"}
: ${DEBEMAIL:="john.rigby@linaro.org"}
: ${force_build:=0}
export GIT_COMMITTER_NAME
export GIT_COMMITTER_EMAIL
export GIT_AUTHOR_NAME
export GIT_AUTHOR_EMAIL
export DEBFULLNAME
export DEBEMAIL
bundle_stream_name=$(echo $JOB_NAME | sed -e 's/_.*//' -e 's/\./_/g')
# Below is the list of values that will be used in the json files
log_info=$BUILD_URL"consoleText"
bundle_stream_name_path="/anonymous/ci-$bundle_stream_name/"
# kernel building helpers
#
fdr() {
fakeroot ./debian/rules "$@"
}
# grab a value from fdr printenv results
#
fdrpenvget() {
fdr printenv \
| grep "^$1[[:blank:]]*=" \
| sed -e 's/.*=//' -e 's/[ \t]*//g'
}
# grab a value from dpkg-parsechangelog results
#
dpchglget() {
dpkg-parsechangelog -ldebian.linaro/changelog \
| grep -Po "^$1:.+" \
| sed -e "s/$1: //"
}
# prepare cross build
#
prepare_cross_build() {
# turn off tools, workaround a binutils bug
sed -i -e 's/do_tools.*=.*/do_tools = false/' debian.linaro/rules.d/armel.mk
sed -i -e 's/march=all/march=armv7-a/' arch/arm/boot/compressed/Makefile
}
# check previous results against packaged and upstream kernels
# to see if a build needs to happen if not then exit with success here
#
exit_if_nothing_todo()
{
test $force_build = "1" && return 0
# packaged kernel is HEAD
# if the results repo does not yet exist then there is something very wrong
#
git ls-remote -h $git_publish_remote_repo_pull || \
exit 1
# if the results branch does not yet exist then there
# is most definately something todo
#
found=$(git ls-remote -h $git_publish_remote_repo_pull $git_publish_remote_branch |
wc -l)
test $found = "0" && new_results_branch=1 && return 0
# first see how upstream compares to previous results
# make a remote that points to upstream
#
upstream_remote_name="remote_random_$RANDOM"
git remote add $upstream_remote_name $upstream_git_tree
git remote update $upstream_remote_name
# make a remote that points to previous results
#
results_remote_name="remote_random_$RANDOM"
git remote add $results_remote_name $git_publish_remote_repo_pull
git remote update $results_remote_name
# count commits in upstream that are not in previous results
#
new_upstream_commits=$(git rev-list \
remotes/$upstream_remote_name/$upstream_git_branch \
^remotes/$results_remote_name/$git_publish_remote_branch \
| wc -l)
test "$new_upstream_commits" != "0" && \
echo "new upstream commits so there is something to do!" && \
return 0
# counting commits with git-revlist does not work for packaged vs results
# since the packaged commits in results have been rebased so git-revlist
# does not know they are the same
#
# if the packaged basis of the previous commit is different than
# current then there is something todo
#
packaged_basis_commit_id=$(git log -n1 --pretty=format:%H)
previous_packaged_basis_commit_id=$(git log -n1 \
remotes/$results_remote_name/$git_publish_remote_branch | \
grep packaged_basis_commit_id | \
sed 's/.*=//')
test "$packaged_basis_commit_id" != "$previous_packaged_basis_commit_id" && \
echo "new packaged tree basis so there is something to do!" && \
return 0
echo "nothing todo, previous results are up to date"
exit 0
}
# start a new release
#
start_new_release() {
fdr clean
release=$(fdrpenvget release)
abinum=$(fdrpenvget abinum)
uploadnum=$(fdrpenvget uploadnum)
prev_revision=$(fdrpenvget prev_revision)
# remove old abi files
#
git rm -r -f debian.linaro/abi/$release-$prev_revision
# for now always increment the abi and the upload numbers
#
((abinum += 1))
((uploadnum += 1))
dch -c debian.linaro/changelog \
-t "LINARO: CI: Autogenerated Continuous Integration Build" \
-b -v "$release-$abinum.$uploadnum~ci~$(date +%Y%m%d%H%M%S)"
sed -i -e "0,/$ubuntu_release/s/$ubuntu_release/UNRELEASED/" \
debian.linaro/changelog
prev_revision=$(fdrpenvget prev_revision)
flavours=$(grep '^flavours[[:blank:]]*=' debian.linaro/rules.d/armel.mk \
| sed -e "s/.*=[ \t]*//")
mkdir -p debian.linaro/abi/$release-$prev_revision/armel
echo $((abinum - 1)) > debian.linaro/abi/$release-$prev_revision/abiname
git add debian.linaro/abi/$release-$prev_revision/abiname
echo 1 > debian.linaro/abi/$release-$prev_revision/armel/ignore
echo 1 > debian.linaro/abi/$release-$prev_revision/armel/ignore.modules
# even when ignoring abi files we still need previous version abi files
# so create some fake ones
#
for f in $flavours
do
echo "(ignore) ignore/ignore 0x0 ignore" > \
debian.linaro/abi/$release-$prev_revision/armel/$f
echo ignore > \
debian.linaro/abi/$release-$prev_revision/armel/$f.modules
done
git add debian.linaro/abi/$release-$prev_revision
git add debian.linaro/changelog
git commit -m "LINARO: CI: Start new release"
}
rebase_on_latest_upstream()
{
# add a remote pointing to upstream and rebase onto it
# if there is anything there not already in HEAD
#
upstream_remote_name="remote_random_$RANDOM"
git remote add $upstream_remote_name $upstream_git_tree
git remote update
newcommits=$(git rev-list \
remotes/$upstream_remote_name/$upstream_git_branch \
^HEAD \
| wc -l)
test $newcommits = "0" && echo "no rebase needed" && return 0
git rebase remotes/$upstream_remote_name/$upstream_git_branch || true
# deal with rebase conflicts in the most crude way possible
# by just skipping them
#
echo "Here are all the skipped commits...." > ../skipped-commits
rm -f ../skipped-commits
while [ -d .git/rebase-apply/ ]
do
git show --pretty=short \
$(cat .git/rebase-apply/original-commit) \
>> ../skipped-commits
git rebase --skip || true
done
cat ../skipped-commits
dch -c debian.linaro/changelog -a "Rebase on new upstream"
git add debian.linaro/changelog
git commit -m "LINARO: CI: rebase on new upstream"
git remote rm $upstream_remote_name
}
update_configs()
{
# use fdr defaultconfigs instead of fdr updateconfigs because the
# former uses
# yes '' | make oldconfig
# while the later uses
# make silentoldconfig
# which does not allow piped input so it isn't really appropriate
# for scripting
#
fdr defaultconfigs || true
# If anything has changed then those changes need to be checked in
#
if [ $(git status --short -uno) ]
then
dch -c debian.linaro/changelog -a "Update configs"
git add debian.linaro/changelog
git commit -a debian.linaro/config -m "LINARO: Update configs"
fi
}
finalize_changelog()
{
sed -i -e "0,/UNRELEASED/s/UNRELEASED/$ubuntu_release/" \
debian.linaro/changelog
source=$(dpchglget Source)
version=$(dpchglget Version)
git add debian.linaro/changelog
echo "$source $version" > commitmsg
echo "packaged_basis_commit_id=$packaged_basis_commit_id" >> commitmsg
git commit -F commitmsg -s
git_publish_tag_name=$(echo "$source-$version" | sed 's/~/-/g')
git tag -m "source $version" "$git_publish_tag_name"
}
publish_kernel_source()
{
test $git_publish = "0" && echo "publishing turned off" && return 0
# first the branch
$lci_b_t/git-publish run \
--local_branch HEAD \
--remote_repo $git_publish_remote_repo_push \
--remote_branch $git_publish_remote_branch \
--keyfile $git_publish_keyfile \
--force
# then the tag
$lci_b_t/git-publish run \
--tag $git_publish_tag_name \
--remote_repo $git_publish_remote_repo_push \
--remote_branch $git_publish_remote_branch \
--keyfile $git_publish_keyfile \
--force
return 0
}
cpu_count=$(cat /proc/cpuinfo | grep processor | wc -l)
if test x$cpu_count = x; then
cpu_count=1
fi
j_count=$(expr $cpu_count '*' 2)
# ok lets actually build the kernel
#
START=$(date +%s)
{
cd $kernel_root
exit_if_nothing_todo
start_new_release
rebase_on_latest_upstream
update_configs
finalize_changelog
prepare_cross_build
fdr clean
debuild --no-tgz-check --no-lintian -j$j_count \
-eCROSS_COMPILE=arm-linux-gnueabi- -b -aarmel -us -uc
publish_kernel_source
cd ..
}
END=$(date +%s)
EXECUTION_TIME_IN_SEC=$(( $END - $START ))
if [ $hwpack_type != none ]; then
kernel_version=$(cd $kernel_root; fdrpenvget revision)
rm *dbgsym*.deb # this messes up the glob later
latest_hwpack=$(hwpack_type=$hwpack_type; \
python lci-build-tools/get_latest_slo_hwpack)
latest_hwpack_name=$(basename $latest_hwpack)
wget -c $latest_hwpack
rm -rf linaro-image-tools
bzr branch lp:linaro-image-tools
new_hwpack_url=$(python linaro-image-tools/linaro-hwpack-replace \
-t $latest_hwpack_name \
-p ./linux-image*${kernel_version}*.deb \
-r linux-image \
-n $BUILD_NUMBER)
new_hwpack_name=$(basename $new_hwpack_url)
fi
# NB: tabs only indenting in this heredoc
#
cd $kernel_root; cat > ../hwpack_info <<-_HWPACK_INFO_END_
KERNEL_CONFIG=$kernel_config
OS_INFO=$(cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | cut -d '=' -f 2)
LOG=$log_info
BUILD_ID=$BUILD_NUMBER
GCC_VERSION=$(dpkg -s gcc | grep Version | cut -d ' ' -f2)
GCC_CROSS_COMPILER=$(dpkg -s gcc-arm-linux-gnueabi | grep Version | cut -d ' ' -f2)
BOARD_TYPES=$board_types
HWPACK_TYPE=$hwpack_type
ROOTFS_TYPE=$rootfs_type
BUNDLE_STREAM_NAME=$bundle_stream_name_path
JOB_URL=http://snapshots.linaro.org/kernel-hwpack/
KERNEL_VERSION=$(git describe --match='v*')
KERNEL_GIT=$(cat .git/config|grep -i 'url = ' | cut -d "=" -f2)
KERNEL_COMMIT=$GIT_COMMIT
COMMIT_TIME=$(git show -s --format=%cD HEAD)
KERNEL_NAME=$bundle_stream_name
SUBMIT_LAVA_JOB=$submit_job
KERNEL_BUILD_URL=$BUILD_URL
KERNEL_BRANCH=$(git branch | grep -e '*' | cut -d '*' -f 2)
KERNEL_JOB_NAME=$JOB_NAME
GIT_LOG=$(git log -n1 --pretty=oneline)
HWPACK_NAME=$new_hwpack_name
URL=$JENKINS_HOME/jobs/$JOB_NAME/workspace/$new_hwpack_name
EXECUTION_TIME_IN_SEC=$(( $END - $START ))
HWPACK_BUILD_DATE=$(echo $new_hwpack_name | cut -d '_' -f3)
_HWPACK_INFO_END_
exit 0
|