blob: cee709d61d9c7a1b7860f4cffdfcd96fb799d976 [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
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010018base="$PWD"
19deps="$base/deps"
20inst="$deps/install"
21export deps inst
22
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010023if [ -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
31 ROOTFS_PREFIX="${ROOTFS_PREFIX:-/opt}"
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
44 wget -nc -q "https://uk.images.linuxcontainers.org/images/debian/stretch/armhf/default/20180114_22:42/rootfs.tar.xz"
45 tar -xf rootfs.tar.xz -C "$ROOTFS/" || true
46 echo "nameserver 8.8.8.8" > "$ROOTFS/etc/resolv.conf"
47 fi
48 mychroot -b /dev apt-get update
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010049 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 Pedrol6cae1d72018-01-11 19:15:34 +010050 fi
51 # Run jenkins.sh inside the chroot:
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010052 INSIDE_CHROOT=1 mychroot_nocwd \
53 -w /osmo-trx \
54 -b "$OSMOTRX_DIR:/osmo-trx" \
55 -b "$(which osmo-clean-workspace.sh):/usr/bin/osmo-clean-workspace.sh" \
56 -b "$(which osmo-build-dep.sh):/usr/bin/osmo-build-dep.sh" \
57 -b "$(which osmo-deps.sh):/usr/bin/osmo-deps.sh" \
58 ./contrib/jenkins.sh
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010059 exit 0
60 fi
61fi
62
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010063mkdir "$deps" || true
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020064
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010065osmo-build-dep.sh libosmocore "" "--disable-doxygen --disable-pcsc"
66
67export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
68export LD_LIBRARY_PATH="$inst/lib"
69
70set +x
71echo
72echo
73echo
74echo " =============================== osmo-trx ==============================="
75echo
76set -x
77
78cd "$base"
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020079autoreconf --install --force
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010080./configure $INSTR
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020081$MAKE $PARALLEL_MAKE
82$MAKE check \
83 || cat-testlogs.sh
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020084
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010085if [ -z "x${INSIDE_CHROOT}" ]; then
86 osmo-clean-workspace.sh
87fi