# -*- coding: utf-8; mode: tcl; tab-width: 8; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4
# vim: set fileencoding=utf-8 tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab filetype=tcl :

PortSystem 1.0

name		    derby-server
set packagename	    derby
version		    10.5.3.0
revision	    0
categories	    java
license		    Apache-2
maintainers	    nomaintainer
platforms	    any
supported_archs	noarch

description	    Relational database implemented entirely in Java (incl. server components)
long_description    Apache Derby, an Apache DB subproject, is an open	    \
		    source relational database implemented entirely in	    \
		    Java and available under the Apache License, Version    \
		    2.0.  Some key advantages include:	1) Derby has a	    \
		    small footprint -- about 2 megabytes for the base	    \
		    engine and embedded JDBC driver.  2) Derby is based	    \
		    on the Java, JDBC, and SQL standards.  3) Derby	    \
		    provides an embedded JDBC driver that lets you	    \
		    embed Derby in any Java-based solution.  4) Derby	    \
		    also supports the more familiar client/server mode	    \
		    with the Derby Network Client JDBC driver and Derby	    \
		    Network Server.  5) Derby is easy to install, deploy,   \
		    and use. This version includes the server components.

homepage	    https://db.apache.org/${packagename}
master_sites	    apache:db/${packagename}/db-${packagename}-${version}
distname	    db-${packagename}-${version}-bin
checksums	    md5 35367c636ce035102a039a19ca707986	    \
		    sha1 5293ce194f4c99b6d981ccac248799c766f0270c   \
		    rmd160 886eb0de5f3e1cb45bee8b13acb62d600ac21ae2

depends_lib	    bin:java:kaffe
conflicts	    ${packagename}
default_variants    +symlinks
use_configure	    no
build   	    {}

pre-destroot {
    foreach f [glob -directory ${worksrcpath}/bin *.bat] {
	file delete $f
    }
}

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/java
    xinstall -m 755 -d ${destroot}${applications_dir}/Utilities

    file copy ${worksrcpath} ${destroot}${prefix}/share/java/${packagename}

    foreach script {Start_Derby} {
	xinstall -m 755							\
	   -W ${filespath}						\
	    ${script}.command						\
	    ${destroot}${applications_dir}/Utilities/${script}.command
	reinplace s|@PREFIX@|${prefix}|g				\
	    ${destroot}${applications_dir}/Utilities/${script}.command
    }
}

variant symlinks description {Installs symlinks into ${prefix}/bin} {
    post-destroot {
	foreach f { NetworkServerControl dblook derby_common.sh ij setEmbeddedCP setNetworkClientCP setNetworkServerCP startNetworkServer stopNetworkServer sysinfo } {
	    system "ln -fs ${prefix}/share/java/${packagename}/bin/$f ${destroot}${prefix}/bin/$f"
	}
	ui_msg "#############################################################"
	ui_msg "#  The Derby symblinks in ${prefix}/bin need \${DERBY_HOME} #"
	ui_msg "#  to be set to ${prefix}/java/derby			    #"
	ui_msg "#############################################################"
    }
}

livecheck.type	    regex
livecheck.url	    "https://db.apache.org/derby/derby_downloads.html"
livecheck.regex     release-(\[0-9.\]+)\.html
