blob: 84e4ea7d207f31954da0f7ef895721f1b3f4f724 [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
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010026base="$PWD"
27deps="$base/deps"
28inst="$deps/install"
29export deps inst
30
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010031if [ -z "${INSIDE_CHROOT}" ]; then
32
33 osmo-clean-workspace.sh
34
35 # Only use ARM chroot if host is not ARM and the target is ARM:
36 if ! $(substr "arm" "$(uname -m)") && [ "x${INSTR}" = "x--with-neon" -o "x${INSTR}" = "x--with-neon-vfpv4" ]; then
37
38 OSMOTRX_DIR="$PWD" # we assume we are called as contrib/jenkins.sh
Alexander Couzensf97296e2018-02-25 20:03:59 +010039 ROOTFS_PREFIX="${ROOTFS_PREFIX:-$HOME}"
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010040 ROOTFS="${ROOTFS_PREFIX}/qemu-img"
41 mkdir -p "${ROOTFS_PREFIX}"
42
43 # Prepare chroot:
44 if [ ! -d "$ROOTFS" ]; then
45 mkdir -p "$ROOTFS"
46 if [ "x${USE_DEBOOTSTRAP}" = "x1" ]; then
47 fakeroot qemu-debootstrap --foreign --include="linux-image-armmp-lpae" --arch=armhf stretch "$ROOTFS" http://ftp.de.debian.org/debian/
48 # Hack to avoid debootstrap trying to mount /proc, as it will fail with "no permissions" and anyway proot takes care of it:
49 sed -i "s/setup_proc//g" "$ROOTFS/debootstrap/suite-script"
50 mychroot /debootstrap/debootstrap --second-stage --verbose http://ftp.de.debian.org/debian/
51 else
Alexander Couzens28b8cc62018-02-25 20:20:28 +010052 YESTERDAY=$(python -c 'import datetime ; print((datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d"))')
53 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 +010054 tar -xf rootfs.tar.xz -C "$ROOTFS/" || true
55 echo "nameserver 8.8.8.8" > "$ROOTFS/etc/resolv.conf"
56 fi
57 mychroot -b /dev apt-get update
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010058 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 +010059 fi
60 # Run jenkins.sh inside the chroot:
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010061 INSIDE_CHROOT=1 mychroot_nocwd \
62 -w /osmo-trx \
63 -b "$OSMOTRX_DIR:/osmo-trx" \
64 -b "$(which osmo-clean-workspace.sh):/usr/bin/osmo-clean-workspace.sh" \
65 -b "$(which osmo-build-dep.sh):/usr/bin/osmo-build-dep.sh" \
66 -b "$(which osmo-deps.sh):/usr/bin/osmo-deps.sh" \
67 ./contrib/jenkins.sh
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010068 exit 0
69 fi
70fi
71
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010072mkdir "$deps" || true
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020073
Pau Espin Pedrol53bdb7f2018-04-16 14:27:38 +020074osmo-build-dep.sh libosmocore "" "--enable-sanitize --disable-doxygen --disable-pcsc"
Pau Espin Pedrol50c78df2019-07-29 21:35:45 +020075PARALLEL_MAKE="" osmo-build-dep.sh libusrp
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010076
77export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
78export LD_LIBRARY_PATH="$inst/lib"
Oliver Smith522cbe92018-11-30 16:34:29 +010079export PATH="$inst/bin:$PATH"
80
Oliver Smith800c0292018-12-05 12:39:05 +010081CONFIG="--enable-sanitize --enable-werror --with-uhd --with-usrp1 --with-lms $INSTR"
82
Oliver Smith522cbe92018-11-30 16:34:29 +010083# Additional configure options and depends
Oliver Smith522cbe92018-11-30 16:34:29 +010084if [ "$WITH_MANUALS" = "1" ]; then
85 osmo-build-dep.sh osmo-gsm-manuals
Oliver Smith800c0292018-12-05 12:39:05 +010086 CONFIG="$CONFIG --enable-manuals"
Oliver Smith522cbe92018-11-30 16:34:29 +010087fi
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010088
89set +x
90echo
91echo
92echo
93echo " =============================== osmo-trx ==============================="
94echo
95set -x
96
97cd "$base"
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020098autoreconf --install --force
Oliver Smith800c0292018-12-05 12:39:05 +010099./configure $CONFIG
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +0200100$MAKE $PARALLEL_MAKE
101$MAKE check \
102 || cat-testlogs.sh
Oliver Smith800c0292018-12-05 12:39:05 +0100103DISTCHECK_CONFIGURE_FLAGS="$CONFIG" $MAKE distcheck \
104 || cat-testlogs.sh
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +0200105
Oliver Smith522cbe92018-11-30 16:34:29 +0100106if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
107 make -C "$base/doc/manuals" publish
108fi
109
Oliver Smith2ded53c2019-07-10 13:26:21 +0200110$MAKE maintainer-clean
Alexander Couzensffa4e592018-02-25 20:23:56 +0100111osmo-clean-workspace.sh