#!/bin/bash
# Copyright © 2019-2026 Collabora Ltd.
# SPDX-License-Identifier: BSD-3-Clause

set -eu -o pipefail

DEB_HOST_GNU_TYPE="$(dpkg-architecture -qDEB_HOST_GNU_TYPE)"
failed=
n=0

for pkg in \
    SPIRV-Headers \
    alsa \
    dav1d \
    dbus-1 \
    egl \
    fontconfig \
    freetype2 \
    gbm \
    gio-2.0 \
    gl \
    glib-2.0 \
    glx \
    gmodule-2.0 \
    gmodule-export-2.0 \
    gmodule-no-export-2.0 \
    gmp \
    gnutls \
    gobject-2.0 \
    gpg-error \
    graphene-1.0 \
    graphene-gobject-1.0 \
    gthread-2.0 \
    gudev-1.0 \
    json-glib-1.0 \
    libelf \
    libffi \
    libfl \
    libmpg123 \
    libpulse \
    libpulse-mainloop-glib \
    libpulse-simple \
    libselinux \
    libspa-0.2 \
    libsystemd \
    libudev \
    libusb-1.0 \
    libv4l1 \
    libv4l2 \
    libv4l2rds \
    libv4lconvert \
    libva \
    libva-drm \
    libva-glx \
    libva-wayland \
    libva-x11 \
    mpfr \
    ogg \
    opusfile \
    osmesa \
    sdl2 \
    theora \
    theoradec \
    theoraenc \
    vorbis \
    vorbisenc \
    vorbisfile \
    vpx \
    vulkan \
    waffle-1 \
    x11 \
    x11-xcb \
    xcb \
    xcomposite \
    xcursor \
    xext \
    xfixes \
    xi \
    xinerama \
    xproto \
    xrandr \
    xrender \
    xtrans \
    xxf86vm \
    zlib \
; do
    n=$(( n + 1 ))

    if v="$("${DEB_HOST_GNU_TYPE}-pkgconf" --modversion "$pkg")"; then
        echo "ok $n - $pkg version $v"
    else
        echo "not ok $n - $pkg"
        failed=1
    fi
done

for pkg in \
    atk \
    cairo \
    cups \
    dxvk-d3d10core \
    dxvk-d3d11 \
    dxvk-d3d8 \
    dxvk-d3d9 \
    dxvk-dxgi \
    expat \
    flac \
    gdk-pixbuf-2.0 \
    harfbuzz \
    harfbuzz-gobject \
    ibus-1.0 \
    libdecor-0 \
    libdrm \
    libgcrypt \
    libidn2 \
    libjpeg \
    libnotify \
    libpci \
    libpipewire-0.3 \
    libpng \
    libpng16 \
    libtasn1 \
    libtiff-4 \
    libvkd3d \
    libvkd3d-shader \
    libvkd3d-utils \
    libwebp \
    libwebpdecoder \
    libwebpdemux \
    libwebpmux \
    libxml-2.0 \
    openal \
    openblas \
    openssl \
    openxr \
    opus \
    p11-kit-1 \
    pango \
    pangocairo \
    pangoft2 \
    pangoxft \
    pixman-1 \
    samplerate \
    sdl3 \
    sdl3-image \
    sdl3-ttf \
    sm \
    sndfile \
    speex \
    speexdsp \
    sqlite3 \
    steam-runtime-tools-0 \
    tbb \
    uuid \
    wayland-client \
    wayland-cursor \
    wayland-egl \
    wayland-server \
    xau \
    xcb-composite \
    xcb-cursor \
    xcb-damage \
    xcb-dpms \
    xcb-dri2 \
    xcb-dri3 \
    xcb-ewmh \
    xcb-glx \
    xcb-icccm \
    xcb-image \
    xcb-keysyms \
    xcb-present \
    xcb-randr \
    xcb-record \
    xcb-render \
    xcb-renderutil \
    xcb-res \
    xcb-screensaver \
    xcb-shape \
    xcb-shm \
    xcb-sync \
    xcb-util \
    xcb-xf86dri \
    xcb-xfixes \
    xcb-xinerama \
    xcb-xinput \
    xcb-xkb \
    xcb-xtest \
    xcb-xv \
    xcb-xvmc \
    xdamage \
    xdmcp \
    xft \
    xkbcommon \
    xkbcommon-x11 \
    xkbfile \
    xmu \
    xpm \
    xpresent \
    xscrnsaver \
    xt \
    xtst \
; do
    n=$(( n + 1 ))

    if [ "$(dpkg --print-architecture)" = i386 ]; then
        echo "ok $n # SKIP $pkg not supported on i386"
    elif v="$("${DEB_HOST_GNU_TYPE}-pkgconf" --modversion "$pkg")"; then
        echo "ok $n - $pkg version $v"
    else
        echo "not ok $n - $pkg"
        failed=1
    fi
done

echo "1..$n"

if [ -n "$failed" ]; then
    exit 1
fi

# vim:set sw=4 sts=4 et ft=sh:
