forked from tytso/xfstests-bld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-all
executable file
·473 lines (428 loc) · 13.6 KB
/
build-all
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
#!/bin/bash
set -e
if type lsb_release >& /dev/null ; then
lsb_release -c | awk '{print $2}' > build-distro
else
rm -f build-distro
fi
if test -f config.custom ; then
. config.custom
else
. config
fi
if test -z "$GOROOT" -a -d /usr/lib/go-1.8 ; then
GOROOT=/usr/lib/go-1.8
fi
if test -n "$GOROOT" ; then
export GOROOT
export GOPATH=$(pwd)/go
PATH="$GOROOT/bin:$PATH"
else
SKIP_SYZKALLER=yes
fi
if test -n "$ACCEL_BIN" -a -d "$ACCEL_BIN" ; then
PATH="$ACCEL_BIN:$PATH"
if test -x "$ACCEL_BIN/bash" ; then
SHELL="$ACCEL_BIN/bash"
fi
fi
if test -n "$TOOLCHAIN_DIR" -a -d "$TOOLCHAIN_DIR"; then
PATH=$TOOLCHAIN_DIR/bin:$PATH
fi
if test -n "$CROSS_COMPILE" ; then
cross="--build=$(e2fsprogs-libs/config/config.guess) --host=$CROSS_COMPILE"
crossfio="--cc=$CROSS_COMPILE-gcc"
fi
if test -z "$USE_LOCAL_E2FSLIBS" -o -d util-linux; then
SKIP_E2FSLIBS=yes
fi
case "$CROSS_COMPILE" in
*-android|*-androideabi)
DO_ANDROID=yes
SKIP_KVM_UTILS=yes
SKIP_QUOTA=yes
SKIP_FIO=yes
SKIP_DBENCH=yes
;;
esac
function build_start () {
echo "----------------- $(date '+%Y-%m-%d %H:%M:%S'): Starting build of $*"
}
function set_skip_all () {
SKIP_E2FSLIBS=yes
SKIP_ATTR=yes
SKIP_ACL=yes
SKIP_POPT=yes
SKIP_AIO=yes
SKIP_DBENCH=yes
SKIP_FIO=yes
SKIP_XFSPROGS=yes
SKIP_XFSTESTS=yes
SKIP_QUOTA=yes
SKIP_KVM_UTILS=yes
SKIP_KEYUTILS=yes
SKIP_FSVERITY=yes
SKIP_IMA_EVM_UTILS=yes
SKIP_STRESS_NG=yes
SKIP_UTIL_LINUX=yes
SKIP_SYZKALLER=yes
SKIP_BLKTESTS=yes
SKIP_NVME_CLI=yes
}
# Optional components
[ -d keyutils ] || SKIP_KEYUTILS=yes
[ -d ima-evm-utils ] || SKIP_IMA_EVM_UTILS=yes
[ -d stress-ng ] || SKIP_STRESS_NG=yes
[ -d util-linux ] || SKIP_UTIL_LINUX=yes
[ -d go/src/github.com/google/syzkaller ] || SKIP_SYZKALLER=yes
[ -d blktests ] || SKIP_BLKTESTS=yes
[ -d nvme-cli ] || SKIP_NVME_CLI=yes
MAKE_CLEAN=":"
while [ "$1" != "" ]; do
case $1 in
--skip-dbench)
SKIP_DBENCH=yes
;;
--skip-quota)
SKIP_QUOTA=yes
;;
--attr-only)
set_skip_all
unset SKIP_ATTR
;;
--acl-only)
set_skip_all
unset SKIP_ACL
;;
--popt-only)
set_skip_all
unset SKIP_POPT
;;
--aio-only)
set_skip_all
unset SKIP_AIO
;;
--e2fslibs-only)
set_skip_all
unset SKIP_E2FSLIBS
;;
--dbench-only)
set_skip_all
unset SKIP_DBENCH
;;
--fio-only)
set_skip_all
unset SKIP_FIO
;;
--keyutils-only)
set_skip_all
unset SKIP_KEYUTILS
;;
--fsverity-only)
set_skip_all
unset SKIP_FSVERITY
;;
--ima-evm-utils-only)
set_skip_all
unset SKIP_IMA_EVM_UTILS
;;
--quota-only)
set_skip_all
unset SKIP_QUOTA
;;
--stress-ng-only)
set_skip_all
unset SKIP_STRESS_NG
;;
--syzkaller-only)
set_skip_all
unset SKIP_SYZKALLER
;;
--util-linux-only)
set_skip_all
unset SKIP_UTIL_LINUX
;;
--xfsprogs-only)
set_skip_all
unset SKIP_XFSPROGS
;;
--xfstests-only)
set_skip_all
unset SKIP_XFSTESTS
;;
--kvm-utils-only)
set_skip_all
unset SKIP_KVM_UTILS
;;
--blktests-only)
set_skip_all
unset SKIP_BLKTESTS
;;
--nvme-cli-only)
set_skip_all
unset SKIP_NVME_CLI
;;
--clean-first)
MAKE_CLEAN="make clean"
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
nr_cpus=$(getconf _NPROCESSORS_ONLN)
J=-j$(expr $nr_cpus \* 1)
DESTDIR=$(pwd)/bld
mkdir -p $DESTDIR
if test -n "$DO_ANDROID" ; then
build_start "Android compatibility library"
(cd android-compat; ./configure $cross ; $MAKE_CLEAN ; \
make $J prefix=$DESTDIR install)
android_compat="-landroid_compat"
LCF="-fpie -include android_compat.h"
LLF="-pie"
else
LCF="-g -O2"
fi
# To make the build more reproducible...
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
export BUILD_PATH_PREFIX_MAP="xfstests-bld=$(pwd)"
# Allow the parent process of build-all to specify CPU/arch-specific
# CFLAGS via an environment variable
LCF="$LCF $CPU_CFLAGS"
# GCC doesn't yet understand BUILD_PATH_PREFIX_MAP
LCF="$LCF -fdebug-prefix-map=$(pwd)=xfstests-bld -gno-record-gcc-switches"
if test -z "$SKIP_E2FSLIBS" ; then
build_start "e2fslibs"
(cd e2fsprogs-libs; \
CFLAGS="$LCF -I$DESTDIR/include" \
LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib" \
./configure $cross --prefix=/ --disable-nls; $MAKE_CLEAN ; make $J; \
make DESTDIR=$DESTDIR $J install)
fi
if test -z "$SKIP_ATTR" ; then
build_start "extended attribute library"
(cd attr; \
CFLAGS="$LCF -I$DESTDIR/include" \
LDFLAGS="$LLF $EXEC_LDFLAGS -static -L$DESTDIR/lib" \
./configure $cross --prefix=$DESTDIR --disable-nls; $MAKE_CLEAN ; \
make $J LDFLAGS="$LLF $EXEC_LLDFLAGS -L$DESTDIR/lib" ; \
make $J install-dev ; make $J install)
fi
if test -z "$SKIP_ACL" ; then
build_start "ACL library"
(cd acl; \
CPPFLAGS="-I$DESTDIR/include" \
CFLAGS="$LCF -I$DESTDIR/include" \
LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib" \
./configure $cross --prefix=$DESTDIR --disable-nls; $MAKE_CLEAN ; \
make $J LDFLAGS="$LLF $EXEC_LLDFLAGS -static -L$DESTDIR/lib" ; \
make $J install)
fi
if test -z "$SKIP_POPT" ; then
build_start "POPT library"
(cd popt; \
CPPFLAGS="-I$DESTDIR/include" \
CFLAGS="$LCF -I$DESTDIR/include" \
LDFLAGS="$LLF -static -L$DESTDIR/lib" \
./configure $cross --prefix=$DESTDIR --disable-nls; $MAKE_CLEAN ; \
make $J LLDFLAGS=-all-static ; \
make $J install)
fi
if test -z "$SKIP_AIO" ; then
build_start "AIO library"
(cd libaio; ./configure $cross --disable-nls; $MAKE_CLEAN ;
make $J prefix=$DESTDIR install)
rm $DESTDIR/lib/libaio.so*
fi
if test -z "$SKIP_KEYUTILS" ; then
build_start "keyutils"
(cd keyutils ;
ver=$(git describe --always --dirty); echo "keyutils $ver ($(git log -1 --pretty=%cD))" > ../keyutils.ver ;
if [ -n "$CROSS_COMPILE" ]; then
export CC="$CROSS_COMPILE-gcc"
export AR="$CROSS_COMPILE-ar"
fi
# Specify NO_SOLIB=1 so that libkeyutils is only built as a static
# library. Then keyctl will be statically linked to it, and we won't
# have to install libkeyutils.so.
$MAKE_CLEAN ;
make $J NO_SOLIB=1 CFLAGS="$LCF" LDFLAGS="$EXEC_LDFLAGS" keyctl libkeyutils.a;
install -D -m 0755 keyctl $DESTDIR/bin/keyctl ;
install -D -m 0644 keyutils.h $DESTDIR/include/keyutils.h ;
install -D -m 0644 libkeyutils.a $DESTDIR/include/libkeyutils.a ;
)
fi
if test -z "$SKIP_FSVERITY"; then
build_start "fsverity"
(cd fsverity; \
ver=$(git describe --always --dirty); echo "fsverity $ver ($(git log -1 --pretty=%cD))" > ../fsverity.ver ; \
$MAKE_CLEAN ; make $J install DESTDIR=$DESTDIR PREFIX=/usr)
fi
if test -z "$SKIP_IMA_EVM_UTILS" ; then
build_start "ima-evm-utils"
(cd ima-evm-utils; \
ver=$(git describe --always --dirty); echo "ima-evm-utils $ver ($(git log -1 --pretty=%cD))" > ../ima-evm-utils.ver ; \
mv INSTALL INSTALL.save ; ./autogen.sh; mv INSTALL.save INSTALL ; \
CFLAGS="$LCF -I$DESTDIR/include" \
LDFLAGS="$LLF $EXEC_LDFLAGS -static -L$DESTDIR/lib" \
./configure $cross --prefix=$DESTDIR ; $MAKE_CLEAN ; \
make $J LDFLAGS="$LLF $EXEC_LLDFLAGS -L$DESTDIR/lib" dist_man_MANS= ; \
make $J install dist_man_MANS= )
fi
if test -z "$SKIP_UTIL_LINUX" ; then
build_start "util-linux"
if test -z "$UTIL_LINUX_LIBS_ONLY" ; then
export make_target="install"
else
export make_target="install-nodist_blkidincHEADERS \
install-uuidincHEADERS install-usrlib_execLTLIBRARIES"
fi
(cd util-linux ;
ver=$(git describe --always --dirty); echo "util-linux $ver ($(git log -1 --pretty=%cD))" > ../util-linux.ver ;
./autogen.sh;
CFLAGS="$LCF -I$DESTDIR/include" \
LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib" \
./configure $cross --prefix=$DESTDIR \
--disable-makeinstall-chown \
--disable-makeinstall-setuid \
--disable-use-tty-group \
--disable-bash-completion \
--disable-nls \
--disable-shared \
--disable-wall \
--disable-write \
--without-ncurses \
--without-python \
--without-systemd \
--without-tinfo;
$MAKE_CLEAN ; make $J $make_target;
# Installing mkfs causes problems because xfstests assumes that mkfs.ext4
# is in the same directory as mkfs. So rely on the system mkfs instead.
rm -f $DESTDIR/sbin/mkfs*;
)
unset make_target
fi
if test -z "$SKIP_STRESS_NG" ; then
build_start "stress-ng"
mkdir -p $DESTDIR/lib
mkdir -p $DESTDIR/bin
(cd stress-ng; \
export CFLAGS="$LCF -I$DESTDIR/include" ; \
export LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib" ; \
$MAKE_CLEAN ; make makeconfig ; make $J ; make DESTDIR=$DESTDIR $J install ; \
ver=$(git describe --always --dirty); echo "stress-ng $ver ($(git log -1 --pretty=%cD))" > ../stress-ng.ver ; \
)
fi
if test -z "$SKIP_DBENCH" ; then
build_start "dbench"
mkdir -p $DESTDIR/lib
mkdir -p $DESTDIR/bin
(cd dbench; \
autoheader ; autoconf ; \
CFLAGS="$LCF -I$DESTDIR/include" \
CPPFLAGS="-I$DESTDIR/include" \
LDFLAGS="$EXEC_LDFLAGS" \
LIBS="$LLF -L$DESTDIR/lib" \
./configure $cross --datadir=/root/xfstests/lib; \
$MAKE_CLEAN ; make $J ; cp dbench $DESTDIR/bin ; cp client.txt $DESTDIR/lib)
fi
if test -z "$SKIP_XFSPROGS" ; then
build_start "xfsprogs"
unset disable_blkid
# If libblkid.a exists and util-linux is not present, then it
# must have come from e2fslibs, and that v1 version of libblkid doesn't
# have the topology functions which xfsprogs needs; hence, we have to
# disable xfsprogs's use of blkid.
if test -f $DESTDIR/lib/libblkid.a -a ! -d util-linux; then
export disable_blkid="--disable-blkid"
fi
(cd libinih ; $MAKE_CLEAN ; make CFLAGS="$LCF -I$DESTDIR/include" ; \
make install DESTDIR=$DESTDIR)
(cd xfsprogs-dev; \
export CFLAGS="$LCF -I$DESTDIR/include" ; \
export CPPFLAGS="-I$DESTDIR/include" ; \
export LDFLAGS="$LLF -static -L$DESTDIR/lib" ; \
export LIBS=-lpthread ; \
export LOCAL_CONFIGURE_OPTIONS="$cross --prefix=/ --disable-lib64 --disable-gettext --disable-libicu --without-selinux $disable_blkid" ; \
make $J realclean ; make $J configure ; \
ver=$(git describe --always --dirty); echo "xfsprogs $ver ($(git log -1 --pretty=%cD))" > ../xfsprogs.ver ; \
aclocal -I m4 ; autoconf -I m4 ; \
./configure $LOCAL_CONFIGURE_OPTIONS ; \
make $J LLDFLAGS=-all-static V=1 PLDLIBS="$android_compat" ; \
DIST_ROOT=$DESTDIR make prefix=/ $J install; \
DIST_ROOT=$DESTDIR make prefix=/ $J install-dev)
unset disable_blkid
fi
find . -name \*.la | xargs rm -f # Die, libtool, die!!!!
if test -z "$SKIP_FIO"; then
build_start "fio"
(cd fio; \
ver=$(git describe --always --dirty); echo "fio $ver ($(git log -1 --pretty=%cD))" > ../fio.ver ; \
export CFLAGS="$LCF -I$DESTDIR/include" ; \
export LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib" ; \
$MAKE_CLEAN ; ./configure $crossfio --disable-native --extra-cflags="$CFLAGS"; make V=1 prefix=/ $J; make prefix=/ V=1 DESTDIR=$DESTDIR $J install)
fi
if test -z "$SKIP_XFSTESTS" ; then
build_start "xfstests"
(cd xfstests-dev; \
ver=$(git describe --always --dirty); echo "xfstests $ver ($(git log -1 --pretty=%cD))" > ../xfstests.ver ; \
autoreconf --include=m4 ; \
export CFLAGS="$LCF -I$DESTDIR/include -fno-stack-protector" ; \
export CPPFLAGS="-I$DESTDIR/include" ; \
export LDFLAGS="$LLF -static -L$DESTDIR/lib" ; \
export LIBS=-lpthread ; \
export LOCAL_CONFIGURE_OPTIONS="$cross" ; \
libtoolize -i ; $MAKE_CLEAN ; \
./configure $cross ; \
make $J LLDFLAGS=$EXEC_LLDFLAGS PLDLIBS="$android_compat" BUILD_VERBOSE=1)
fi
if test -z "$SKIP_QUOTA"; then
build_start "quota-tools"
#
# Hack around older quota-tools's lack of cross compilation support
#
if test -f quota/Makefile.in && ! grep -q "@CC@" quota/Makefile.in ; then
echo "No @CC@"
ed quota/Makefile.in <<EOF
1i
CC = @CC@
.
w
q
EOF
fi
(cd quota; \
ver=$(git describe --always --dirty); echo "quota $ver ($(git log -1 --pretty=%cD))" > ../quota.ver ; \
export CFLAGS="$LCF -I$DESTDIR/include" ; \
export LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib $EXEC_LDFLAGS" ; \
export CPPFLAGS="-I$DESTDIR/include" ; \
autoreconf -fvi ; \
./configure $cross --enable-ext2direct=no --enable-nls=no --prefix=$DESTDIR ; \
$MAKE_CLEAN ; make AM_LDFLAGS="" V=1 $J; make V=1 $J install)
fi
if test -z "$SKIP_SYZKALLER"; then
build_start "syzkaller"
(cd go/src/github.com/google/syzkaller; \
ver=$(git describe --always --dirty); echo "syzkaller $ver ($(git log -1 --pretty=%cD))" > ../../../../../syzkaller.ver ; \
$MAKE_CLEAN ; make $J execprog executor ; cp bin/*/syz-* $DESTDIR/bin)
fi
if test -z "$SKIP_BLKTESTS"; then
build_start "blktests"
(cd blktests ; $MAKE_CLEAN ; make ; \
ver=$(git describe --always --dirty); echo "blktests $ver ($(git log -1 --pretty=%cD))" > ../blktests.ver)
fi
if test -z "$SKIP_NVME_CLI"; then
build_start "nvme-cli"
(cd nvme-cli ; $MAKE_CLEAN ; make CFLAGS="$LCF -I. -I$DESTDIR/include " \
LDFLAGS="$LLF $EXEC_LDFLAGS -L$DESTDIR/lib" ; \
install -D -m 0755 nvme $DESTDIR/bin/nvme ; \
ver=$(git describe --always --dirty --tags); echo "nvme-cli $ver ($(git log -1 --pretty=%cD))" > ../nvme-cli.ver)
fi
if test -z "$SKIP_KVM_UTILS"; then
build_start "misc VM utils"
(cd misc ; LDFLAGS="$EXEC_LDFLAGS -L$DESTDIR/lib" ./configure $cross ; \
$MAKE_CLEAN ; make $J ; make install DESTDIR=$DESTDIR)
fi