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.7
.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 -DHAVE_ECC_BRAINPOOL"
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 --enable-ecccustcurves"
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 $?
92 : ${DEPS_BUILD_DIR=$BUILD_DIR/..}
93 : ${DEPS_PREFIX=/usr/local}
95 if [ -e
/etc
/os-release
]; then
97 elif [ -e
/usr
/lib
/os-release
]; then
105 CFLAGS
="-g -O2 -Wall -Wno-format -Wno-format-security -Wno-pointer-sign -Werror"
109 # should be the default, but lets make sure
110 CONFIG
="--with-printf-hooks=glibc"
113 CONFIG
="--disable-defaults --enable-pki --enable-openssl --enable-pem"
114 export TESTS_PLUGINS
="test-vectors pem openssl!"
118 CONFIG
="--disable-defaults --enable-pki --enable-gcrypt --enable-pkcs1"
119 export TESTS_PLUGINS
="test-vectors pkcs1 gcrypt!"
120 if [ "$ID" = "ubuntu" -a
"$VERSION_ID" = "20.04" ]; then
121 DEPS
="libgcrypt20-dev"
123 DEPS
="libgcrypt11-dev"
127 CONFIG
="--disable-defaults --enable-pki --enable-botan --enable-pem"
128 export TESTS_PLUGINS
="test-vectors pem botan!"
130 if test "$1" = "build-deps"; then
135 CONFIG
="--disable-defaults --enable-pki --enable-wolfssl --enable-pem"
136 export TESTS_PLUGINS
="test-vectors pem wolfssl!"
137 # build with custom options to enable all the features the plugin supports
139 if test "$1" = "build-deps"; then
144 CONFIG
="--with-printf-hooks=builtin"
146 all|coverage|sonarcloud
)
147 if [ "$TEST" = "sonarcloud" ]; then
148 if [ -z
"$SONAR_PROJECT" -o
-z
"$SONAR_ORGANIZATION" -o
-z
"$SONAR_TOKEN" ]; then
149 echo "The SONAR_PROJECT, SONAR_ORGANIZATION and SONAR_TOKEN" \
150 "environment variables are required to run this test"
154 CONFIG
="--enable-all --disable-android-dns --disable-android-log
155 --disable-kernel-pfroute --disable-keychain
156 --disable-lock-profiler --disable-padlock --disable-fuzzing
157 --disable-osx-attr --disable-tkm --disable-uci
158 --disable-unwind-backtraces
159 --disable-svc --disable-dbghelp-backtraces --disable-socket-win
160 --disable-kernel-wfp --disable-kernel-iph --disable-winhttp
161 --disable-python-eggs-install"
162 # not enabled on the build server
163 CONFIG
="$CONFIG --disable-af-alg"
164 if test "$TEST" != "coverage"; then
165 CONFIG
="$CONFIG --disable-coverage"
167 # not actually required but configure checks for it
170 # Botan requires newer compilers, so disable it on Ubuntu 16.04
171 if [ "$ID" = "ubuntu" -a
"$VERSION_ID" = "16.04" ]; then
172 CONFIG
="$CONFIG --disable-botan"
174 DEPS
="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
175 libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
176 libldap2-dev libpcsclite-dev libpam0g-dev binutils-dev libnm-dev
177 libgcrypt20-dev libjson-c-dev python3-pip libtspi-dev libsystemd-dev"
178 if [ "$ID" = "ubuntu" -a
"$VERSION_ID" = "20.04" ]; then
179 DEPS
="$DEPS libiptc-dev"
181 DEPS
="$DEPS iptables-dev"
184 if test "$1" = "build-deps"; then
185 if [ "$ID" != "ubuntu" -o
"$VERSION_ID" != "16.04" ]; then
193 CONFIG
="--disable-defaults --enable-svc --enable-ikev2
194 --enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
195 --enable-constraints --enable-revocation --enable-pem --enable-pkcs1
196 --enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
197 --enable-eap-tnc --enable-eap-ttls --enable-eap-identity
198 --enable-updown --enable-ext-auth --enable-libipsec --enable-pkcs11
199 --enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
200 --enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
201 --enable-pki --enable-swanctl --enable-socket-win
202 --enable-kernel-iph --enable-kernel-wfp --enable-winhttp"
203 # no make check for Windows binaries unless we run on a windows host
204 if test "$APPVEYOR" != "True"; then
207 CONFIG
="$CONFIG --enable-openssl"
208 CFLAGS
="$CFLAGS -I$OPENSSL_DIR/include"
209 LDFLAGS
="-L$OPENSSL_DIR"
212 CFLAGS
="$CFLAGS -mno-ms-bitfields"
213 DEPS
="gcc-mingw-w64-base"
216 CONFIG
="--host=x86_64-w64-mingw32 $CONFIG --enable-dbghelp-backtraces"
217 DEPS
="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev $DEPS"
218 CC
="x86_64-w64-mingw32-gcc"
221 CONFIG
="--host=i686-w64-mingw32 $CONFIG"
222 DEPS
="gcc-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev $DEPS"
223 CC
="i686-w64-mingw32-gcc"
228 if test "$1" = "deps"; then
229 git clone git
://git.strongswan.org
/android-ndk-boringssl.git
-b ndk-static \
230 src
/frontends
/android
/app
/src
/main
/jni
/openssl
235 # this causes a false positive in ip-packet.c since Xcode 8.3
236 CFLAGS
="$CFLAGS -Wno-address-of-packed-member"
237 # use the same options as in the Homebrew Formula
238 CONFIG
="--disable-defaults --enable-charon --enable-cmd --enable-constraints
239 --enable-curl --enable-eap-gtc --enable-eap-identity
240 --enable-eap-md5 --enable-eap-mschapv2 --enable-farp --enable-ikev1
241 --enable-ikev2 --enable-kernel-libipsec --enable-kernel-pfkey
242 --enable-kernel-pfroute --enable-nonce --enable-openssl
243 --enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
244 --enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
245 --enable-scepclient --enable-socket-default --enable-sshkey
246 --enable-stroke --enable-swanctl --enable-unity --enable-updown
247 --enable-x509 --enable-xauth-generic"
248 DEPS
="automake autoconf libtool bison gettext openssl curl"
249 BREW_PREFIX
=$
(brew
--prefix
)
250 export PATH
=$BREW_PREFIX/opt
/bison
/bin
:$PATH
251 export ACLOCAL_PATH
=$BREW_PREFIX/opt
/gettext/share
/aclocal
:$ACLOCAL_PATH
252 for pkg
in openssl curl
254 PKG_CONFIG_PATH
=$BREW_PREFIX/opt
/$pkg/lib
/pkgconfig
:$PKG_CONFIG_PATH
255 CPPFLAGS
="-I$BREW_PREFIX/opt/$pkg/include $CPPFLAGS"
256 LDFLAGS
="-L$BREW_PREFIX/opt/$pkg/lib $LDFLAGS"
258 export PKG_CONFIG_PATH
263 # use the options of the FreeBSD port (including options), except smp,
264 # which requires a patch but is deprecated anyway, only using the builtin
266 CONFIG
="--enable-kernel-pfkey --enable-kernel-pfroute --disable-scripts
267 --disable-kernel-netlink --enable-openssl --enable-eap-identity
268 --enable-eap-md5 --enable-eap-tls --enable-eap-mschapv2
269 --enable-eap-peap --enable-eap-ttls --enable-md4 --enable-blowfish
270 --enable-addrblock --enable-whitelist --enable-cmd --enable-curl
271 --enable-eap-aka --enable-eap-aka-3gpp2 --enable-eap-dynamic
272 --enable-eap-radius --enable-eap-sim --enable-eap-sim-file
273 --enable-gcm --enable-ipseckey --enable-kernel-libipsec
274 --enable-load-tester --enable-ldap --enable-mediation
275 --enable-mysql --enable-sqlite --enable-tpm --enable-tss-tss2
276 --enable-unbound --enable-unity --enable-xauth-eap --enable-xauth-pam
277 --with-printf-hooks=builtin --enable-attr-sql --enable-sql
279 DEPS
="git gmp openldap-client libxml2 mysql80-client sqlite3 unbound ldns tpm2-tss"
280 export GPERF
=/usr
/local/bin
/gperf
281 export LEX
=/usr
/local/bin
/flex
284 CFLAGS
="$CFLAGS -DNO_CHECK_MEMWIPE"
285 CONFIG
="--enable-fuzzing --enable-static --disable-shared --disable-scripts
286 --enable-imc-test --enable-tnccs-20"
287 # don't run any of the unit tests
288 export TESTS_RUNNERS
=
290 if test -z
"$1"; then
291 if test -z
"$FUZZING_CORPORA"; then
292 git clone
--depth
1 https
://github.com
/strongswan
/fuzzing-corpora.git fuzzing-corpora
293 export FUZZING_CORPORA
=$BUILD_DIR/fuzzing-corpora
295 # these are about the same as those on OSS-Fuzz (except for the
296 # symbolize options and strip_path_prefix)
297 export ASAN_OPTIONS
=redzone
=16:handle_sigill
=1:strict_string_check
=1:\
298 allocator_release_to_os_interval_ms
=500:strict_memcmp
=1:detect_container_overflow
=1:\
299 coverage
=0:allocator_may_return_null
=1:use_sigaltstack
=1:detect_stack_use_after_return
=1:\
300 alloc_dealloc_mismatch
=0:detect_leaks
=1:print_scariness
=1:max_uar_stack_size_log
=16:\
301 handle_abort
=1:check_malloc_usable_size
=0:quarantine_size_mb
=10:detect_odr_violation
=0:\
302 symbolize
=1:handle_segv
=1:fast_unwind_on_fatal
=0:external_symbolizer_path
=/usr
/bin
/llvm-symbolizer-3.5
306 DEPS
="gnome-common libsecret-1-dev libgtk-3-dev libnm-dev libnma-dev"
307 if test "$TEST" = "nm"; then
308 DEPS
="$DEPS libnm-glib-vpn-dev libnm-gtk-dev"
310 CONFIG
="$CONFIG --without-libnm-glib"
312 cd src
/frontends
/gnome
313 # don't run ./configure with ./autogen.sh
321 CONFIG
="--disable-defaults"
327 if test -z
"$1"; then
329 # after rebases or for new/duplicate branches, the passed base commit
330 # ID might not be valid
331 git rev-parse
-q
--verify
$base^
{commit
}
333 # this will always compare against master, while via base we
334 # otherwise only contains "new" commits
335 base
=$
(git merge-base origin
/master
${COMMIT_ID})
337 base
=$
(git rev-parse
$base)
339 echo "Starting code review for $COMMIT_ID (base $base) on lgtm.com"
340 git
diff --binary
$base > lgtm.
patch ||
exit $?
341 curl
-s
-X POST
--data-binary @lgtm.
patch \
342 "https://lgtm.com/api/v1.0/codereviews/${LGTM_PROJECT}?base=${base}&external-id=${BUILD_NUMBER}" \
343 -H
'Content-Type: application/octet-stream' \
344 -H
'Accept: application/json' \
345 -H
"Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res ||
exit $?
346 lgtm_check_url
=$
(jq
-r
'."task-result-url"' lgtm.res
)
347 if [ -z
"$lgtm_check_url" -o
"$lgtm_check_url" = "null" ]; then
351 lgtm_url
=$
(jq
-r
'."task-result"."results-url"' lgtm.res
)
352 echo "Progress and full results: ${lgtm_url}"
354 echo -n
"Waiting for completion: "
356 while [ "$lgtm_status" = "pending" ]; do
358 curl
-s
-X GET
"${lgtm_check_url}" \
359 -H
'Accept: application/json' \
360 -H
"Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res
366 lgtm_status
=$
(jq
-r
'.status' lgtm.res
)
370 if [ "$lgtm_status" != "success" ]; then
371 lgtm_message
=$
(jq
-r
'.["status-message"]' lgtm.res
)
372 echo "Code review failed: ${lgtm_message}"
375 lgtm_new
=$
(jq
-r
'.languages[].new' lgtm.res |
awk '{t+=$1} END {print t}')
376 lgtm_fixed
=$
(jq
-r
'.languages[].fixed' lgtm.res |
awk '{t+=$1} END {print t}')
377 echo -n
"Code review complete: "
378 printf "%b\n" "\e[1;31m${lgtm_new}\e[0m new alerts, \e[1;32m${lgtm_fixed}\e[0m fixed"
383 echo "$0: unknown test $TEST" >&2
392 sudo apt-get update
-qq
&& \
393 sudo apt-get
install -qq bison flex gperf
gettext $DEPS
400 pkg
install -y automake autoconf libtool pkgconf
&& \
401 pkg
install -y bison flex gperf
gettext $DEPS
407 test -z
"$PYDEPS" || pip3
-q
install --user
$PYDEPS
418 --disable-dependency-tracking
419 --enable-silent-rules
420 --enable-test-vectors
421 --enable-monolithic=${MONOLITHIC-no}
422 --enable-leak-detective=${LEAK_DETECTIVE-no}"
424 echo "$ ./autogen.sh"
425 .
/autogen.sh ||
exit $?
426 echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
427 CC
="$CC" CFLAGS
="$CFLAGS" .
/configure
$CONFIG ||
exit $?
437 echo "$ make $TARGET"
440 # without target, coverage is currently not supported anyway because
441 # sonarqube only supports gcov, not lcov
442 build-wrapper-linux-x86-64
--out-dir bw-output
make -j4 ||
exit $?
445 make -j4
$TARGET ||
exit $?
451 if test -s
make.warnings
; then
459 -Dsonar.
host.url
=https
://sonarcloud.io \
460 -Dsonar.projectKey
=${SONAR_PROJECT} \
461 -Dsonar.organization
=${SONAR_ORGANIZATION} \
462 -Dsonar.login
=${SONAR_TOKEN} \
463 -Dsonar.projectVersion
=$
(git describe
)+${BUILD_NUMBER} \
465 -Dsonar.cfamily.threads
=2 \
466 -Dsonar.cfamily.cache.enabled
=true \
467 -Dsonar.cfamily.cache.path
=$HOME/.sonar-cache \
468 -Dsonar.cfamily.build-wrapper-output
=bw-output ||
exit $?
469 rm -r bw-output .scannerwork
473 cd src
/frontends
/android
474 echo "$ ./gradlew build"
475 NDK_CCACHE
=ccache .
/gradlew build ||
exit $?
481 # ensure there are no unignored build artifacts (or other changes) in the Git repo
482 unclean
="$(git status --porcelain)"
483 if test -n
"$unclean"; then
484 echo "Unignored build artifacts or other changes:"