-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·278 lines (223 loc) · 5.31 KB
/
build.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
#!/bin/sh
cd "$(dirname $0)"
for x in LANGUAGE LC_ALL LANG; do
export $x=C
done
title() {
cat <<-EOT
#
# $*
#
EOT
}
err() {
echo "$*" >&2
}
get_prefix() {
local remote= prefix=
local x=
if [ $# = 0 ]; then
:
elif [ $# -eq 1 ]; then
prefix="$1"
shift
elif [ $# -gt 1 ]; then
prefix="$1"
remote="$2"
shift 2
fi
# prefix developer trees
if [ -n "$remote" -a "$remote" != "origin" ]; then
prefix="$prefix-$remote"
fi
# branches and extras
for x; do
x="$(echo "$x" | tr '/' '-' | sed -e 's|sunxi[-_]||g' )"
if [ -n "$x" -a "$x" != sunxi ]; then
prefix="$prefix-$x"
fi
done
echo "$prefix"
}
name2gitdir() {
echo "$PWD/$(get_prefix "$1" "${2:-origin}").git"
}
clone() {
local name="$1" url="$2" remote="${3:-origin}"
local dir=$(name2gitdir "$name" "$remote")
local refdir=$(name2gitdir "$name")
title "${dir#$PWD/} <- $url"
if [ -s "$dir/config" ]; then
cd "$dir"
git remote update -p
cd - > /dev/null
elif [ "$dir" != "$refdir" -a -s "$refdir/config" ]; then
git clone --reference "$refdir" --mirror "$url" "$dir"
else
git clone --mirror "$url" "$dir"
fi
}
updated() {
local refdir="$1" branch="$2" name="$3"
local dir="$PWD/$name"
local rev0= rev1= ret=false
title "$name"
if [ ! -s "$dir/.git/config" ]; then
git clone -q -s "$refdir" -b "$branch" "$dir"
if [ -s "$dir/.git/config" ]; then
ret=true
fi
else
cd "$dir"
rev0=$(git rev-parse HEAD)
git fetch origin
rev1="$(git rev-parse origin/$branch)"
if [ "$rev0" != "$rev1" ]; then
ret=true
git reset -q --hard "origin/$branch"
fi
git remote update
cd - > /dev/null
fi
$ret
}
push_nightly() {
mkdir -p "nightly/$1/"
rsync -ai --delete-after "nightly/$1/" "linux-sunxi.org:nightly/$1/"
}
#
# linux
#
build_linux() {
local name="$1" remote="$2" branch="$3" rev=
local refdir=$(name2gitdir "$name" "$remote")
local prefix=$(get_prefix "$name" "$remote" "$branch")
local build_all=false build=
local base="$PWD" prefix2= x=
local builddir= nightly=
if updated "$refdir" "$branch" "$prefix"; then
build_all=true
elif [ ! -s "$prefix/.git/config" ]; then
return
fi
cd "$prefix"
rev=$(git rev-parse HEAD | sed -e 's/^\(.......\).*/\1/')
for defconfig in arch/arm/configs/sun?i*_defconfig \
arch/arm/configs/multi_v7_defconfig \
arch/arm/configs/a[123][023]*_defconfig; do
[ -s "$defconfig" ] || continue
defconfig="${defconfig##*/}"
prefix2="$(echo ${defconfig%_defconfig} |
sed -e 's/sunxi[_-]//g' -e 's/sunxi$//')"
prefix2="$prefix${prefix2:+-$prefix2}"
builddir="$base/build_$(echo $prefix2 | sed -e 's|-sunxi||g')"
nightly="$base/nightly/$name/$prefix2"
if $build_all; then
build=true
elif [ ! -d "$builddir" ]; then
build=true
else
build=false
x="$(ls -1 "$nightly/$prefix2"-*-$rev.{build,err}.txt 2> /dev/null |
sed -ne "/$prefix2-[0123456789T]\+-$rev\..*\.txt/p" |
sort | tail -n1 | grep '.err.txt$')"
if [ -s "$x" ]; then
if grep -q 'internal error, aborting at' "$x" ||
grep -q 'mali_osk_atomics.o: invalid string offset' "$x"; then
build=true
fi
fi
fi
$build || continue
"$base/build_linux.sh" "$defconfig" "$builddir" "$nightly" "$prefix2"
done
cd - > /dev/null
}
N=linux-sunxi
clone $N https://github.com/linux-sunxi/$N.git
for b in \
sunxi-3.0 \
sunxi-3.4 \
stage/sunxi-3.0 \
stage/sunxi-3.4 \
experimental/sunxi-3.10 \
experimental/sunxi-3.14 \
sunxi-next \
; do
build_linux "$N" origin "$b"
done
clone $N https://github.com/arokux/linux.git arokux
build_linux $N arokux sunxi-next-usb
clone $N https://github.com/bjzhang/linux-allwinner.git bjzhang
build_linux $N bjzhang sun7i-xen-dom0
build_linux $N bjzhang sun7i_xen_domU
push_nightly $N
#
# u-boot
#
N=u-boot-sunxi
simple_build() {
local builder="$1"
local name="$2" remote="$3" branch="$4"
local prefix=
local builddir= nightly=
shift 4
local refdir=$(name2gitdir "$name" "$remote")
local build=false
local base="$PWD"
prefix="${branch##*:}"
if [ "$prefix" = "$branch" ]; then
prefix=$(get_prefix "$name" "$remote" "$branch")
else
branch="${branch%:*}"
fi
builddir="$base/build_$(echo $prefix | sed -e 's|-sunxi||g')"
nightly="$base/nightly/$name/$prefix"
if updated "$refdir" "$branch" "$prefix"; then
build=true
elif [ ! -s "$prefix/.git/config" ]; then
return
elif [ ! -d "$builddir" ]; then
build=true
fi
$build || return
cd "$prefix"
"$builder" "$builddir" "$nightly" "$prefix" "$@"
cd - > /dev/null
}
build_uboot() {
simple_build "$PWD/build_u-boot.sh" "$@"
}
clone $N https://github.com/linux-sunxi/$N.git
for b in sunxi \
mirror/sunxi:$N-custodian \
mirror/next:$N-custodian-next \
mirror/master:$N-mainline \
; do
build_uboot $N origin "$b"
done
clone $N https://github.com/arokux/$N.git arokux
build_uboot $N arokux sunxi-usb
clone $N https://github.com/bjzhang/$N.git bjzhang
build_uboot $N bjzhang sunxi_hyp
push_nightly $N
#
# xen
#
N=xen-sunxi
_build_xen() {
local builddir="$1" nightly="$2" name="$3" base="$4"
local x= y=
for x in $base/build_linux-bjzhang-sun7i-xen-dom0-sun7i_dom0/arch/arm/boot/dts/*-xen.dtb; do
[ -s "$x" ] || continue
y="${x##*/}"
y="${y%-xen.dtb}"
"$base/build_xen.sh" "$builddir/build_$y" "$nightly/$name-$y" "$name-$y" "$y" "$x"
done
}
build_xen() {
simple_build "_build_xen" "$@" "$PWD"
}
clone $N git://xenbits.xen.org/xen.git
build_xen $N origin master
push_nightly $N