# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           meson 1.0

name                osinfo-db-tools
version             1.12.0
categories          sysutils gnome
license             LGPL-2.1+
maintainers         {makr @mohd-akram} openmaintainer

description         Tools for managing the libosinfo database files
long_description    ${description}

homepage            https://libosinfo.org
master_sites        https://releases.pagure.org/libosinfo/

checksums           rmd160  dfe9499f0767c6ee58da10641d8e4a2386b9e2ad \
                    sha256  f3315f675d18770f25dea8ed04b20b8fc80efb00f60c37ee5e815f9c3776e7f3 \
                    size    66204
use_xz              yes

depends_build-append \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:json-glib \
                    port:libarchive \
                    port:libsoup \
                    port:libxslt

# soup-message.h: error: redefinition of typedef ‘SoupMessage’
compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2

configure.cflags-append \
                    -std=gnu99

variant tests description "Enable testing" {
    set py_ver          3.12
    set py_ver_nodot    [string map {. {}} ${py_ver}]
    configure.python    ${prefix}/bin/python${py_ver}

    patchfiles-append   patch-fix-python.diff

    post-patch {
        reinplace "s|@PYTHON@|${configure.python}|" ${worksrcpath}/tests/meson.build
        fs-traverse f ${worksrcpath}/tests {
            if {[string match *.py ${f}]} {
                reinplace -q "s|/usr/bin/env python3|${configure.python}|" ${f}
            }
        }
    }

    depends_build-append \
                        port:python${py_ver_nodot}
    depends_test-append port:py${py_ver_nodot}-pytest \
                        port:py${py_ver_nodot}-requests

    test.run            yes
}