Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | set -ex |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 3 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 4 | substr() { [ -z "${2##*$1*}" ]; } |
| 5 | |
| 6 | #apt-get install qemu qemu-user-static qemu-system-arm debootstrap fakeroot proot |
| 7 | mychroot_nocwd() { |
| 8 | # LC_ALL + LANGUAGE set to avoid lots of print errors due to locale not being set inside container |
| 9 | # PATH is needed to be able to reach binaries like ldconfig without logging in to root, which adds the paths to PATH. |
| 10 | # PROOT_NO_SECCOMP is requried due to proot bug #106 |
| 11 | 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 "$@" |
| 12 | } |
| 13 | |
| 14 | mychroot() { |
| 15 | mychroot_nocwd -w / "$@" |
| 16 | } |
| 17 | |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 18 | base="$PWD" |
| 19 | deps="$base/deps" |
| 20 | inst="$deps/install" |
| 21 | export deps inst |
| 22 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 23 | if [ -z "${INSIDE_CHROOT}" ]; then |
| 24 | |
| 25 | osmo-clean-workspace.sh |
| 26 | |
| 27 | # Only use ARM chroot if host is not ARM and the target is ARM: |
| 28 | if ! $(substr "arm" "$(uname -m)") && [ "x${INSTR}" = "x--with-neon" -o "x${INSTR}" = "x--with-neon-vfpv4" ]; then |
| 29 | |
| 30 | OSMOTRX_DIR="$PWD" # we assume we are called as contrib/jenkins.sh |
Alexander Couzens | f97296e | 2018-02-25 20:03:59 +0100 | [diff] [blame] | 31 | ROOTFS_PREFIX="${ROOTFS_PREFIX:-$HOME}" |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 32 | ROOTFS="${ROOTFS_PREFIX}/qemu-img" |
| 33 | mkdir -p "${ROOTFS_PREFIX}" |
| 34 | |
| 35 | # Prepare chroot: |
| 36 | if [ ! -d "$ROOTFS" ]; then |
| 37 | mkdir -p "$ROOTFS" |
| 38 | if [ "x${USE_DEBOOTSTRAP}" = "x1" ]; then |
| 39 | fakeroot qemu-debootstrap --foreign --include="linux-image-armmp-lpae" --arch=armhf stretch "$ROOTFS" http://ftp.de.debian.org/debian/ |
| 40 | # Hack to avoid debootstrap trying to mount /proc, as it will fail with "no permissions" and anyway proot takes care of it: |
| 41 | sed -i "s/setup_proc//g" "$ROOTFS/debootstrap/suite-script" |
| 42 | mychroot /debootstrap/debootstrap --second-stage --verbose http://ftp.de.debian.org/debian/ |
| 43 | else |
Alexander Couzens | 28b8cc6 | 2018-02-25 20:20:28 +0100 | [diff] [blame] | 44 | YESTERDAY=$(python -c 'import datetime ; print((datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d"))') |
| 45 | 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] | 46 | tar -xf rootfs.tar.xz -C "$ROOTFS/" || true |
| 47 | echo "nameserver 8.8.8.8" > "$ROOTFS/etc/resolv.conf" |
| 48 | fi |
| 49 | mychroot -b /dev apt-get update |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 50 | 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] | 51 | fi |
| 52 | # Run jenkins.sh inside the chroot: |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 53 | INSIDE_CHROOT=1 mychroot_nocwd \ |
| 54 | -w /osmo-trx \ |
| 55 | -b "$OSMOTRX_DIR:/osmo-trx" \ |
| 56 | -b "$(which osmo-clean-workspace.sh):/usr/bin/osmo-clean-workspace.sh" \ |
| 57 | -b "$(which osmo-build-dep.sh):/usr/bin/osmo-build-dep.sh" \ |
| 58 | -b "$(which osmo-deps.sh):/usr/bin/osmo-deps.sh" \ |
| 59 | ./contrib/jenkins.sh |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 60 | exit 0 |
| 61 | fi |
| 62 | fi |
| 63 | |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 64 | mkdir "$deps" || true |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 65 | |
Pau Espin Pedrol | 53bdb7f | 2018-04-16 14:27:38 +0200 | [diff] [blame] | 66 | osmo-build-dep.sh libosmocore "" "--enable-sanitize --disable-doxygen --disable-pcsc" |
Pau Espin Pedrol | e860520 | 2018-04-26 20:02:36 +0200 | [diff] [blame] | 67 | osmo-build-dep.sh libusrp |
Pau Espin Pedrol | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 68 | |
| 69 | export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH" |
| 70 | export LD_LIBRARY_PATH="$inst/lib" |
| 71 | |
| 72 | set +x |
| 73 | echo |
| 74 | echo |
| 75 | echo |
| 76 | echo " =============================== osmo-trx ===============================" |
| 77 | echo |
| 78 | set -x |
| 79 | |
| 80 | cd "$base" |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 81 | autoreconf --install --force |
Pau Espin Pedrol | e7d267f | 2018-08-30 21:04:10 +0200 | [diff] [blame] | 82 | ./configure --enable-sanitize --enable-werror --with-uhd --with-usrp1 --with-lms $INSTR |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 83 | $MAKE $PARALLEL_MAKE |
| 84 | $MAKE check \ |
| 85 | || cat-testlogs.sh |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 86 | |
Alexander Couzens | ffa4e59 | 2018-02-25 20:23:56 +0100 | [diff] [blame] | 87 | osmo-clean-workspace.sh |