# -*- 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           gitlab 1.0
PortGroup           meson 1.0

gitlab.instance     https://gitlab.gnome.org
gitlab.setup        World secrets 13.0.1
revision            0
categories          gnome security sysutils
license             GPL-3
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Password manager for GNOME
long_description    {*}${description}
use_bzip2           yes
checksums           rmd160  5b5cd6dc890832ca18e30f2525545ad3a4025ad6 \
                    sha256  f24d703d90203c0f0e08fbfbf56be7fef1c7b06d78b62a038d7f690c45c0af92 \
                    size    533088

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]

set python.prefix   ${frameworks_dir}/Python.framework/Versions/${py_ver}
set python.bin      ${python.prefix}/bin/python${py_ver}
set python.pkgd     ${python.prefix}/lib/python${py_ver}/site-packages

# Fix breakage from fdcc4ac276dad65dd5de4218aaa1469ca8abf1a6
patchfiles-append   patch-unrustify.diff

patchfiles-append   patch-find-right-python.diff

post-patch {
    reinplace "s|@PYTHON@|${python.bin}|" ${worksrcpath}/meson.build
    reinplace "s|@PY_PACKAGES@|${python.pkgd}|" ${worksrcpath}/meson.build
}

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

depends_lib-append  port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk4.pc:gtk4 \
                    port:gtksourceview5 \
                    port:libadwaita \
                    port:python${py_ver_nodot} \
                    port:py${py_ver_nodot}-gobject3 \
                    port:py${py_ver_nodot}-kcs11 \
                    port:py${py_ver_nodot}-pyhibp \
                    port:py${py_ver_nodot}-pykeepass \
                    port:py${py_ver_nodot}-pyotp \
                    port:py${py_ver_nodot}-validators \
                    port:py${py_ver_nodot}-yubico \
                    port:py${py_ver_nodot}-zxcvbn

depends_run-append  port:desktop-file-utils

# Dependency is not declared anywhere explicitly,
# but secrets will fail to launch if usb module is not found.
depends_run-append  port:py${py_ver_nodot}-pyusb

configure.pkg_config_path-prepend \
                    ${python.prefix}/lib/pkgconfig

post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
    system "${prefix}/bin/gtk4-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
}

# https://trac.macports.org/ticket/70137
notes "
If you get an error upon launching the app,\
try setting GSK_RENDERER=cairo in the environment.\
You may also add it into a shell config file.
"
