blob: 11def5c6dd2c91c71e9c5b2c2c9da8e665b3499a [file] [log] [blame]
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +02001#!/bin/sh
2set -ex
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +02003
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +01004substr() { [ -z "${2##*$1*}" ]; }
5
6#apt-get install qemu qemu-user-static qemu-system-arm debootstrap fakeroot proot
7mychroot_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
14mychroot() {
15 mychroot_nocwd -w / "$@"
16}
17
18if [ -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
50fi
51
52### BUILD osmo-trx
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020053
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020054autoreconf --install --force
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010055./configure $INSTR
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020056$MAKE $PARALLEL_MAKE
57$MAKE check \
58 || cat-testlogs.sh
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020059
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010060if [ -z "x${INSIDE_CHROOT}" ]; then
61 osmo-clean-workspace.sh
62fi