###############################################################################
# Dockerfile used to make gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-archlinux:20260126_update_gcc_16
###############################################################################

FROM archlinux:latest

MAINTAINER Peio Rigaux <peio.rigaux@belledonne-communications.com>

# Configure locale
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    locale-gen
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

ENV SHELL=/bin/bash
#ENV PS1='\[\e[33m\]\u@bc-dev-archlinux-latest>\[\e[0m\] '

# WARNING : AS ARCHLINUX IS A ROLLING RELEASE, ALL THE IMAGE MUST BE REBUILT FOR AN UPGRADE, OTHERWIZE THERE COULD BE CONFLICTS BETWEEN PACKAGES (ALL THE SYSTEM MUST BE UPDATED AT ONCE, THIS IS ALSO TRUE OUT OF DOCKER)
# Update keyring
RUN pacman --noconfirm --noprogressbar -Sy archlinux-keyring

# Install common general tools
RUN pacman --noconfirm --noprogressbar -Syu && \
    pacman --noconfirm --noprogressbar -S nano sudo vim && \
    pacman -Scc

# Install development tools
RUN pacman --noconfirm --noprogressbar -Syu && \
    pacman --noconfirm --noprogressbar -S at autoconf automake bison ccache clang cmake doxygen elfutils gcc gdb git graphviz intltool libtool lsb-release make meson nasm ninja openssh patch perl pkgconf python-pip python-pystache python-six python-jsonschema python-jinja yasm && \
    pacman -Scc

# Install linphone & flexisip dependencies development packages
RUN pacman --noconfirm --noprogressbar -Syu && \
    pacman --noconfirm --noprogressbar -S alsa-lib ffmpeg glew gsm jansson libbsd libjpeg-turbo libsrtp libvpx libxml2 libxv mariadb mbedtls mesa net-snmp openssl opus postgresql protobuf pulseaudio qt5-base qt5-declarative qt5-quickcontrols2 qt5-speech qt5-svg qt5-tools speex speexdsp sqlite v4l-utils xerces-c && \
    pacman -Scc
# Configure user bc
RUN useradd -ms /bin/bash bc && \
    echo 'bc:cotcot' | chpasswd && \
    echo 'bc ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Install AUR makepkg tools
RUN pacman --noconfirm --noprogressbar -Syu && \
    pacman --noconfirm --noprogressbar -S debugedit fakeroot && \
    pacman -Scc

# Install AUR packages dependencies
RUN pacman --noconfirm --noprogressbar -Syu && \
    pacman --noconfirm --noprogressbar -S chrpath && \
    pacman -Scc

# Install AUR packages

# build2
USER bc
RUN git clone https://aur.archlinux.org/build2.git /tmp/build2
WORKDIR /tmp/build2
RUN makepkg

USER root
RUN pacman --noconfirm --noprogressbar -U *.pkg.tar.zst

# libcutl
USER bc
RUN git clone https://aur.archlinux.org/libcutl.git /tmp/libcutl
WORKDIR /tmp/libcutl
RUN makepkg

USER root
RUN pacman --noconfirm --noprogressbar -U *.pkg.tar.zst

# libxsd-frontend
USER bc
RUN git clone https://aur.archlinux.org/libxsd-frontend.git /tmp/libxsd-frontend
WORKDIR /tmp/libxsd-frontend
RUN makepkg

USER root
RUN pacman --noconfirm --noprogressbar -U *.pkg.tar.zst

# XSD
USER bc
RUN git clone https://aur.archlinux.org/xsd.git /tmp/xsd
WORKDIR /tmp/xsd
RUN makepkg

USER root
RUN pacman --noconfirm --noprogressbar -U *.pkg.tar.zst

USER bc
WORKDIR /home/bc

CMD bash
ENTRYPOINT /bin/bash
