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 | |
| 18 | if [ -z "${INSIDE_CHROOT}" ]; then |
| 19 | |
| 20 | osmo-clean-workspace.sh |
| 21 | |
| 22 | # Only use ARM chroot if host is not ARM and the target is ARM: |
| 23 | if ! $(substr "arm" "$(uname -m)") && [ "x${INSTR}" = "x--with-neon" -o "x${INSTR}" = "x--with-neon-vfpv4" ]; then |
| 24 | |
| 25 | OSMOTRX_DIR="$PWD" # we assume we are called as contrib/jenkins.sh |
| 26 | ROOTFS_PREFIX="${ROOTFS_PREFIX:-/opt}" |
| 27 | ROOTFS="${ROOTFS_PREFIX}/qemu-img" |
| 28 | mkdir -p "${ROOTFS_PREFIX}" |
| 29 | |
| 30 | # Prepare chroot: |
| 31 | if [ ! -d "$ROOTFS" ]; then |
| 32 | mkdir -p "$ROOTFS" |
| 33 | if [ "x${USE_DEBOOTSTRAP}" = "x1" ]; then |
| 34 | fakeroot qemu-debootstrap --foreign --include="linux-image-armmp-lpae" --arch=armhf stretch "$ROOTFS" http://ftp.de.debian.org/debian/ |
| 35 | # Hack to avoid debootstrap trying to mount /proc, as it will fail with "no permissions" and anyway proot takes care of it: |
| 36 | sed -i "s/setup_proc//g" "$ROOTFS/debootstrap/suite-script" |
| 37 | mychroot /debootstrap/debootstrap --second-stage --verbose http://ftp.de.debian.org/debian/ |
| 38 | else |
| 39 | wget -nc -q "https://uk.images.linuxcontainers.org/images/debian/stretch/armhf/default/20180114_22:42/rootfs.tar.xz" |
| 40 | tar -xf rootfs.tar.xz -C "$ROOTFS/" || true |
| 41 | echo "nameserver 8.8.8.8" > "$ROOTFS/etc/resolv.conf" |
| 42 | fi |
| 43 | mychroot -b /dev apt-get update |
| 44 | mychroot apt-get -y install build-essential dh-autoreconf pkg-config libuhd-dev libusb-1.0-0-dev libusb-dev git |
| 45 | fi |
| 46 | # Run jenkins.sh inside the chroot: |
| 47 | INSIDE_CHROOT=1 mychroot_nocwd -w /osmo-trx -b "$OSMOTRX_DIR:/osmo-trx" -b "$(which osmo-clean-workspace.sh):/usr/bin/osmo-clean-workspace.sh" ./contrib/jenkins.sh |
| 48 | exit 0 |
| 49 | fi |
| 50 | fi |
| 51 | |
| 52 | ### BUILD osmo-trx |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 53 | |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 54 | autoreconf --install --force |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 55 | ./configure $INSTR |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 56 | $MAKE $PARALLEL_MAKE |
| 57 | $MAKE check \ |
| 58 | || cat-testlogs.sh |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 59 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 60 | if [ -z "x${INSIDE_CHROOT}" ]; then |
| 61 | osmo-clean-workspace.sh |
| 62 | fi |