# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4

PortSystem          1.0

name                dcc
version             2.3.169
revision            0
categories          mail
# The license seems to be MIT but with the additional caveat that
# modified copies may not be called "dcc". There is also the additional
# restriction stated on the web site that it "is free only to
# organizations that participate in the global DCC network" but I don't
# see that stated in the actual license file.
license             Restrictive/Distributable
maintainers         nomaintainer

description         The Distributed Checksum Clearinghouses or DCC is an \
                    anti-spam content filter that runs on a variety \
                    of operating systems.
long_description    {*}${description} The counts can be used by SMTP \
                    servers and mail user agents to detect and reject \
                    or filter spam or unsolicited bulk mail. DCC \
                    servers exchange or \"flood\" common \
                    checksums. The checksums include values that are \
                    constant across common variations in bulk \
                    messages, including \"personalizations.\"

homepage            https://www.dcc-servers.net/dcc/
master_sites        ${homepage}source/old/
extract.suffix      .tar.Z

checksums           rmd160  1bb78386215232482a02c410e1eaec46f2de3ec5 \
                    sha256  3447e655476ac742942daf25fc217236da456dd0f82b7117661b9a70484b7bf6 \
                    size    1534973

# DCC is used by rspamd as a spam checker; run it as the ${rspamd_user}, not root
# This should be the same as the local variables in `port file rspamd`
set rspamd_user     _rspamd
set rspamd_group    ${rspamd_user}
add_users ${rspamd_user} group=${rspamd_group} realname=Rspamd

depends_build       port:pkgconfig
# Consider uncommenting after the rspamd port is fixed; see `port file rspamd`
# depends_lib         port:rspamd

# ==============================================================
# The license does not permit distributing modified copies under
# the "dcc" name, so don't ever add any patches to this port.
# ==============================================================
patch {}

configure.pre_args  ""
configure.post_args ""
configure.args      --homedir=${prefix}/etc/${name} \
                    --bindir=${prefix}/bin \
                    --libexecdir=${prefix}/libexec/${name} \
                    --mandir=${prefix}/share/man \
                    --with-rundir=${prefix}/var/run/${name} \
                    --enable-64-bits \
                    --disable-dccm \
                    --with-uid=${rspamd_user} \
                    --with-installroot=${destroot}

build.pre_args      ""
build.post_args     ""

destroot.pre_args   ""
destroot.args       install
destroot.post_args  ""

set mail_basepath   ${prefix}/share/mail

post-destroot {
    # create default directories
    xinstall -o ${rspamd_user} -g ${rspamd_group} -m 0775 -d ${destroot}${prefix}/etc/${name}
    xinstall -m 0755 -d ${destroot}${prefix}/libexec/${name}
    xinstall -o ${rspamd_user} -g ${rspamd_group} -m 0755 -d ${destroot}${prefix}/var/run/${name}
    xinstall -o ${rspamd_user} -g ${rspamd_group} -m 0755 -d ${destroot}${prefix}/var/log/${name}

    # copy the license and FAQ
    xinstall -m 0444 -W ${worksrcpath} LICENSE FAQ.html ${destroot}${prefix}/etc/${name}
}

# Create a launchd.plist for the dccifd socket, run as ${rspamd_user}:${rspand_group}
# This must be run in foreground for launchd (dccifd -b)
startupitem.create  yes
startupitem.name    dccifd
startupitem.executable \
                    ${prefix}/libexec/${name}/dccifd -b \
                    -I ${rspamd_user}

destroot.keepdirs   ${destroot}${prefix}/etc/${name} \
                    ${destroot}${prefix}/var/run/${name} \
                    ${destroot}${prefix}/var/log/${name} \
                    ${destroot}${prefix}/var/${name}
