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 |
| 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 |
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 | 8b843e5 | 2018-02-20 14:44:39 +0100 | [diff] [blame] | 66 | osmo-build-dep.sh libosmocore "" "--disable-doxygen --disable-pcsc" |
| 67 | |
| 68 | export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH" |
| 69 | export LD_LIBRARY_PATH="$inst/lib" |
| 70 | |
| 71 | set +x |
| 72 | echo |
| 73 | echo |
| 74 | echo |
| 75 | echo " =============================== osmo-trx ===============================" |
| 76 | echo |
| 77 | set -x |
| 78 | |
| 79 | cd "$base" |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 80 | autoreconf --install --force |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 81 | ./configure $INSTR |
Neels Hofmeyr | 76b98cf | 2016-10-14 15:17:32 +0200 | [diff] [blame] | 82 | $MAKE $PARALLEL_MAKE |
| 83 | $MAKE check \ |
| 84 | || cat-testlogs.sh |
Neels Hofmeyr | b0e1bd8 | 2017-10-27 22:54:53 +0200 | [diff] [blame] | 85 | |
Pau Espin Pedrol | 6cae1d7 | 2018-01-11 19:15:34 +0100 | [diff] [blame] | 86 | if [ -z "x${INSIDE_CHROOT}" ]; then |
| 87 | osmo-clean-workspace.sh |
| 88 | fi |