2 # Build script for Travis CI
6 # same revision used in the build recipe of the testing environment
8 BOTAN_DIR
=$DEPS_BUILD_DIR/botan
10 if test -d "$BOTAN_DIR"; then
14 echo "$ build_botan()"
16 # if the leak detective is enabled we have to disable threading support
17 # (used for std::async) as that causes invalid frees somehow, the
18 # locking allocator causes a static leak via the first function that
19 # references it (e.g. crypter or hasher), so we disable that too
20 if test "$LEAK_DETECTIVE" = "yes"; then
21 BOTAN_CONFIG
="--without-os-features=threads
22 --disable-modules=locking_allocator"
24 # disable some larger modules we don't need for the tests
25 BOTAN_CONFIG
="$BOTAN_CONFIG --disable-modules=pkcs11,tls,x509,xmss
26 --prefix=$DEPS_PREFIX"
28 git clone https
://github.com
/randombit
/botan.git
$BOTAN_DIR &&
30 git checkout
-qf $BOTAN_REV &&
31 python .
/configure.py
--amalgamation $BOTAN_CONFIG &&
32 make -j4 libs
>/dev
/null
&&
33 sudo
make install >/dev
/null
&&
34 sudo ldconfig ||
exit $?
40 WOLFSSL_REV
=v4.4
.0-stable
41 WOLFSSL_DIR
=$DEPS_BUILD_DIR/wolfssl
43 if test -d "$WOLFSSL_DIR"; then
47 echo "$ build_wolfssl()"
49 WOLFSSL_CFLAGS
="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB"
50 WOLFSSL_CONFIG
="--prefix=$DEPS_PREFIX
51 --disable-crypttests --disable-examples
52 --enable-keygen --enable-rsapss --enable-aesccm
53 --enable-aesctr --enable-des3 --enable-camellia
54 --enable-curve25519 --enable-ed25519
55 --enable-curve448 --enable-ed448
56 --enable-sha3 --enable-shake256"
58 git clone https
://github.com
/wolfSSL
/wolfssl.git
$WOLFSSL_DIR &&
60 git checkout
-qf $WOLFSSL_REV &&
62 .
/configure C_EXTRA_FLAGS
="$WOLFSSL_CFLAGS" $WOLFSSL_CONFIG &&
63 make -j4 >/dev
/null
&&
64 sudo
make install >/dev
/null
&&
65 sudo ldconfig ||
exit $?
72 TSS2_PKG
=tpm2-tss-
$TSS2_REV
73 TSS2_DIR
=$DEPS_BUILD_DIR/$TSS2_PKG
74 TSS2_SRC
=https
://github.com
/tpm2-software
/tpm2-tss
/releases
/download
/$TSS2_REV/$TSS2_PKG.
tar.gz
76 if test -d "$TSS2_DIR"; then
82 curl
-L $TSS2_SRC |
tar xz
-C $DEPS_BUILD_DIR &&
84 .
/configure
--prefix=$DEPS_PREFIX --disable-doxygen-doc &&
85 make -j4 >/dev
/null
&&
86 sudo
make install >/dev
/null
&&
87 sudo ldconfig ||
exit $?
91 : ${TRAVIS_BUILD_DIR=$PWD}
92 : ${DEPS_BUILD_DIR=$TRAVIS_BUILD_DIR/..}
93 : ${DEPS_PREFIX=/usr/local}
99 CFLAGS
="-g -O2 -Wall -Wno-format -Wno-format-security -Wno-pointer-sign -Werror"
103 # should be the default, but lets make sure
104 CONFIG
="--with-printf-hooks=glibc"
107 CONFIG
="--disable-defaults --enable-pki --enable-openssl --enable-pem"
108 export TESTS_PLUGINS
="test-vectors pem openssl!"
112 CONFIG
="--disable-defaults --enable-pki --enable-gcrypt --enable-pkcs1"
113 export TESTS_PLUGINS
="test-vectors pkcs1 gcrypt!"
114 DEPS
="libgcrypt11-dev"
117 CONFIG
="--disable-defaults --enable-pki --enable-botan --enable-pem"
118 export TESTS_PLUGINS
="test-vectors pem botan!"
120 if test "$1" = "build-deps"; then
125 CONFIG
="--disable-defaults --enable-pki --enable-wolfssl --enable-pem"
126 export TESTS_PLUGINS
="test-vectors pem wolfssl!"
127 # build with custom options to enable all the features the plugin supports
129 if test "$1" = "build-deps"; then
134 CONFIG
="--with-printf-hooks=builtin"
136 all|coverage|sonarcloud
)
137 CONFIG
="--enable-all --disable-android-dns --disable-android-log
138 --disable-kernel-pfroute --disable-keychain
139 --disable-lock-profiler --disable-padlock --disable-fuzzing
140 --disable-osx-attr --disable-tkm --disable-uci
141 --disable-unwind-backtraces
142 --disable-svc --disable-dbghelp-backtraces --disable-socket-win
143 --disable-kernel-wfp --disable-kernel-iph --disable-winhttp"
144 # not enabled on the build server
145 CONFIG
="$CONFIG --disable-af-alg"
146 if test "$TRAVIS_CPU_ARCH" != "amd64"; then
147 CONFIG
="$CONFIG --disable-aesni --disable-rdrand"
149 if test "$TEST" != "coverage"; then
150 CONFIG
="$CONFIG --disable-coverage"
152 # not actually required but configure checks for it
155 # Botan requires GCC 5.0, so disable it on Ubuntu 16.04
156 if test -n "$UBUNTU_XENIAL"; then
157 CONFIG
="$CONFIG --disable-botan"
159 DEPS
="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
160 libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
161 libpcsclite-dev libpam0g-dev binutils-dev libnm-dev libgcrypt20-dev
162 libjson-c-dev iptables-dev python-pip libtspi-dev libsystemd-dev"
164 if test "$1" = "build-deps"; then
165 if test -z "$UBUNTU_XENIAL"; then
173 CONFIG
="--disable-defaults --enable-svc --enable-ikev2
174 --enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
175 --enable-constraints --enable-revocation --enable-pem --enable-pkcs1
176 --enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
177 --enable-eap-tnc --enable-eap-ttls --enable-eap-identity
178 --enable-updown --enable-ext-auth --enable-libipsec
179 --enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
180 --enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
181 --enable-pki --enable-swanctl --enable-socket-win
182 --enable-kernel-iph --enable-kernel-wfp --enable-winhttp"
183 # no make check for Windows binaries unless we run on a windows host
184 if test "$APPVEYOR" != "True"; then
188 CONFIG
="$CONFIG --enable-openssl"
189 CFLAGS
="$CFLAGS -I/c/OpenSSL-$TEST/include"
190 LDFLAGS
="-L/c/OpenSSL-$TEST"
193 CFLAGS
="$CFLAGS -mno-ms-bitfields"
194 DEPS
="gcc-mingw-w64-base"
197 CONFIG
="--host=x86_64-w64-mingw32 $CONFIG --enable-dbghelp-backtraces"
198 DEPS
="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev $DEPS"
199 CC
="$CCACHE x86_64-w64-mingw32-gcc"
202 CONFIG
="--host=i686-w64-mingw32 $CONFIG"
203 DEPS
="gcc-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev $DEPS"
204 CC
="$CCACHE i686-w64-mingw32-gcc"
209 # this causes a false positive in ip-packet.c since Xcode 8.3
210 CFLAGS
="$CFLAGS -Wno-address-of-packed-member"
211 # use the same options as in the Homebrew Formula
212 CONFIG
="--disable-defaults --enable-charon --enable-cmd --enable-constraints
213 --enable-curl --enable-eap-gtc --enable-eap-identity
214 --enable-eap-md5 --enable-eap-mschapv2 --enable-ikev1 --enable-ikev2
215 --enable-kernel-libipsec --enable-kernel-pfkey
216 --enable-kernel-pfroute --enable-nonce --enable-openssl
217 --enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
218 --enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
219 --enable-scepclient --enable-socket-default --enable-sshkey
220 --enable-stroke --enable-swanctl --enable-unity --enable-updown
221 --enable-x509 --enable-xauth-generic"
222 DEPS
="bison gettext openssl curl"
223 BREW_PREFIX
=$
(brew
--prefix)
224 export PATH
=$BREW_PREFIX/opt
/bison
/bin
:$PATH
225 export ACLOCAL_PATH
=$BREW_PREFIX/opt
/gettext
/share
/aclocal
:$ACLOCAL_PATH
226 for pkg
in openssl curl
228 PKG_CONFIG_PATH
=$BREW_PREFIX/opt
/$pkg/lib
/pkgconfig
:$PKG_CONFIG_PATH
229 CPPFLAGS
="-I$BREW_PREFIX/opt/$pkg/include $CPPFLAGS"
230 LDFLAGS
="-L$BREW_PREFIX/opt/$pkg/lib $LDFLAGS"
232 export PKG_CONFIG_PATH
237 # use the options of the FreeBSD port (including options), except smp,
238 # which requires a patch but is deprecated anyway, only using the builtin
240 CONFIG
="--enable-kernel-pfkey --enable-kernel-pfroute --disable-scripts
241 --disable-kernel-netlink --enable-openssl --enable-eap-identity
242 --enable-eap-md5 --enable-eap-tls --enable-eap-mschapv2
243 --enable-eap-peap --enable-eap-ttls --enable-md4 --enable-blowfish
244 --enable-addrblock --enable-whitelist --enable-cmd --enable-curl
245 --enable-eap-aka --enable-eap-aka-3gpp2 --enable-eap-dynamic
246 --enable-eap-radius --enable-eap-sim --enable-eap-sim-file
247 --enable-gcm --enable-ipseckey --enable-kernel-libipsec
248 --enable-load-tester --enable-ldap --enable-mediation
249 --enable-mysql --enable-sqlite --enable-tpm --enable-unbound
250 --enable-unity --enable-xauth-eap --enable-xauth-pam
251 --with-printf-hooks=builtin --enable-attr-sql --enable-sql"
252 DEPS
="gmp openldap-client libxml2 mysql80-client sqlite3 unbound ldns"
253 export GPERF
=/usr
/local
/bin
/gperf
254 export LEX
=/usr
/local
/bin
/flex
257 CFLAGS
="$CFLAGS -DNO_CHECK_MEMWIPE"
258 CONFIG
="--enable-fuzzing --enable-static --disable-shared --disable-scripts
259 --enable-imc-test --enable-tnccs-20"
260 # don't run any of the unit tests
261 export TESTS_RUNNERS
=
263 if test -z "$1"; then
264 if test -z "$FUZZING_CORPORA"; then
265 git clone
--depth 1 https
://github.com
/strongswan
/fuzzing-corpora.git fuzzing-corpora
266 export FUZZING_CORPORA
=$TRAVIS_BUILD_DIR/fuzzing-corpora
268 # these are about the same as those on OSS-Fuzz (except for the
269 # symbolize options and strip_path_prefix)
270 export ASAN_OPTIONS
=redzone
=16:handle_sigill
=1:strict_string_check
=1:\
271 allocator_release_to_os_interval_ms
=500:strict_memcmp
=1:detect_container_overflow
=1:\
272 coverage
=0:allocator_may_return_null
=1:use_sigaltstack
=1:detect_stack_use_after_return
=1:\
273 alloc_dealloc_mismatch
=0:detect_leaks
=1:print_scariness
=1:max_uar_stack_size_log
=16:\
274 handle_abort
=1:check_malloc_usable_size
=0:quarantine_size_mb
=10:detect_odr_violation
=0:\
275 symbolize
=1:handle_segv
=1:fast_unwind_on_fatal
=0:external_symbolizer_path
=/usr
/bin
/llvm-symbolizer-3.5
279 DEPS
="gnome-common libsecret-1-dev libgtk-3-dev libnm-dev libnma-dev"
280 if test "$TEST" = "nm"; then
281 DEPS
="$DEPS libnm-glib-vpn-dev libnm-gtk-dev"
283 CONFIG
="$CONFIG --without-libnm-glib"
285 cd src
/frontends
/gnome
286 # don't run ./configure with ./autogen.sh
294 CONFIG
="--disable-defaults"
300 if test -z "$1"; then
301 # fall back to the parent of the latest commit (on new branches we might
302 # not have a range, also on duplicate branches)
303 base
="${TRAVIS_COMMIT}^"
304 if test -n "$TRAVIS_COMMIT_RANGE"; then
305 base
="${TRAVIS_COMMIT_RANGE%...*}"
306 # after rebases, the first commit ID in the range might not be valid
307 git rev-parse
-q --verify $base
309 # this will always compare against master, while the range
310 # otherwise only contains "new" commits
311 base
=$
(git merge-base origin
/master
${TRAVIS_COMMIT})
314 base
=$
(git rev-parse
$base)
315 project_id
=1506185006272
317 echo "Starting code review for $TRAVIS_COMMIT (base $base) on lgtm.com"
318 git
diff --binary $base > lgtm.
patch ||
exit $?
319 curl
-s -X POST
--data-binary @lgtm.
patch \
320 "https://lgtm.com/api/v1.0/codereviews/${project_id}?base=${base}&external-id=${TRAVIS_BUILD_NUMBER}" \
321 -H 'Content-Type: application/octet-stream' \
322 -H 'Accept: application/json' \
323 -H "Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res ||
exit $?
324 lgtm_check_url
=$
(jq
-r '."task-result-url"' lgtm.res
)
325 if [ "$lgtm_check_url" = "null" ]; then
329 lgtm_url
=$
(jq
-r '."task-result"."results-url"' lgtm.res
)
330 echo "Progress and full results: ${lgtm_url}"
332 echo -n "Waiting for completion: "
334 while [ "$lgtm_status" = "pending" ]; do
336 curl
-s -X GET
"${lgtm_check_url}" \
337 -H 'Accept: application/json' \
338 -H "Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res
344 lgtm_status
=$
(jq
-r '.status' lgtm.res
)
348 if [ "$lgtm_status" != "success" ]; then
349 lgtm_message
=$
(jq
-r '.["status-message"]' lgtm.res
)
350 echo "Code review failed: ${lgtm_message}"
353 lgtm_new
=$
(jq
-r '.languages[].new' lgtm.res |
awk '{t+=$1} END {print t}')
354 lgtm_fixed
=$
(jq
-r '.languages[].fixed' lgtm.res |
awk '{t+=$1} END {print t}')
355 echo -n "Code review complete: "
356 printf "%b\n" "\e[1;31m${lgtm_new}\e[0m new alerts, \e[1;32m${lgtm_fixed}\e[0m fixed"
361 echo "$0: unknown test $TEST" >&2
368 case "$TRAVIS_OS_NAME" in
370 sudo apt-get update
-qq && \
371 sudo apt-get
install -qq bison flex gperf
gettext $DEPS
378 pkg
install -y automake autoconf libtool pkgconf
&& \
379 pkg
install -y bison flex gperf
gettext $DEPS
385 test -z "$PYDEPS" || pip
-q install --user $PYDEPS
396 --disable-dependency-tracking
397 --enable-silent-rules
398 --enable-test-vectors
399 --enable-monolithic=${MONOLITHIC-no}
400 --enable-leak-detective=${LEAK_DETECTIVE-no}"
402 echo "$ ./autogen.sh"
403 .
/autogen.sh ||
exit $?
404 echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
405 CC
="$CC" CFLAGS
="$CFLAGS" .
/configure
$CONFIG ||
exit $?
415 echo "$ make $TARGET"
418 # there is an issue with the platform detection that causes sonarqube to
419 # fail on bionic with "ERROR: ld.so: object '...libinterceptor-${PLATFORM}.so'
420 # from LD_PRELOAD cannot be preloaded (cannot open shared object file)"
421 # https://jira.sonarsource.com/browse/CPP-2027
422 BW_PATH
=$
(dirname $
(which build-wrapper-linux-x86-64
))
423 cp $BW_PATH/libinterceptor-x86_64.so
$BW_PATH/libinterceptor-haswell.so
424 # without target, coverage is currently not supported anyway because
425 # sonarqube only supports gcov, not lcov
426 build-wrapper-linux-x86-64
--out-dir bw-output
make -j4 ||
exit $?
429 make -j4 $TARGET ||
exit $?
435 if test -s make.warnings
; then
443 -Dsonar.projectKey
=strongswan \
444 -Dsonar.projectVersion
=$
(git describe
)+${TRAVIS_BUILD_NUMBER} \
446 -Dsonar.cfamily.threads
=2 \
447 -Dsonar.cfamily.cache.enabled
=true \
448 -Dsonar.cfamily.cache.path
=$HOME/.sonar-cache \
449 -Dsonar.cfamily.build-wrapper-output
=bw-output ||
exit $?
450 rm -r bw-output .scannerwork
456 # ensure there are no unignored build artifacts (or other changes) in the Git repo
457 unclean
="$(git status --porcelain)"
458 if test -n "$unclean"; then
459 echo "Unignored build artifacts or other changes:"