• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5FROM debian:stretch
6LABEL description="Test crosvm using a command like the following: \
7docker run --privileged -v /dev/log:/dev/log -v <path to crosvm>:/platform/crosvm:ro <crosvm base image>"
8
9RUN apt-get update && apt-get install -y \
10    autoconf \
11    automake \
12    curl \
13    gcc \
14    g++ \
15    git \
16    libcap-dev \
17    libdbus-1-dev \
18    libdrm-dev \
19    libfdt-dev \
20    libegl1-mesa-dev \
21    libgl1-mesa-dev \
22    libgles1-mesa-dev \
23    libgles2-mesa-dev \
24    libssl1.0-dev \
25    libtool \
26    libusb-1.0-0-dev \
27    libwayland-dev \
28    make \
29    nasm \
30    ninja-build \
31    pkg-config \
32    protobuf-compiler \
33    python3
34
35ENV RUSTUP_HOME=/usr/local/rustup \
36    CARGO_HOME=/usr/local/cargo \
37    PATH=/usr/local/cargo/bin:$PATH \
38    RUST_VERSION=1.35.0 \
39    RUSTFLAGS='--cfg hermetic'
40
41# Debian usually has an old rust version in the repository. Instead of using that, we use rustup to
42# pull in a toolchain versions of our choosing.
43RUN curl -LO "https://static.rust-lang.org/rustup/archive/1.14.0/x86_64-unknown-linux-gnu/rustup-init" \
44    && echo "0077ff9c19f722e2be202698c037413099e1188c0c233c12a2297bf18e9ff6e7 *rustup-init" | sha256sum -c - \
45    && chmod +x rustup-init \
46    && ./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION \
47    && rustup component add rustfmt-preview \
48    && rm rustup-init \
49    && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
50    && rustup --version \
51    && cargo --version \
52    && rustc --version
53
54# Warms up the cargo registry cache for future cargo runs. Cargo will still update the cache using a
55# git pull, but it only needs to download files that were changed since this image was built.
56RUN cargo install thisiznotarealpackage -q || true
57
58# Used /scratch for building dependencies which are too new or don't exist on Debian stretch.
59WORKDIR /scratch
60
61# minijail does not exist in upstream linux distros.
62RUN git clone https://android.googlesource.com/platform/external/minijail \
63    && cd minijail \
64    && make -j$(nproc) \
65    && cp libminijail.so /usr/lib/x86_64-linux-gnu/
66
67# The gbm used by upstream linux distros is not compatible with crosvm, which must use Chrome OS's
68# minigbm.
69RUN dpkg --force-depends -r libgbm1
70RUN git clone https://chromium.googlesource.com/chromiumos/platform/minigbm \
71    && cd minigbm \
72    && sed 's/-Wall/-Wno-maybe-uninitialized/g' -i Makefile \
73    && make install -j$(nproc)
74
75# New libepoxy requires newer meson than is in Debian stretch.
76ARG MESON_COMMIT=master
77RUN git clone https://github.com/mesonbuild/meson \
78    && cd meson \
79    && git checkout $MESON_COMMIT \
80    && ln -s $PWD/meson.py /usr/bin/meson
81
82# New libepoxy has EGL_KHR_DEBUG entry points needed by crosvm.
83ARG LIBEPOXY_COMMIT=master
84RUN git clone https://github.com/anholt/libepoxy.git \
85    && cd libepoxy \
86    && git checkout $LIBEPOXY_COMMIT \
87    && mkdir build \
88    && cd build \
89    && meson \
90    && ninja install
91
92# virglrenderer is under heavy development on master and we want the very latest.
93RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git \
94    && cd virglrenderer \
95    && ./autogen.sh \
96    && make install -j$(nproc)
97
98# Install libtpm2 so that tpm2-sys/build.rs does not try to build it in place in
99# the read-only source directory.
100ARG TPM2_COMMIT=master
101RUN git clone https://chromium.googlesource.com/chromiumos/third_party/tpm2 \
102    && cd tpm2 \
103    && git checkout $TPM2_COMMIT \
104    && make -j$(nproc) \
105    && cp build/libtpm2.a /lib
106
107# Install librendernodehost
108ARG PLATFORM2_COMMIT=master
109RUN git clone https://chromium.googlesource.com/chromiumos/platform2 \
110    && cd platform2 \
111    && git checkout $PLATFORM2_COMMIT \
112    && cd rendernodehost \
113    && gcc -c src.c -o src.o \
114    && ar rcs librendernodehost.a src.o \
115    && cp librendernodehost.a /lib
116
117# Set up sysroot from which system_api proto files are built.
118ENV SYSROOT=/sysroot
119RUN mkdir -p $SYSROOT/usr/include/chromeos/dbus/trunks \
120    && cp platform2/trunks/interface.proto \
121        $SYSROOT/usr/include/chromeos/dbus/trunks
122
123# Inform pkg-config where libraries we install are placed.
124COPY pkgconfig/* /usr/lib/pkgconfig
125
126# Reduces image size and prevents accidentally using /scratch files
127RUN rm -r /scratch /usr/bin/meson
128
129# The manual installation of shared objects requires an ld.so.cache refresh.
130RUN ldconfig
131
132# Pull down repositories that crosvm depends on to cros checkout-like locations.
133ENV CROS_ROOT=/
134ENV THIRD_PARTY_ROOT=$CROS_ROOT/third_party
135RUN mkdir -p $THIRD_PARTY_ROOT
136ENV PLATFORM_ROOT=$CROS_ROOT/platform
137RUN mkdir -p $PLATFORM_ROOT
138
139# Pull the cras library for audio access.
140ARG ADHD_COMMIT=master
141RUN git clone https://chromium.googlesource.com/chromiumos/third_party/adhd $THIRD_PARTY_ROOT/adhd \
142    && cd $THIRD_PARTY_ROOT/adhd \
143    && git checkout $ADHD_COMMIT
144
145# The /build directory is used so that the bind mounted /platform/crosvm volume
146# does not get scribbled on.
147ENV CARGO_TARGET_DIR=/build
148RUN mkdir -p $CARGO_TARGET_DIR
149WORKDIR /platform/crosvm
150