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 | |
| 26 | if [ -z "${INSIDE_CHROOT}" ]; then |
| 27 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 28 | # 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 Couzens | f97296e | 2018-02-25 20:03:59 +0100 | [diff] [blame] | 32 | ROOTFS_PREFIX="${ROOTFS_PREFIX:-$HOME}" |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 33 | 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 Couzens | 28b8cc6 | 2018-02-25 20:20:28 +0100 | [diff] [blame] | 45 | 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 Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 47 | 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 Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 51 | 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] | 52 | fi |
| 53 | # Run jenkins.sh inside the chroot: |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 54 | 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 Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 61 | exit 0 |
| 62 | fi |
| 63 | fi |
| 64 | |
Pau Espin Pedrol | fd67262 | 2020-02-19 11:53:30 +0100 | [diff] [blame] | 65 | set -ex |
| 66 | |
| 67 | if ! [ -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 |
| 70 | fi |
| 71 | |
| 72 | base="$PWD" |
| 73 | deps="$base/deps" |
| 74 | inst="$deps/install" |
| 75 | export deps inst |
| 76 | |
| 77 | osmo-clean-workspace.sh |
| 78 | |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 79 | mkdir "$deps" || true |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 80 | |
Pau Espin Pedrol | 53bdb7f | 2018-04-16 14:27:38 +0200 | [diff] [blame] | 81 | osmo-build-dep.sh libosmocore "" "--enable-sanitize --disable-doxygen --disable-pcsc" |
Pau Espin Pedrol | 50c78df | 2019-07-29 21:35:45 +0200 | [diff] [blame] | 82 | PARALLEL_MAKE="" osmo-build-dep.sh libusrp |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 83 | |
| 84 | export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH" |
| 85 | export LD_LIBRARY_PATH="$inst/lib" |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 86 | export PATH="$inst/bin:$PATH" |
| 87 | |
Eric Wild | 1e17c4f | 2020-03-24 17:19:27 +0100 | [diff] [blame] | 88 | CONFIG="--enable-sanitize --enable-werror --with-uhd --with-usrp1 --with-lms --with-ipc $INSTR" |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 89 | |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 90 | # Additional configure options and depends |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 91 | if [ "$WITH_MANUALS" = "1" ]; then |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 92 | CONFIG="$CONFIG --enable-manuals" |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 93 | fi |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 94 | |
| 95 | set +x |
| 96 | echo |
| 97 | echo |
| 98 | echo |
| 99 | echo " =============================== osmo-trx ===============================" |
| 100 | echo |
| 101 | set -x |
| 102 | |
| 103 | cd "$base" |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 104 | autoreconf --install --force |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 105 | ./configure $CONFIG |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 106 | $MAKE $PARALLEL_MAKE |
| 107 | $MAKE check \ |
| 108 | || cat-testlogs.sh |
Pau Espin Pedrol | e69a56c | 2020-10-12 19:48:47 +0200 | [diff] [blame] | 109 | DISTCHECK_CONFIGURE_FLAGS="$CONFIG" $MAKE $PARALLEL_MAKE distcheck \ |
Oliver Smith | 800c029 | 2018-12-05 12:39:05 +0100 | [diff] [blame] | 110 | || cat-testlogs.sh |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 111 | |
Oliver Smith | 522cbe9 | 2018-11-30 16:34:29 +0100 | [diff] [blame] | 112 | if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then |
| 113 | make -C "$base/doc/manuals" publish |
| 114 | fi |
| 115 | |
Pau Espin Pedrol | e69a56c | 2020-10-12 19:48:47 +0200 | [diff] [blame] | 116 | $MAKE $PARALLEL_MAKE maintainer-clean |
Pau Espin Pedrol | 0333496 | 2020-08-25 15:33:33 +0200 | [diff] [blame] | 117 | |
| 118 | # Verify distro-specific package patches apply: |
| 119 | for patch in debian/patches/*.patch; do |
| 120 | patch --dry-run -p1 < "$patch" |
| 121 | done |
| 122 | |
Alexander Couzens | ffa4e59 | 2018-02-25 20:23:56 +0100 | [diff] [blame] | 123 | osmo-clean-workspace.sh |