# -*- 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               java 1.0
PortGroup               github 1.0

github.setup            w3c epubcheck 5.1.0 v
revision                0

categories              textproc
platforms               any
license                 BSD
maintainers             nomaintainer
supported_archs         noarch

java.version            1.7+
java.fallback           openjdk11

description             EPUB validator

long_description        EPUBCheck is a tool to validate the \
                        conformance of EPUB publications against the \
                        EPUB specifications. EPUBCheck can be run as a \
                        standalone command-line tool or used as a Java \
                        library.

checksums               sha256  74a59af8602bf59b1d04266a450d9cdcb5986e36d825adc403cde0d95e88c9e8 \
                        rmd160  dd2342a5725d976a6988e33350e547ce94f8b917 \
                        size    30332866

# This Portfile downloads the Java bytecode for EPUBCheck from GitHub,
# rather than pulling together all the Java bits and pieces necessary
# to run EPUBCheck
github.tarball_from     releases

use_zip                 yes
extract.post_args       ""

# Since we're just dealing with downloaded bytecode, there is no configure
# and build
use_configure           no

build {}

# Since this is a non-standard installation,
# the standard destroot phase is entirely overridden
destroot {
    # path to the epubcheck java files (without ${destroot}):
    set epubcheck ${prefix}/share/java/epubcheck

    # install the template epubcheck script from files:
    xinstall ${filespath}/epubcheck.in ${destroot}${prefix}/bin/epubcheck

    # set the correct path to epubcheck.jar in the epubcheck script:
    reinplace "s|@@EPUBCHECK@@|${epubcheck}|g" ${destroot}${prefix}/bin/epubcheck

    # install the epubcheck java files:
    xinstall -d ${destroot}${epubcheck}/lib

    xinstall ${worksrcpath}/${name}.jar ${destroot}${epubcheck}/${name}.jar
    xinstall {*}[glob ${worksrcpath}/*.txt] ${destroot}${epubcheck}
    xinstall {*}[glob ${worksrcpath}/lib/*] ${destroot}${epubcheck}/lib
}
