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

github.setup        google google-authenticator-libpam 1.10
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                pam-google-authenticator
categories          security
maintainers         {eborisch @eborisch} openmaintainer
license             apache-2 

description         Pluggable Authentication Module for Google Authenticator

long_description    The Google Authenticator PAM module provides an easy way \
                    use Google's 2FA (via Google Authenticator app) to your \
                    existing user authentication infrastructure.

checksums \
    rmd160  9b8a66bcfa9ae2d45268fac2acc848351369702e \
    sha256  c85bdf528643eb8ec404b2494047ff5829469acb33b339501020ff326c6849f8 \
    size    64416

depends_run-append      port:qrencode

# While this isn't needed to compile, the application (setup) portion uses
# dlopen to opportunistically load libqrencode. This dependency is recorded
# above, but application needs the prefix/lib directory in the search path to
# find it.
configure.ldflags-append    -Wl,-rpath -Wl,${prefix}/lib

patch {
    # Match pam-u2f's location for consistency
    reinplace "s|/security|/pam|" Makefile.am
}

use_autoreconf          yes
autoreconf.args         --install

post-destroot {
    xinstall -m 0644 ${worksrcpath}/LICENSE \
        ${destroot}${prefix}/share/doc/google-authenticator/
}

notes "
Create a file for a new service in /etc/pam.d/ or edit
an already existing one by adding a line similar to this:

auth required ${prefix}/lib/pam/pam_google_authenticator.so

See man google-authenticator and pam_google_authenticator or
https://github.com/google/google-authenticator-libpam for details
"