summaryrefslogtreecommitdiff
blob: 80c6ce0c57708d98aede782b446b421dc9b1c038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-java/slf4j-api/slf4j-api-1.5.11.ebuild,v 1.5 2010/10/14 16:59:11 ranger Exp $

EAPI="4"
JAVA_PKG_IUSE="doc source test"

inherit user java-pkg-2 java-ant-2

DESCRIPTION="The leading SQL relational database engine written in Java."
HOMEPAGE="http://hsqldb.org/"
SRC_URI="mirror://sourceforge/${PN}/${PN}/${PN}_2_2/${P}.zip"
LICENSE="BSD"
SLOT="2"
KEYWORDS="~amd64"
IUSE=""

COMMON_DEP="java-virtuals/servlet-api:3.0"

RDEPEND=">=virtual/jre-1.6
	${COMMON_DEP}"
DEPEND=">=virtual/jdk-1.6
	app-arch/unzip
	test? ( dev-java/ant-junit
		dev-java/ant-core
		=dev-java/junit-3.8* )
	${COMMON_DEP}"

S="${WORKDIR}/${P}/${PN}"

JAVA_ANT_REWRITE_CLASSPATH="yes"
EANT_GENTOO_CLASSPATH="servlet-api-3.0"
EANT_BUILD_TARGET="hsqldb sqltool hsqldbutil" #+hsqljdbc  ?
EANT_BUILD_XML="build/build.xml"
JAVA_ANT_CLASSPATH_TAGS="${JAVA_ANT_CLASSPATH_TAGS} available"
JAVA_PKG_BSFIX_NAME="build.xml test.xml"
#tests can't be compiled with ecj
JAVA_PKG_FORCE_COMPILER="javac"

HSQLDB_HOME="/var/lib/hsqldb-${SLOT}"

pkg_setup() {
	enewgroup hsqldb
	enewuser hsqldb -1 /bin/sh /dev/null hsqldb
	java-pkg-2_pkg_setup
}

java_prepare() {
	find \( -name '*.jar' -o -name '*.zip' \) -exec rm -v {} + || die
	# don't enable java7-only codepaths, currently there aren't any anyway.
	sed -i -e '/available classname="java.sql.PseudoColumnUsage/d' build/build.xml || die

	# doc-src doesn't exist; upstream make dist bug.
	mv doc doc-src || die

	mkdir conf

	sed -e "s/^server.database.0=.*$/server.database.0=file:${HSQLDB_HOME//\//\\/}\/db0/g" \
		sample/server.properties > conf/server.properties || die
	cp "${FILESDIR}/hsqldb-${SLOT}.conf" "conf/hsqldb-${SLOT}"
	cp conf/server.properties conf/webserver.properties
	sed -e '/^$/{N; /# Each server.database.X/ i \
\
#This is the server port for hsqldb Web Server \
server.port=8080\

}' \
		conf/server.properties > conf/webserver.properties || die
	sed -e '/^$/{N; /# Template for a urlid for an Oracle database/ i\
# This is for a hsqldb Web Server running with default settings on your local \
# computer (and for which you have not changed the password for "SA"). \
# Please note, that port setting should be the same as in webserver.properties \
urlid localhost-web-sa \
url jdbc:hsqldb:http://localhost:8080/ \
username SA \
password \
\

}' \
		sample/sqltool.rc > conf/sqltool.rc || die
}

EANT_TEST_GENTOO_CLASSPATH="servlet-api-3.0,junit" #,ant-core"
EANT_TEST_TARGET="hsqldbtest" #preprocessor"
EANT_TEST_EXTRA_ARGS="-D_junit_available=true"

src_test() {
	java-pkg-2_src_test
	# test-src missing from archieve, upstream make dist bug.
	#EANT_GENTOO_CLASSPATH="junit,ant-core" \
	#	eant -f "${EANT_BUILD_XML}" preprocessor
	#EANT_GENTOO_CLASSPATH="junit,ant-core" \
	#	ANT_OPTS="-Xmx1536m -XX:PermSize=1200m -Djunit.available=true" \
	#	ANT_TASKS="ant-junit" \
	#	eant -f build/test.xml make.test.suite run.test.suite

	local classpath=".:lib/hsqldb.jar:lib/hsqldbtest.jar"
	classpath+=":$(java-pkg_getjars --build-only junit)" || die
	java -cp ${classpath} org.hsqldb.test.TestUtil || die
}

src_install() {
	java-pkg_dojar lib/{hsqldb,hsqldbutil,sqltool}.jar

	if use doc; then
		java-pkg_dojavadoc doc-src/apidocs
		dodoc doc-src/*.txt
	fi
	use source && java-pkg_dosrc src/org

	# Servers
	java-pkg_dolauncher ${PN}-server-${SLOT} \
		--main org.hsqldb.server.Server
	java-pkg_dolauncher ${PN}-webserver-${SLOT} \
		--main org.hsqldb.server.WebServer

	# Tools
	java-pkg_dolauncher ${PN}-manager-${SLOT} \
		--main org.hsqldb.util.DatabaseManagerSwing
	java-pkg_dolauncher ${PN}-sqltool-${SLOT} \
		--main org.hsqldb.cmdline.SqlTool

	# Put init, configuration and authorization files in /etc
	doinitd "${FILESDIR}/hsqldb-${SLOT}"
	doconfd "conf/hsqldb-${SLOT}"

	dodir "/etc/hsqldb-${SLOT}"
	insinto "/etc/hsqldb-${SLOT}"
	# Change the ownership of server.properties and sqltool.rc
	# files to hsqldb:hsqldb. (resolves Bug #111963)
	insopts -m0600 -o hsqldb -g hsqldb
	diropts -m0700 -o hsqldb -g hsqldb

	doins "${S}/conf/server.properties"
	doins "${S}/conf/webserver.properties"
	doins "${S}/conf/sqltool.rc"

	dodir "${HSQLDB_HOME}"

	dodir /var/log
	touch "${D}"var/log/hsqldb-${SLOT}.log
	fowners hsqldb:hsqldb /var/log/hsqldb-${SLOT}.log

	# Create symlink to server.properties
	# (required by the hqldb init script)
	insinto "${HSQLDB_HOME}"
	for cfg in "server.properties" "webserver.properties" "sqltool.rc"; do
		dosym "/etc/hsqldb-${SLOT}/${cfg}" "${HSQLDB_HOME}/${cfg}"
	done

}

pkg_postinst() {
	elog "hsqldb-${SLOT} server will start with default database"
	elog "and default credentials (SA/(empty password))."
	elog "Please change /etc/hsqldb-${SLOT}/server.properties"
	elog "/etc/hsqldb-${SLOT}/sqltool.rc if the default behaviour"
	elog "is not desired."
}