2018-10-23 22:08:57 +00:00
|
|
|
# Copyright 2018 The Chromium OS Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2020-06-25 19:45:48 +00:00
|
|
|
FROM debian:buster
|
2018-09-20 21:39:59 +00:00
|
|
|
LABEL description="Test crosvm using a command like the following: \
|
2019-01-25 03:16:54 +00:00
|
|
|
docker run --privileged -v /dev/log:/dev/log -v <path to crosvm>:/platform/crosvm:ro <crosvm base image>"
|
2018-09-20 21:39:59 +00:00
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
curl \
|
2018-10-30 16:16:30 +00:00
|
|
|
g++ \
|
2019-08-16 22:37:46 +00:00
|
|
|
gcc \
|
2018-09-20 21:39:59 +00:00
|
|
|
git \
|
2019-08-16 22:37:46 +00:00
|
|
|
kmod \
|
2018-09-20 21:39:59 +00:00
|
|
|
libcap-dev \
|
2019-04-05 19:33:58 +00:00
|
|
|
libdbus-1-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libegl1-mesa-dev \
|
2019-08-16 22:37:46 +00:00
|
|
|
libfdt-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libgl1-mesa-dev \
|
|
|
|
libgles2-mesa-dev \
|
2019-10-04 20:53:44 +00:00
|
|
|
libpciaccess-dev \
|
2020-06-25 19:45:48 +00:00
|
|
|
libssl-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libtool \
|
2018-11-30 22:10:11 +00:00
|
|
|
libusb-1.0-0-dev \
|
2018-09-20 21:39:59 +00:00
|
|
|
libwayland-dev \
|
|
|
|
make \
|
|
|
|
nasm \
|
|
|
|
ninja-build \
|
|
|
|
pkg-config \
|
|
|
|
protobuf-compiler \
|
|
|
|
python3
|
|
|
|
|
|
|
|
ENV RUSTUP_HOME=/usr/local/rustup \
|
|
|
|
CARGO_HOME=/usr/local/cargo \
|
|
|
|
PATH=/usr/local/cargo/bin:$PATH \
|
2020-04-15 18:41:50 +00:00
|
|
|
RUST_VERSION=1.42.0 \
|
2019-01-17 22:17:01 +00:00
|
|
|
RUSTFLAGS='--cfg hermetic'
|
2018-09-20 21:39:59 +00:00
|
|
|
|
|
|
|
# Debian usually has an old rust version in the repository. Instead of using that, we use rustup to
|
|
|
|
# pull in a toolchain versions of our choosing.
|
2020-04-15 18:41:50 +00:00
|
|
|
RUN curl -LO "https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-gnu/rustup-init" \
|
|
|
|
&& echo "ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b *rustup-init" | sha256sum -c - \
|
2018-09-20 21:39:59 +00:00
|
|
|
&& chmod +x rustup-init \
|
|
|
|
&& ./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION \
|
|
|
|
&& rm rustup-init \
|
|
|
|
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
|
|
|
|
&& rustup --version \
|
|
|
|
&& cargo --version \
|
|
|
|
&& rustc --version
|
|
|
|
|
|
|
|
# Warms up the cargo registry cache for future cargo runs. Cargo will still update the cache using a
|
|
|
|
# git pull, but it only needs to download files that were changed since this image was built.
|
|
|
|
RUN cargo install thisiznotarealpackage -q || true
|
|
|
|
|
|
|
|
# Used /scratch for building dependencies which are too new or don't exist on Debian stretch.
|
|
|
|
WORKDIR /scratch
|
|
|
|
|
2019-10-04 20:53:44 +00:00
|
|
|
# New libepoxy and libdrm-dev requires newer meson than is in Debian stretch.
|
|
|
|
ARG MESON_COMMIT=master
|
|
|
|
RUN git clone https://github.com/mesonbuild/meson \
|
|
|
|
&& cd meson \
|
|
|
|
&& git checkout $MESON_COMMIT \
|
|
|
|
&& ln -s $PWD/meson.py /usr/bin/meson
|
|
|
|
|
|
|
|
# The libdrm-dev in distro can be too old to build minigbm,
|
|
|
|
# so we build it from upstream.
|
|
|
|
ARG DRM_COMMIT=master
|
|
|
|
RUN git clone https://gitlab.freedesktop.org/mesa/drm \
|
|
|
|
&& cd drm \
|
|
|
|
&& git checkout $DRM_COMMIT \
|
|
|
|
&& meson build \
|
|
|
|
&& ninja -C build/ install
|
|
|
|
|
2018-09-20 21:39:59 +00:00
|
|
|
# The gbm used by upstream linux distros is not compatible with crosvm, which must use Chrome OS's
|
|
|
|
# minigbm.
|
|
|
|
RUN dpkg --force-depends -r libgbm1
|
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/platform/minigbm \
|
|
|
|
&& cd minigbm \
|
|
|
|
&& sed 's/-Wall/-Wno-maybe-uninitialized/g' -i Makefile \
|
2019-05-02 19:26:24 +00:00
|
|
|
&& make install -j$(nproc)
|
2018-09-20 21:39:59 +00:00
|
|
|
|
|
|
|
# New libepoxy has EGL_KHR_DEBUG entry points needed by crosvm.
|
2019-05-02 19:26:24 +00:00
|
|
|
ARG LIBEPOXY_COMMIT=master
|
2018-09-20 21:39:59 +00:00
|
|
|
RUN git clone https://github.com/anholt/libepoxy.git \
|
|
|
|
&& cd libepoxy \
|
2019-05-02 19:26:24 +00:00
|
|
|
&& git checkout $LIBEPOXY_COMMIT \
|
2018-09-20 21:39:59 +00:00
|
|
|
&& mkdir build \
|
|
|
|
&& cd build \
|
|
|
|
&& meson \
|
|
|
|
&& ninja install
|
|
|
|
|
2019-08-16 16:28:28 +00:00
|
|
|
# We've forked virglrenderer to accomodate differences in the GBM header.
|
|
|
|
# Until we can upstream our changes, build based on this downstream tree.
|
|
|
|
RUN git clone https://gitlab.freedesktop.org/gurchetansingh/virglrenderer.git \
|
2018-09-20 21:39:59 +00:00
|
|
|
&& cd virglrenderer \
|
2019-08-16 16:28:28 +00:00
|
|
|
&& git checkout keep-kokoro-happy \
|
2018-09-20 21:39:59 +00:00
|
|
|
&& ./autogen.sh \
|
2019-05-02 19:26:24 +00:00
|
|
|
&& make install -j$(nproc)
|
2018-09-20 21:39:59 +00:00
|
|
|
|
2019-01-17 22:17:01 +00:00
|
|
|
# Install libtpm2 so that tpm2-sys/build.rs does not try to build it in place in
|
|
|
|
# the read-only source directory.
|
2019-05-02 19:26:24 +00:00
|
|
|
ARG TPM2_COMMIT=master
|
2019-01-17 22:17:01 +00:00
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/third_party/tpm2 \
|
|
|
|
&& cd tpm2 \
|
2019-05-02 19:26:24 +00:00
|
|
|
&& git checkout $TPM2_COMMIT \
|
|
|
|
&& make -j$(nproc) \
|
2019-01-17 22:17:01 +00:00
|
|
|
&& cp build/libtpm2.a /lib
|
|
|
|
|
2020-04-01 06:45:56 +00:00
|
|
|
# PUll down platform2 repositroy and install librendernodehost.
|
|
|
|
# Note that we clone the repository outside of /scratch not to be removed
|
|
|
|
# because crosvm depends on libvda.
|
|
|
|
ENV PLATFORM2_ROOT=/platform2
|
2019-05-02 19:26:24 +00:00
|
|
|
ARG PLATFORM2_COMMIT=master
|
2020-04-01 06:45:56 +00:00
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/platform2 $PLATFORM2_ROOT \
|
|
|
|
&& cd $PLATFORM2_ROOT \
|
2020-07-07 22:59:00 +00:00
|
|
|
&& git checkout $PLATFORM2_COMMIT
|
2020-04-01 06:45:56 +00:00
|
|
|
|
2019-04-05 19:33:58 +00:00
|
|
|
# Set up sysroot from which system_api proto files are built.
|
|
|
|
ENV SYSROOT=/sysroot
|
|
|
|
RUN mkdir -p $SYSROOT/usr/include/chromeos/dbus/trunks \
|
2020-04-01 06:45:56 +00:00
|
|
|
&& cp $PLATFORM2_ROOT/trunks/interface.proto \
|
2019-04-05 19:33:58 +00:00
|
|
|
$SYSROOT/usr/include/chromeos/dbus/trunks
|
2020-04-15 18:41:50 +00:00
|
|
|
# Copy it under rustc's sysroot as well for cargo clippy.
|
|
|
|
RUN export RUST_SYSROOT=$(rustc --print sysroot); echo $RUST_SYSROOT
|
|
|
|
RUN mkdir -p $RUST_SYSROOT/usr/include/chromeos/dbus/trunks \
|
|
|
|
&& cp $PLATFORM2_ROOT/trunks/interface.proto \
|
|
|
|
$RUST_SYSROOT/usr/include/chromeos/dbus/trunks
|
2019-04-05 19:33:58 +00:00
|
|
|
|
2019-01-17 22:17:01 +00:00
|
|
|
# Inform pkg-config where libraries we install are placed.
|
2020-04-10 11:14:28 +00:00
|
|
|
# Also, copy a dummy libvda.pc to compile crosvm with video features.
|
|
|
|
COPY pkgconfig/* /usr/lib/pkgconfig/
|
2019-01-17 22:17:01 +00:00
|
|
|
|
2018-09-20 21:39:59 +00:00
|
|
|
# Reduces image size and prevents accidentally using /scratch files
|
|
|
|
RUN rm -r /scratch /usr/bin/meson
|
|
|
|
|
|
|
|
# The manual installation of shared objects requires an ld.so.cache refresh.
|
|
|
|
RUN ldconfig
|
|
|
|
|
2019-01-22 02:33:21 +00:00
|
|
|
# Pull down repositories that crosvm depends on to cros checkout-like locations.
|
|
|
|
ENV CROS_ROOT=/
|
|
|
|
ENV THIRD_PARTY_ROOT=$CROS_ROOT/third_party
|
|
|
|
RUN mkdir -p $THIRD_PARTY_ROOT
|
2019-01-24 06:44:17 +00:00
|
|
|
ENV PLATFORM_ROOT=$CROS_ROOT/platform
|
|
|
|
RUN mkdir -p $PLATFORM_ROOT
|
2020-02-18 18:31:20 +00:00
|
|
|
ENV AOSP_EXTERNAL_ROOT=$CROS_ROOT/aosp/external
|
|
|
|
RUN mkdir -p $AOSP_EXTERNAL_ROOT
|
|
|
|
|
|
|
|
# minijail does not exist in upstream linux distros.
|
|
|
|
RUN git clone https://android.googlesource.com/platform/external/minijail $AOSP_EXTERNAL_ROOT/minijail \
|
|
|
|
&& cd $AOSP_EXTERNAL_ROOT/minijail \
|
2020-07-13 20:03:58 +00:00
|
|
|
&& git checkout $MINIJAIL_COMMIT \
|
2020-02-18 18:31:20 +00:00
|
|
|
&& make -j$(nproc) \
|
|
|
|
&& cp libminijail.so /usr/lib/x86_64-linux-gnu/
|
2019-01-24 06:44:17 +00:00
|
|
|
|
2019-01-22 02:33:21 +00:00
|
|
|
# Pull the cras library for audio access.
|
2019-06-03 18:15:38 +00:00
|
|
|
ARG ADHD_COMMIT=master
|
|
|
|
RUN git clone https://chromium.googlesource.com/chromiumos/third_party/adhd $THIRD_PARTY_ROOT/adhd \
|
|
|
|
&& cd $THIRD_PARTY_ROOT/adhd \
|
|
|
|
&& git checkout $ADHD_COMMIT
|
2019-01-22 02:33:21 +00:00
|
|
|
|
2019-01-25 03:16:54 +00:00
|
|
|
# The /build directory is used so that the bind mounted /platform/crosvm volume
|
|
|
|
# does not get scribbled on.
|
2018-09-20 21:39:59 +00:00
|
|
|
ENV CARGO_TARGET_DIR=/build
|
|
|
|
RUN mkdir -p $CARGO_TARGET_DIR
|
2019-01-25 03:16:54 +00:00
|
|
|
WORKDIR /platform/crosvm
|