# this file is used to build the image gpsbabel_build_environment used by travis.

FROM ubuntu:noble

LABEL maintainer="https://github.com/tsteven4"

WORKDIR /app

# update environment.
# software-properties-common, gpg-agent and ppa:tsteven4/clazy-backports
# are needed to get a backported version of clazy (1.12-2~noble12) that works
# with Qt6.
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
    apt-utils \
    software-properties-common \
    gpg-agent \
 && add-apt-repository ppa:tsteven4/clazy-backports \
 && apt-get upgrade -y \
 && rm -rf /var/lib/apt/lists/*

# install packages needed for gpsbabel build
# split into multiple commands to limit layer size

# basic build and test tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    g++ \
    make \
    git \
    valgrind \
    expat \
    libxml2-utils \
    bear \
    cmake \
    ninja-build \
    clazy \
    clang-tidy \
    jq \
    curl \
    ca-certificates \
 && rm -rf /var/lib/apt/lists/*

# alternative compiler
RUN apt-get update && apt-get install -y --no-install-recommends \
    clang \
 && rm -rf /var/lib/apt/lists/*

# pkgs needed to build document
RUN apt-get update && apt-get install -y --no-install-recommends \
    fop \
    xsltproc \
    docbook-xml \
    docbook5-xml \
    docbook-xsl \
    docbook-xsl-ns \
    libavalon-framework-java \
    jing \
 && rm -rf /var/lib/apt/lists/*

# pkgs with libraries needed by gpsbabel
RUN apt-get update && apt-get install -y --no-install-recommends \
    libusb-1.0-0-dev \
    pkg-config \
    libudev-dev \
 && rm -rf /var/lib/apt/lists/*

# pkgs with qt used by gpsbabel
RUN apt-get update && apt-get install -y --no-install-recommends \
    qt6-base-dev \
    qt6-5compat-dev \
    qt6-serialport-dev \
    libx11-xcb-dev \
    libxkbcommon-dev \
    qt6-tools-dev \
    qt6-translations-l10n \
    qt6-webengine-dev \
    qt6-wayland \
 && rm -rf /var/lib/apt/lists/*

# dbgsyms for "libqt6core6t64/noble,now 6.4.2+dfsg-21.1build5 amd64" needed for gpsbabel.supp
RUN apt-get update && apt-get install -y --no-install-recommends ubuntu-dbgsym-keyring \
 && echo "deb http://ddebs.ubuntu.com noble main restricted universe multiverse" >> /etc/apt/sources.list.d/ddebs.list \
 && echo "deb http://ddebs.ubuntu.com noble-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/ddebs.list \
 && echo "deb http://ddebs.ubuntu.com noble-proposed main restricted universe multiverse" >> /etc/apt/sources.list.d/ddebs.list \
 && apt-get update && apt-get install -y --no-install-recommends libqt6core6t64-dbgsym \
 && rm -rf /var/lib/apt/lists/*

# pkgs needed to generate coverage report:
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcovr \
 && rm -rf /var/lib/apt/lists/*

# install environment for locale test
RUN apt-get update && apt-get install -y --no-install-recommends \
    locales \
 && rm -rf /var/lib/apt/lists/* \
 && sed -i 's/^# *\(en_US ISO-8859-1\)/\1/' /etc/locale.gen \
 && locale-gen \
 && locale -a
