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

name                ninka
version             1.3
revision            1
categories          devel
platforms           any
maintainers         {ryandesign @ryandesign} openmaintainer
license             GPL-2+

description         license identification tool
long_description    \
    Ninka is a lightweight license identification tool for source code. It is \
    sentence-based, and provides a simple way to identify open source licenses in a \
    source code file. It is capable of identifying several dozen different licenses \
    (and their variations)

# Web site is down: https://github.com/dmgerman/ninka/issues/47
homepage            https://web.archive.org/web/20221130165539/http://ninka.turingmachine.org/
master_sites        https://web.archive.org/web/20160409090107if_/http://ninka.turingmachine.org/download/
livecheck.type      none

depends_lib         bin:perl:perl5
use_bzip2           yes
supported_archs     noarch

checksums           rmd160  84925c82173d54e036b76a6639d018055a033b5c \
                    sha256  fb9c17bcea2c1c2f77ae0adfe1a95adc7778c55041249fba89f2ad5fb75374fb \
                    size    81062

post-extract {
    # Fix incorrect permissions in distfile, and remove backup files that
    # were left in the distfile.
    fs-traverse item ${workpath} {
        if {[string index ${item} end] eq "~"} {
            delete ${item}
        } else {
            file attributes ${item} -permissions a+r
        }
    }
}

set datadir         ${prefix}/share/${name}
set docdir          ${prefix}/share/doc/${subport}

patchfiles          patch-ninka.pl.diff
post-patch {
    reinplace "s|%%DATADIR%%|${datadir}|" ${worksrcpath}/ninka.pl
}

use_configure       no

build {}

destroot {
    xinstall ${worksrcpath}/ninka.pl ${destroot}${prefix}/bin/ninka

    xinstall -d ${destroot}${datadir}
    set directoriesToCopy [list comments extComments filter matcher senttok splitter]
    foreach directory ${directoriesToCopy} {
        copy ${worksrcpath}/${directory} ${destroot}${datadir}
    }

    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} ChangeLog README.TXT ${destroot}${docdir}
}
