# -*- 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               makefile 1.0

github.setup            Reflejo pam-touchID 757cafcadfefc7601825577f51e80d4815900367
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
name                    pam-touchid
version                 20210121
revision                0
platforms               {darwin >= 20}
categories              security
maintainers             {i0ntempest @i0ntempest} openmaintainer
license                 public-domain

description             PAM plugin module that allows Touch ID to be used for authentication
long_description        A PAM plugin that allows the Touch ID to be used for authentication, \
                        written in Swift.

checksums               rmd160  9b4fe80f6a00685f41ea64e40e4573aa4dce663e \
                        sha256  c1e80b0168076312d3acad63f6d9e887debfe04f304dc8b4b69cfa83c32d0665 \
                        size    2878

# Makefile fix-ups and enable verbose
post-patch {
    reinplace "s| = | ?= |g" ${worksrcpath}/Makefile
    reinplace "s| := | ?= |g" ${worksrcpath}/Makefile
    reinplace "s|swiftc|swiftc -v|g" ${worksrcpath}/Makefile
}

build.env-append        TARGET=${build_arch}-apple-darwin${os.major}
destroot.env-append     DESTINATION=${destroot}${prefix}/lib/pam
universal_variant       no

notes-append "
    Edit /etc/pam.d/sudo to include the following line as the first line (not including comments)\
    to enable authentication with Touch ID for sudo:
    auth       sufficient     ${prefix}/lib/pam/pam_touchid.so       \"reason=execute a command as root\"
    
    Remove this line before uninstalling this port or sudo will stop working.
"