1#
2# Docker cross-compiler target
3#
4# This docker target uses prebuilt toolchains for LoongArch64 from:
5# https://github.com/loongson/build-tools/releases
6#
7FROM docker.io/library/debian:11-slim
8
9# Duplicate deb line as deb-src
10RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.list
11
12RUN export DEBIAN_FRONTEND=noninteractive && \
13    apt-get update && \
14    apt-get install -y eatmydata && \
15    eatmydata apt-get dist-upgrade -y && \
16    apt build-dep -yy qemu
17
18RUN apt-get update && \
19    DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
20    DEBIAN_FRONTEND=noninteractive eatmydata \
21    apt-get install -y --no-install-recommends \
22        build-essential \
23        bison \
24        ca-certificates \
25        ccache \
26        clang  \
27        flex \
28        curl \
29        gettext \
30        git \
31        ninja-build \
32        python3-pip \
33        python3-setuptools \
34        python3-venv \
35        python3-wheel && \
36        dpkg-query --showformat '${Package}_${Version}_${Architecture}\n' --show > /packages.txt
37
38RUN /usr/bin/pip3 install tomli
39
40RUN curl -#SL https://github.com/loongson/build-tools/releases/download/2023.08.08/CLFS-loongarch64-8.1-x86_64-cross-tools-gcc-glibc.tar.xz \
41    | tar -xJC /opt
42
43ENV PATH $PATH:/opt/cross-tools/bin
44ENV LD_LIBRARY_PATH /opt/cross-tools/lib:/opt/cross-tools/loongarch64-unknown-linux-gnu/lib:$LD_LIBRARY_PATH
45
46ENV QEMU_CONFIGURE_OPTS --disable-docs --disable-tools
47ENV DEF_TARGET_LIST loongarch64-linux-user,loongarch64-softmmu
48ENV MAKE /usr/bin/make
49
50# As a final step configure the user (if env is defined)
51ARG USER
52ARG UID
53RUN if [ "${USER}" ]; then \
54  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
55