1#
2# Docker cross-compiler target for riscv64
3#
4# Currently the only distro that gets close to cross compiling riscv64
5# images is Debian Sid (with unofficial ports). As this is a moving
6# target we keep the library list minimal and are aiming to migrate
7# from this hack as soon as we are able.
8#
9FROM docker.io/library/debian:sid-slim
10
11# Add ports
12RUN apt update && \
13    DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
14    DEBIAN_FRONTEND=noninteractive eatmydata apt update -yy && \
15    DEBIAN_FRONTEND=noninteractive eatmydata apt upgrade -yy
16
17# Install common build utilities
18RUN DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy \
19    bison \
20    bc \
21    build-essential \
22    ca-certificates \
23    debian-ports-archive-keyring \
24    dpkg-dev \
25    flex \
26    gettext \
27    git \
28    libglib2.0-dev \
29    ninja-build \
30    pkg-config \
31    python3 \
32    python3-venv
33
34# Add ports and riscv64 architecture
35RUN echo "deb http://ftp.ports.debian.org/debian-ports/ sid main" >> /etc/apt/sources.list
36RUN dpkg --add-architecture riscv64
37
38# Duplicate deb line as deb-src
39RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.list
40
41RUN apt update && \
42    DEBIAN_FRONTEND=noninteractive eatmydata \
43    apt install -y --no-install-recommends \
44         gcc-riscv64-linux-gnu \
45         libc6-dev-riscv64-cross \
46         libfdt-dev:riscv64 \
47         libffi-dev:riscv64 \
48         libglib2.0-dev:riscv64 \
49         libpixman-1-dev:riscv64
50
51# Specify the cross prefix for this image (see tests/docker/common.rc)
52ENV QEMU_CONFIGURE_OPTS --cross-prefix=riscv64-linux-gnu-
53ENV DEF_TARGET_LIST riscv64-softmmu,riscv64-linux-user
54# As a final step configure the user (if env is defined)
55ARG USER
56ARG UID
57RUN if [ "${USER}" ]; then \
58  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
59