blob: 990e6f4b0bfe935c9a7929113cd231aab96fc1b5 [file] [log] [blame]
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +02001#!/bin/sh
Oliver Smith522cbe92018-11-30 16:34:29 +01002# jenkins build helper script for osmo-trx. This is how we build on jenkins.osmocom.org
3#
4# environment variables:
5# * INSTR: configure the CPU instruction set ("--with-sse", "--with-neon" or "--with-neon-vfpv4")
6# * WITH_MANUALS: build manual PDFs if set to "1"
7# * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1")
8# * INSIDE_CHROOT: (used internally) set to "1" when the script runs with QEMU in an ARM chroot
9#
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020010set -ex
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020011
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010012substr() { [ -z "${2##*$1*}" ]; }
13
14#apt-get install qemu qemu-user-static qemu-system-arm debootstrap fakeroot proot
15mychroot_nocwd() {
16 # LC_ALL + LANGUAGE set to avoid lots of print errors due to locale not being set inside container
17 # PATH is needed to be able to reach binaries like ldconfig without logging in to root, which adds the paths to PATH.
Martin Hauke066fd042019-10-13 19:08:00 +020018 # PROOT_NO_SECCOMP is required due to proot bug #106
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010019 LC_ALL=C LANGUAGE=C PATH="$PATH:/usr/sbin:/sbin" PROOT_NO_SECCOMP=1 proot -r "$ROOTFS" -w / -b /proc --root-id -q qemu-arm-static "$@"
20}
21
22mychroot() {
23 mychroot_nocwd -w / "$@"
24}
25
26if [ -z "${INSIDE_CHROOT}" ]; then
27
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010028 # Only use ARM chroot if host is not ARM and the target is ARM:
29 if ! $(substr "arm" "$(uname -m)") && [ "x${INSTR}" = "x--with-neon" -o "x${INSTR}" = "x--with-neon-vfpv4" ]; then
30
31 OSMOTRX_DIR="$PWD" # we assume we are called as contrib/jenkins.sh
Alexander Couzensf97296e2018-02-25 20:03:59 +010032 ROOTFS_PREFIX="${ROOTFS_PREFIX:-$HOME}"
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010033 ROOTFS="${ROOTFS_PREFIX}/qemu-img"
34 mkdir -p "${ROOTFS_PREFIX}"
35
36 # Prepare chroot:
37 if [ ! -d "$ROOTFS" ]; then
38 mkdir -p "$ROOTFS"
39 if [ "x${USE_DEBOOTSTRAP}" = "x1" ]; then
40 fakeroot qemu-debootstrap --foreign --include="linux-image-armmp-lpae" --arch=armhf stretch "$ROOTFS" http://ftp.de.debian.org/debian/
41 # Hack to avoid debootstrap trying to mount /proc, as it will fail with "no permissions" and anyway proot takes care of it:
42 sed -i "s/setup_proc//g" "$ROOTFS/debootstrap/suite-script"
43 mychroot /debootstrap/debootstrap --second-stage --verbose http://ftp.de.debian.org/debian/
44 else
Alexander Couzens28b8cc62018-02-25 20:20:28 +010045 YESTERDAY=$(python -c 'import datetime ; print((datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d"))')
46 wget -nc -q "https://uk.images.linuxcontainers.org/images/debian/stretch/armhf/default/${YESTERDAY}_22:42/rootfs.tar.xz"
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010047 tar -xf rootfs.tar.xz -C "$ROOTFS/" || true
48 echo "nameserver 8.8.8.8" > "$ROOTFS/etc/resolv.conf"
49 fi
50 mychroot -b /dev apt-get update
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010051 mychroot apt-get -y install build-essential dh-autoreconf pkg-config libuhd-dev libusb-1.0-0-dev libusb-dev git libtalloc-dev libgnutls28-dev stow
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010052 fi
53 # Run jenkins.sh inside the chroot:
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010054 INSIDE_CHROOT=1 mychroot_nocwd \
55 -w /osmo-trx \
56 -b "$OSMOTRX_DIR:/osmo-trx" \
57 -b "$(which osmo-clean-workspace.sh):/usr/bin/osmo-clean-workspace.sh" \
58 -b "$(which osmo-build-dep.sh):/usr/bin/osmo-build-dep.sh" \
59 -b "$(which osmo-deps.sh):/usr/bin/osmo-deps.sh" \
60 ./contrib/jenkins.sh
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010061 exit 0
62 fi
63fi
64
Pau Espin Pedrolfd672622020-02-19 11:53:30 +010065set -ex
66
67if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
68 echo "Error: We need to have scripts/osmo-deps.sh from http://git.osmocom.org/osmo-ci/ in PATH !"
69 exit 2
70fi
71
72base="$PWD"
73deps="$base/deps"
74inst="$deps/install"
75export deps inst
76
77osmo-clean-workspace.sh
78
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010079mkdir "$deps" || true
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020080
Pau Espin Pedrol53bdb7f2018-04-16 14:27:38 +020081osmo-build-dep.sh libosmocore "" "--enable-sanitize --disable-doxygen --disable-pcsc"
Pau Espin Pedrol50c78df2019-07-29 21:35:45 +020082PARALLEL_MAKE="" osmo-build-dep.sh libusrp
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010083
84export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
85export LD_LIBRARY_PATH="$inst/lib"
Oliver Smith522cbe92018-11-30 16:34:29 +010086export PATH="$inst/bin:$PATH"
87
Ericb7253c62022-11-28 19:21:08 +010088CONFIG="--enable-sanitize --enable-werror --with-uhd --with-usrp1 --with-lms --with-ipc --with-mstrx $INSTR"
Oliver Smith800c0292018-12-05 12:39:05 +010089
Oliver Smith522cbe92018-11-30 16:34:29 +010090# Additional configure options and depends
Oliver Smith522cbe92018-11-30 16:34:29 +010091if [ "$WITH_MANUALS" = "1" ]; then
Oliver Smith800c0292018-12-05 12:39:05 +010092 CONFIG="$CONFIG --enable-manuals"
Oliver Smith522cbe92018-11-30 16:34:29 +010093fi
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010094
95set +x
96echo
97echo
98echo
99echo " =============================== osmo-trx ==============================="
100echo
101set -x
102
103cd "$base"
Vadim Yanitskiy5a23a242022-12-14 23:43:32 +0700104git submodule status
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +0200105autoreconf --install --force
Oliver Smith800c0292018-12-05 12:39:05 +0100106./configure $CONFIG
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +0200107$MAKE $PARALLEL_MAKE
108$MAKE check \
109 || cat-testlogs.sh
Oliver Smith1c6a3452022-07-11 13:54:00 +0200110
111if arch | grep -v -q arm; then
112 DISTCHECK_CONFIGURE_FLAGS="$CONFIG" $MAKE $PARALLEL_MAKE distcheck \
113 || cat-testlogs.sh
114fi
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +0200115
Oliver Smith522cbe92018-11-30 16:34:29 +0100116if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
117 make -C "$base/doc/manuals" publish
118fi
119
Pau Espin Pedrole69a56c2020-10-12 19:48:47 +0200120$MAKE $PARALLEL_MAKE maintainer-clean
Pau Espin Pedrol03334962020-08-25 15:33:33 +0200121
Alexander Couzensffa4e592018-02-25 20:23:56 +0100122osmo-clean-workspace.sh