# Test coverage provided by this container:
# - arm64
# - default hostonly
# - xfs
# - memstrack
# - ndctl (for nvdimm)
# - fcoe-utils (Fibre Channel over Ethernet)
# - curl (url-lib)
# - cifs-utils (cifs)
# - openssh (ssh-client)
# - rsyslog (syslog)
# - libkcapi-hmaccalc (fido)
# - nss-softokn, kdumpbase out of tree dracut modules
# - fips
# - ignition
# - dbus-broker
# - network: network-legacy, network-manager

ARG DISTRIBUTION=fedora
ARG REGISTRY=registry.fedoraproject.org

FROM ${REGISTRY}/${DISTRIBUTION}

# export ARG
ARG DISTRIBUTION

# prefer running tests with xfs
ENV TEST_FSTYPE=xfs

RUN \
if [[ "${DISTRIBUTION}" =~ "centos:" ]]; then \
    dnf config-manager --set-enabled crb; \
    dnf -y install epel-release; \
else \
    dnf -y install --setopt=install_weak_deps=False \
    btrfs-progs \
    dhcp-client \
    dhcp-server \
    nbd \
    qemu \
    scsi-target-utils \
; fi

RUN dnf -y install --setopt=install_weak_deps=False \
    asciidoctor \
    bash-completion \
    bluez \
    cargo \
    cifs-utils \
    cryptsetup \
    crypto-policies-scripts \
    device-mapper-multipath \
    dracut-live \
    e2fsprogs \
    erofs-utils \
    fcoe-utils \
    fuse3 \
    gcc \
    ignition \
    iproute \
    iputils \
    iscsi-initiator-utils \
    jq \
    kbd \
    kdump-utils \
    kernel \
    kmod-devel \
    libfido2 \
    libkcapi-hmaccalc \
    libselinux-utils \
    lvm2 \
    make \
    mdadm \
    memstrack \
    ndctl \
    NetworkManager \
    nfs-utils \
    nvme-cli \
    parted \
    pcsc-lite \
    plymouth \
    qemu-kvm \
    rng-tools \
    rsyslog \
    squashfs-tools \
    swtpm \
    systemd-boot-unsigned \
    systemd-container \
    systemd-devel \
    systemd-resolved \
    systemd-ukify \
    tpm2-tools \
    xfsprogs \
    xorriso \
    && dnf -y update && dnf clean all

# CentOS Stream ships only qemu-kvm, but it disables the KVM accel when it's not available
RUN \
if [[ "${DISTRIBUTION}" =~ "centos:" ]]; then \
    [[ -e /usr/bin/qemu-kvm ]] || ln -sf /usr/libexec/qemu-kvm /usr/bin/qemu-kvm ;\
    [[ -e /usr/bin/qemu-system-$(uname -m) ]] || ln -sv /usr/libexec/qemu-kvm /usr/bin/qemu-system-$(uname -m) ;\
fi ;\
update-crypto-policies --no-reload --set FIPS
