# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           qt5 1.0

github.setup        lxqt lxqt-openssh-askpass 0.15.0
revision            0
checksums           rmd160  d05d67a99fff3735763fd7adbd1057fd8c3c628c \
                    sha256  5371e955b18494eaa342c9ccfc7ef64b38af4c78514bdcdc4c81a017898416c1 \
                    size    17032

categories          sysutils
platforms           darwin
maintainers         nomaintainer
license             LGPL-2.1

description         GUI to query passwords on behalf of SSH agents

long_description    {*}${description}

github.tarball_from releases
use_xz              yes

qt5.depends_build_component \
                    qttools
depends_build-append \
                    port:lxqt-build-tools

depends_lib-append  port:liblxqt

startupitem.type    launchd
startupitem.create  no
startupitem.location \
                    LaunchAgents
startupitem.uniquename \
                    org.lxqt.ssh-agent

post-extract {
    # Copy launchd plists to worksrcpath
    file copy ${filespath}/${startupitem.uniquename}.plist.in ${worksrcpath}/${startupitem.uniquename}.plist
}

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/${startupitem.uniquename}.plist
}

post-destroot {
    set launchd_dir     ${prefix}/etc/${startupitem.location}/${startupitem.uniquename}/

    file mkdir ${destroot}${launchd_dir}
    file copy ${worksrcpath}/${startupitem.uniquename}.plist ${destroot}${launchd_dir}

    # install the plist, if startupitem.install is set
    if {[getuid] == 0 && ${startupitem.install}} {
        xinstall -m 0755 -d ${destroot}/Library/${startupitem.location}
        ln -sf ${launchd_dir}${startupitem.plist} ${destroot}/Library/${startupitem.location}
    } else {
        ln -sf ${launchd_dir}${startupitem.plist} ${destroot}${prefix}/etc/${startupitem.location}
    }
}
