# -*- 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        cracklib cracklib 2.9.11 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0

categories          security
license             LGPL-2.1
maintainers         nomaintainer
description         A ProActive Password Sanity Library
long_description    CrackLib is a library containing a C function (well, \
                    lots of functions really, but you only need to use   \
                    one of them) which may be used in a passwd-like      \
                    program.  The idea is simple: try to prevent users   \
                    from choosing passwords that could be guessed by     \
                    Crack by filtering them out, at source.

depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:gettext \
                    port:libtool \
                    port:bzip2

depends_lib-append  port:gettext-runtime \
                    port:libiconv \
                    port:zlib

checksums           rmd160  80661d1221bee6a21af01a238d3cdfc4f8b10c02 \
                    sha256  78807c1a81ddfee0452b94a603975a468874e7e24804a1ee1c364f9c5c979f66 \
                    size    8672605

worksrcdir          ${distname}/src

configure.cmd       ./autogen.sh && ./configure

configure.args      --without-python

# generate updated version of cracklib-words file
# previously provided by port cracklib-words
# now part of the cracklib github distribution

post-build {
    system -W ${workpath}/${distname} \
         "${prefix}/bin/bzcat `/usr/bin/find words/files -type f` | LC_CTYPE=C /usr/bin/tr ':upper:' ':lower:' | LC_CTYPE=C /usr/bin/sort -u > src/dicts/cracklib-words"
}

# replace installed default words file cracklib-small with generated cracklib-words
# and generate corresponding pw_dict database using cracklib-packer

post-destroot {
    delete ${destroot}${prefix}/share/cracklib/cracklib-small
    copy ${worksrcpath}/dicts/cracklib-words ${destroot}${prefix}/share/cracklib
    system "DYLD_LIBRARY_PATH=${destroot}${prefix}/lib ${destroot}${prefix}/sbin/cracklib-packer ${destroot}${prefix}/share/cracklib/pw_dict < ${destroot}${prefix}/share/cracklib/cracklib-words"
}