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

PortSystem          1.0
PortGroup           github 1.0
PortGroup           makefile 1.0

github.setup        exaile exaile 4.2.0
revision            0
categories          audio python
platforms           {darwin any}
license             GPL-2
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer

description         Full-featured Python-based music player for GTK
long_description    ${name} is a music player with a simple interface \
                    and powerful music management capabilities.
homepage            https://exaile.org
checksums           rmd160  7c1ffb18420152e9691bf51344e4fadae718aaa4 \
                    sha256  766001437cd1610f750fa1d08807141a37b632270300ddf8fad447cbfbefa2f1 \
                    size    3906794
github.tarball_from archive
supported_archs     noarch

set py_ver          3.13
set py_ver_nodot    [string map {. {}} ${py_ver}]
configure.python    ${prefix}/bin/python${py_ver}

patchfiles          patch-Makefile.diff

# Audio output works without this, but nevertheless, add osxaudiosink.
# https://gstreamer.freedesktop.org/documentation/osxaudio/osxaudiosink.html
patchfiles-append   patch-sink.py.diff

# https://github.com/exaile/exaile/issues/969
patchfiles-append   patch-no-broken-cocoa-for-goods-sake.diff

post-patch {
    reinplace "s|python3|${configure.python}|" \
                    ${worksrcpath}/${name} ${worksrcpath}/Makefile ${worksrcpath}/plugins/Makefile
    reinplace "s|--startgui|--startgui --nohal|" \
                    ${worksrcpath}/${name}
}

depends_build-append \
                    port:gettext \
                    port:help2man \
                    path:bin/pkg-config:pkgconfig \
                    port:py${py_ver_nodot}-black

depends_lib-append  path:lib/pkgconfig/cairo.pc:cairo \
                    port:dbus-python${py_ver_nodot} \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:gstreamer1 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    path:lib/pkgconfig/librsvg-2.0.pc:librsvg \
                    port:python${py_ver_nodot}

depends_run-append  port:adwaita-icon-theme \
                    port:desktop-file-utils \
                    port:gstreamer1-gst-libav \
                    port:gstreamer1-gst-plugins-base \
                    port:gstreamer1-gst-plugins-good \
                    port:py-gst-python \
                    port:py${py_ver_nodot}-berkeleydb \
                    port:py${py_ver_nodot}-bsddb3 \
                    port:py${py_ver_nodot}-cairo \
                    port:py${py_ver_nodot}-feedparser \
                    port:py${py_ver_nodot}-gobject3 \
                    port:py${py_ver_nodot}-mutagen \
                    port:py${py_ver_nodot}-pylast \
                    port:py${py_ver_nodot}-six

platform linux {
    depends_run-append \
                    port:pulseaudio
}

build.target        all_no_locale
destroot.target     install_no_locale

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
}

notes "
${name} uses dbus at runtime. If dbus service is not running, please start it with:\
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
"
