# -*- 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               github 1.0
PortGroup               xcode 1.0

github.setup            lukas-zronek ssh-askpass-mac 1.2 v

categories              aqua
license                 BSD
maintainers             {@sstallion gmail.com:sstallion} openmaintainer

description             A macOS front-end of ssh-askpass with keychain support
long_description        ssh-askpass-mac is a graphical front-end for ssh-add on macOS, which can \
                        store the password of a private key in the keychain

use_xcode               yes

github.tarball_from     archive

checksums               rmd160  2f0e11cbe34da1f854fd7852d8bb066bb8073cd5 \
                        sha256  a1f3aad9eb908fd3f2e82422e67fff3c64ad97d09c20b669d0f2e46632ca9438 \
                        size    17932

post-destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/Library/LaunchAgents
    xinstall -m 0644 ${filespath}/org.macports.ssh-askpass-mac.plist \
        ${destroot}${prefix}/Library/LaunchAgents
    reinplace "s|@APPLICATIONS_DIR@|${applications_dir}|g" \
        ${destroot}${prefix}/Library/LaunchAgents/org.macports.ssh-askpass-mac.plist

    if {${startupitem.install} && [geteuid] == 0} {
        xinstall -d -m 0755 ${destroot}/Library/LaunchAgents
        ln -s ${prefix}/Library/LaunchAgents/org.macports.ssh-askpass-mac.plist ${destroot}/Library/LaunchAgents
    }
}

notes "
Launch ${name} with
    launchctl load -w \\
        /Library/LaunchAgents/org.machports.ssh-askpass-mac.plist

On macOS < 12 (Monterey) or OpenSSH < 8.3 add the following line to the
startup file of your shell:

    ssh-add $@ < /dev/null

You can also disable the keychain with the following command:

    defaults write at.zronek.lukas.ssh-askpass useKeychain -bool false
"

startupitem.install     yes
startupitem.location    LaunchAgents
