blob: e600e0120a3971faef324cb872a71200842b15d0 [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
Alexander Couzensf97296e2018-02-25 20:03:59 +010031 ROOTFS_PREFIX="${ROOTFS_PREFIX:-$HOME}"
Pau Espin Pedrol6cae1d72018-01-11 19:15:34 +010032 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 Couzens28b8cc62018-02-25 20:20:28 +010044 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 Pedrol6cae1d72018-01-11 19:15:34 +010046 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 Pedrol8b843e52018-02-20 14:44:39 +010050 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 +010051 fi
52 # Run jenkins.sh inside the chroot:
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010053 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 Pedrol6cae1d72018-01-11 19:15:34 +010060 exit 0
61 fi
62fi
63
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010064mkdir "$deps" || true
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020065
Pau Espin Pedrol53bdb7f2018-04-16 14:27:38 +020066osmo-build-dep.sh libosmocore "" "--enable-sanitize --disable-doxygen --disable-pcsc"
Pau Espin Pedrol8b843e52018-02-20 14:44:39 +010067
68export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
69export LD_LIBRARY_PATH="$inst/lib"
70
71set +x
72echo
73echo
74echo
75echo " =============================== osmo-trx ==============================="
76echo
77set -x
78
79cd "$base"
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020080autoreconf --install --force
Pau Espin Pedrol53bdb7f2018-04-16 14:27:38 +020081./configure --enable-sanitize $INSTR
Neels Hofmeyr76b98cf2016-10-14 15:17:32 +020082$MAKE $PARALLEL_MAKE
83$MAKE check \
84 || cat-testlogs.sh
Neels Hofmeyrb0e1bd82017-10-27 22:54:53 +020085
Alexander Couzensffa4e592018-02-25 20:23:56 +010086osmo-clean-workspace.sh