Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 2 | # 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 Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 10 | set -ex |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 11 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 12 | substr() { [ -z "${2##*$1*}" ]; } |
| 13 | |
| 14 | #apt-get install qemu qemu-user-static qemu-system-arm debootstrap fakeroot proot |
| 15 | mychroot_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 Hauke | 066fd04 | 2019-10-13 19:08:00 +0200 | [diff] [blame^] | 18 | # PROOT_NO_SECCOMP is required due to proot bug #106 |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 19 | 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 | |
| 22 | mychroot() { |
| 23 | mychroot_nocwd -w / "$@" |
| 24 | } |
| 25 | |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 26 | base="$PWD" |
| 27 | deps="$base/deps" |
| 28 | inst="$deps/install" |
| 29 | export deps inst |
| 30 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 31 | if [ -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 Couzens | f97296e | 2018-02-25 20:03:59 +0100 | [diff] [blame] | 39 | ROOTFS_PREFIX="${ROOTFS_PREFIX:-$HOME}" |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 40 | 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 Couzens | 28b8cc6 | 2018-02-25 20:20:28 +0100 | [diff] [blame] | 52 | 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 Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 54 | 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 Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 58 | 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 Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 59 | fi |
| 60 | # Run jenkins.sh inside the chroot: |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 61 | 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 Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 68 | exit 0 |
| 69 | fi |
| 70 | fi |
| 71 | |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 72 | mkdir "$deps" || true |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 73 | |
Pau Espin Pedrol | 53bdb7f | 2018-04-16 14:27:38 +0200 | [diff] [blame] | 74 | osmo-build-dep.sh libosmocore "" "--enable-sanitize --disable-doxygen --disable-pcsc" |
Pau Espin Pedrol | 50c78df | 2019-07-29 21:35:45 +0200 | [diff] [blame] | 75 | PARALLEL_MAKE="" osmo-build-dep.sh libusrp |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 76 | |
| 77 | export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH" |
| 78 | export LD_LIBRARY_PATH="$inst/lib" |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 79 | export PATH="$inst/bin:$PATH" |
| 80 | |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 81 | CONFIG="--enable-sanitize --enable-werror --with-uhd --with-usrp1 --with-lms $INSTR" |
| 82 | |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 83 | # Additional configure options and depends |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 84 | if [ "$WITH_MANUALS" = "1" ]; then |
| 85 | osmo-build-dep.sh osmo-gsm-manuals |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 86 | CONFIG="$CONFIG --enable-manuals" |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 87 | fi |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 88 | |
| 89 | set +x |
| 90 | echo |
| 91 | echo |
| 92 | echo |
| 93 | echo " =============================== osmo-trx ===============================" |
| 94 | echo |
| 95 | set -x |
| 96 | |
| 97 | cd "$base" |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 98 | autoreconf --install --force |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 99 | ./configure $CONFIG |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 100 | $MAKE $PARALLEL_MAKE |
| 101 | $MAKE check \ |
| 102 | || cat-testlogs.sh |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 103 | DISTCHECK_CONFIGURE_FLAGS="$CONFIG" $MAKE distcheck \ |
| 104 | || cat-testlogs.sh |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 105 | |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 106 | if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then |
| 107 | make -C "$base/doc/manuals" publish |
| 108 | fi |
| 109 | |
Oliver Smith | 2ded53c | 2019-07-10 13:26:21 +0200 | [diff] [blame] | 110 | $MAKE maintainer-clean |
Alexander Couzens | ffa4e59 | 2018-02-25 20:23:56 +0100 | [diff] [blame] | 111 | osmo-clean-workspace.sh |