|
| 1 | +FROM ubuntu:16.04 |
| 2 | + |
| 3 | +RUN apt-get update -y && apt-get install -y --no-install-recommends \ |
| 4 | + bc \ |
| 5 | + bzip2 \ |
| 6 | + ca-certificates \ |
| 7 | + cmake \ |
| 8 | + cpio \ |
| 9 | + curl \ |
| 10 | + file \ |
| 11 | + g++ \ |
| 12 | + gcc-aarch64-linux-gnu \ |
| 13 | + git \ |
| 14 | + libc6-dev \ |
| 15 | + libc6-dev-arm64-cross \ |
| 16 | + make \ |
| 17 | + python2.7 \ |
| 18 | + qemu-system-aarch64 \ |
| 19 | + xz-utils |
| 20 | + |
| 21 | +ENV ARCH=arm64 \ |
| 22 | + CROSS_COMPILE=aarch64-linux-gnu- |
| 23 | + |
| 24 | +WORKDIR /build |
| 25 | + |
| 26 | +# Compile the kernel that we're going to run and be emulating with. This is |
| 27 | +# basically just done to be compatible with the QEMU target that we're going |
| 28 | +# to be using when running tests. If any other kernel works or if any |
| 29 | +# other QEMU target works with some other stock kernel, we can use that too! |
| 30 | +# |
| 31 | +# The `config` config file was a previously generated config file for |
| 32 | +# the kernel. This file was generated by running `make defconfig` |
| 33 | +# followed by `make menuconfig` and then enabling the IPv6 protocol page. |
| 34 | +COPY disabled/aarch64-gnu/config /build/.config |
| 35 | +RUN curl https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.42.tar.xz | \ |
| 36 | + tar xJf - && \ |
| 37 | + cd /build/linux-4.4.42 && \ |
| 38 | + cp /build/.config . && \ |
| 39 | + make -j$(nproc) all && \ |
| 40 | + cp arch/arm64/boot/Image /tmp && \ |
| 41 | + cd /build && \ |
| 42 | + rm -rf linux-4.4.42 |
| 43 | + |
| 44 | +# Compile an instance of busybox as this provides a lightweight system and init |
| 45 | +# binary which we will boot into. Only trick here is configuring busybox to |
| 46 | +# build static binaries. |
| 47 | +RUN curl https://www.busybox.net/downloads/busybox-1.21.1.tar.bz2 | tar xjf - && \ |
| 48 | + cd busybox-1.21.1 && \ |
| 49 | + make defconfig && \ |
| 50 | + sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config && \ |
| 51 | + make -j$(nproc) && \ |
| 52 | + make install && \ |
| 53 | + mv _install /tmp/rootfs && \ |
| 54 | + cd /build && \ |
| 55 | + rm -rf busybox-1.12.1 |
| 56 | + |
| 57 | +# Download the ubuntu rootfs, which we'll use as a chroot for all our tests. |
| 58 | +WORKDIR /tmp |
| 59 | +RUN mkdir rootfs/ubuntu |
| 60 | +RUN curl http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-arm64.tar.gz | \ |
| 61 | + tar xzf - -C rootfs/ubuntu && \ |
| 62 | + cd rootfs && mkdir proc sys dev etc etc/init.d |
| 63 | + |
| 64 | +# Copy over our init script, which starts up our test server and also a few |
| 65 | +# other misc tasks. |
| 66 | +COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS |
| 67 | +RUN chmod +x rootfs/etc/init.d/rcS |
| 68 | + |
| 69 | +# Helper to quickly fill the entropy pool in the kernel. |
| 70 | +COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c |
| 71 | +RUN aarch64-linux-gnu-gcc addentropy.c -o rootfs/addentropy -static |
| 72 | + |
| 73 | +COPY scripts/dumb-init.sh /scripts/ |
| 74 | +RUN sh /scripts/dumb-init.sh |
| 75 | + |
| 76 | +COPY scripts/sccache.sh /scripts/ |
| 77 | +RUN sh /scripts/sccache.sh |
| 78 | + |
| 79 | +ENTRYPOINT ["/usr/bin/dumb-init", "--"] |
| 80 | + |
| 81 | +ENV RUST_CONFIGURE_ARGS \ |
| 82 | + --target=aarch64-unknown-linux-gnu \ |
| 83 | + --qemu-aarch64-rootfs=/tmp/rootfs |
| 84 | +ENV SCRIPT python2.7 ../x.py test --target aarch64-unknown-linux-gnu |
| 85 | +ENV NO_CHANGE_USER=1 |
0 commit comments