# Mimic Manjaro ARM Minimal 23.02
FROM docker.io/manjarolinux/base:20230226

RUN cat <<-EOF >/etc/pam.d/su
#%PAM-1.0
auth            sufficient      pam_rootok.so
auth            sufficient      pam_wheel.so trust use_uid
auth            required        pam_wheel.so use_uid
auth            required        pam_unix.so
account         required        pam_unix.so
session         required        pam_unix.so
password        include         system-auth
EOF

# Pre-update to speed up tests
RUN pacman -Syu --noconfirm

# The Manjaro image oddly returns 1 on `pacman -Qe`
# until a package has been marked explicitly installed.
# This behaviour is different from the native system image.
# `pacman -Qe` is part of the community.pacman operations.
# So we set preinstalled manjaro packages with no dependencies as explicit
RUN pacman -Qtq | xargs pacman -D --asexplicit

RUN useradd -m -G wheel bun

CMD [ "/sbin/init" ]
