# THIS FILE WAS AUTO-GENERATED
#
#  $ lcitool dockerfile --layers all --cross-arch armv7l debian-12 qemu
#
# https://gitlab.com/libvirt/libvirt-ci

FROM docker.io/library/debian:12-slim

RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -y eatmydata && \
    eatmydata apt-get dist-upgrade -y && \
    eatmydata apt-get install --no-install-recommends -y \
                      bash \
                      bc \
                      bindgen \
                      bison \
                      bsdextrautils \
                      bzip2 \
                      ca-certificates \
                      ccache \
                      dbus \
                      debianutils \
                      diffutils \
                      exuberant-ctags \
                      findutils \
                      flex \
                      gcc \
                      gcovr \
                      gettext \
                      git \
                      hostname \
                      libglib2.0-dev \
                      llvm \
                      locales \
                      make \
                      meson \
                      mtools \
                      ncat \
                      ninja-build \
                      openssh-client \
                      pkgconf \
                      python3 \
                      python3-numpy \
                      python3-opencv \
                      python3-pillow \
                      python3-pip \
                      python3-sphinx \
                      python3-sphinx-rtd-theme \
                      python3-venv \
                      python3-yaml \
                      rpm2cpio \
                      rustc \
                      sed \
                      socat \
                      sparse \
                      swtpm \
                      tar \
                      tesseract-ocr \
                      tesseract-ocr-eng \
                      xorriso \
                      zstd && \
    eatmydata apt-get autoremove -y && \
    eatmydata apt-get autoclean -y && \
    sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \
    dpkg-reconfigure locales && \
    rm -f /usr/lib*/python3*/EXTERNALLY-MANAGED

ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
ENV LANG "en_US.UTF-8"
ENV MAKE "/usr/bin/make"
ENV NINJA "/usr/bin/ninja"
ENV PYTHON "/usr/bin/python3"

RUN export DEBIAN_FRONTEND=noninteractive && \
    dpkg --add-architecture armhf && \
    eatmydata apt-get update && \
    eatmydata apt-get dist-upgrade -y && \
    eatmydata apt-get install --no-install-recommends -y dpkg-dev && \
    eatmydata apt-get install --no-install-recommends -y \
                      gcc-arm-linux-gnueabihf \
                      libaio-dev:armhf \
                      libasan6:armhf \
                      libasound2-dev:armhf \
                      libattr1-dev:armhf \
                      libbpf-dev:armhf \
                      libbrlapi-dev:armhf \
                      libbz2-dev:armhf \
                      libc6-dev:armhf \
                      libcacard-dev:armhf \
                      libcap-ng-dev:armhf \
                      libcapstone-dev:armhf \
                      libcbor-dev:armhf \
                      libcmocka-dev:armhf \
                      libcurl4-gnutls-dev:armhf \
                      libdaxctl-dev:armhf \
                      libdrm-dev:armhf \
                      libepoxy-dev:armhf \
                      libfdt-dev:armhf \
                      libffi-dev:armhf \
                      libfuse3-dev:armhf \
                      libgbm-dev:armhf \
                      libgcrypt20-dev:armhf \
                      libglib2.0-dev:armhf \
                      libglusterfs-dev:armhf \
                      libgnutls28-dev:armhf \
                      libgtk-3-dev:armhf \
                      libgtk-vnc-2.0-dev:armhf \
                      libibverbs-dev:armhf \
                      libiscsi-dev:armhf \
                      libjemalloc-dev:armhf \
                      libjpeg62-turbo-dev:armhf \
                      libjson-c-dev:armhf \
                      liblttng-ust-dev:armhf \
                      liblzo2-dev:armhf \
                      libncursesw5-dev:armhf \
                      libnfs-dev:armhf \
                      libnuma-dev:armhf \
                      libpam0g-dev:armhf \
                      libpcre2-dev:armhf \
                      libpipewire-0.3-dev:armhf \
                      libpixman-1-dev:armhf \
                      libpng-dev:armhf \
                      libpulse-dev:armhf \
                      librbd-dev:armhf \
                      librdmacm-dev:armhf \
                      libsasl2-dev:armhf \
                      libsdl2-dev:armhf \
                      libsdl2-image-dev:armhf \
                      libseccomp-dev:armhf \
                      libselinux1-dev:armhf \
                      libslirp-dev:armhf \
                      libsnappy-dev:armhf \
                      libsndio-dev:armhf \
                      libspice-protocol-dev:armhf \
                      libspice-server-dev:armhf \
                      libssh-gcrypt-dev:armhf \
                      libsystemd-dev:armhf \
                      libtasn1-6-dev:armhf \
                      libubsan1:armhf \
                      libudev-dev:armhf \
                      liburing-dev:armhf \
                      libusb-1.0-0-dev:armhf \
                      libusbredirhost-dev:armhf \
                      libvdeplug-dev:armhf \
                      libvirglrenderer-dev:armhf \
                      libvte-2.91-dev:armhf \
                      libxdp-dev:armhf \
                      libxen-dev:armhf \
                      libzstd-dev:armhf \
                      nettle-dev:armhf \
                      systemtap-sdt-dev:armhf \
                      zlib1g-dev:armhf && \
    eatmydata apt-get autoremove -y && \
    eatmydata apt-get autoclean -y && \
    mkdir -p /usr/local/share/meson/cross && \
    printf "[binaries]\n\
c = '/usr/bin/arm-linux-gnueabihf-gcc'\n\
ar = '/usr/bin/arm-linux-gnueabihf-gcc-ar'\n\
strip = '/usr/bin/arm-linux-gnueabihf-strip'\n\
pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'\n\
\n\
[host_machine]\n\
system = 'linux'\n\
cpu_family = 'arm'\n\
cpu = 'armhf'\n\
endian = 'little'\n" > /usr/local/share/meson/cross/arm-linux-gnueabihf && \
    dpkg-query --showformat '${Package}_${Version}_${Architecture}\n' --show > /packages.txt && \
    mkdir -p /usr/libexec/ccache-wrappers && \
    ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/arm-linux-gnueabihf-cc && \
    ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/arm-linux-gnueabihf-gcc

ENV ABI "arm-linux-gnueabihf"
ENV MESON_OPTS "--cross-file=arm-linux-gnueabihf"
ENV RUST_TARGET "armv7-unknown-linux-gnueabihf"
ENV QEMU_CONFIGURE_OPTS --cross-prefix=arm-linux-gnueabihf-
ENV DEF_TARGET_LIST arm-softmmu,arm-linux-user
# As a final step configure the user (if env is defined)
ARG USER
ARG UID
RUN if [ "${USER}" ]; then \
  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi