summaryrefslogtreecommitdiff
blob: 3c9618ccc7a229c533cf869fd6c94cb87b641b2c (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/monetdb/monetdb-4.12.0.ebuild,v 1.3 2007/01/31 13:41:05 genone Exp $

inherit flag-o-matic eutils

DESCRIPTION="A main-memory relational database for SQL, XQuery and MIL"
HOMEPAGE="http://monetdb.cwi.nl/"
IUSE="java readline debug"
PV_SQL=${PV/4./2.}
PV_XQ=${PV/4./0.}
PV_M=${PV}
SRC_URI="mirror://sourceforge/monetdb/MonetDB-${PV_M}.tar.gz
	mirror://sourceforge/monetdb/MonetDB-SQL-${PV_SQL}.tar.gz
	mirror://sourceforge/monetdb/MonetDB-XQuery-${PV_XQ}.tar.gz"
LICENSE="MonetDBPL-1.1 PathfinderPL-1.1"
SLOT="0"
KEYWORDS="~ppc ~x86"
RESTRICT="test"

DEPEND="virtual/libc
		>=sys-devel/gcc-3.3
		java? ( >=virtual/jdk-1.4 )
		java? ( dev-java/ant-core )
		readline? ( >=sys-libs/readline-4.1 )
		dev-libs/libxml2
		>=dev-libs/libpcre-5"

DATA_DIR="/var/lib/MonetDB"

pkg_setup() {
	# see if we have a dbfarm, and whether there is a version of monetdb
	# installed which is not a version that we can 'upgrade' to.
	if [ -x "${DATA_DIR}/dbfarm" ] || [ -x "${DATA_DIR}/log" ];
	then
		if [ -x "/usr/bin/monetdb-config" ] && \
			[ "`/usr/bin/monetdb-config --version`" != "${PV_M}" ];
		then
			while read line; do eerror "${line}"; done <<EOF
MonetDB ${MY_PV} cannot upgrade your existing SQL databases.  You must
export your existing SQL databases to a file using "JdbcClient -D" and
then restore them when you have upgraded completey using
"JdbcClient -f".  Dumping and restoring of MIL and XQuery databases
unfortunately is not possible at the moment.

You must remove your entire database directory to continue.
(database directory = ${DATA_DIR}).
See the following url for more information on dumping and
restoring your database:
http://monetdb.cwi.nl/TechDocs/FrontEnds/SQL/upgrade/
EOF
			die "Cannot upgrade automatically."
		fi
	fi

	enewgroup monetdb
	enewuser monetdb -1 /bin/bash "${DATA_DIR}" monetdb
}

src_unpack() {
	unpack ${A} || die

	epatch "${FILESDIR}/${PN}-${PV_M}"-gentoo-MapiClient.patch
	epatch "${FILESDIR}/${PN}-${PV_M}"-gentoo-conf.patch
}

src_compile() {
	# The tar has capitals, the ebuild doesn't...
	cd "${WORKDIR}/MonetDB-${PV_M}"

	# setting these respects the user's CFLAGS and disables -Werror etc.
	local myconf="--disable-optimize --disable-debug"
	sed -i \
		-e 's|CFLAGS="\$CFLAGS \\\$(X_CFLAGS)"||' \
		configure || die "failed fixing configure"

	# Gentoo's amd64 doesn't allow 32-bits monetdb to compile, hence we switch
	# to 64-bits Mserver here.  Note that this also gives 64-bits OIDs.
	use amd64 && myconf="${myconf} --enable-bits=64"

	myconf="${myconf} $(use_with java)"
	myconf="${myconf} $(use_with readline)"
	myconf="${myconf} $(use_enable debug assert)"

	econf ${myconf} || die "econf monetdb failed"

	# NOTE: the Makefiles have serious issues with parallel builds.
	# Nothing is guaranteed to work but a single process build.
	emake -j1 || die "emake monetdb failed"

	# make the header files available to the sql and xquery compilation
	mkdir include
	cd include
	ln -s ../src/common
	ln -s ../src/gdk
	ln -s ../src/monet
	ln -s ../src/modules/plain
	ln -s ../src/modules/contrib
	ln -s ../src/mapi
	ln -s ../src/mapi/clients/C
	ln -s ../monetdb_config.h
	ln -s ../sysdefs.h

	cd "${WORKDIR}/MonetDB-${PV_M}"
	mkdir -p lib/MonetDB
	cd lib/MonetDB
	find ../.. -name "lib_*" -exec ln -s {} ';' >& /dev/null
	ln -s . .libs

	cd "${WORKDIR}/MonetDB-${PV_M}/lib"
	find .. -name "lib*" -exec ln -s {} ';' >& /dev/null
	ln -s . .libs

	# enable the fool-script
	mkdir -p "${WORKDIR}/MonetDB-${PV_M}/bin"
	MYWD=`echo ${WORKDIR} | sed -re 's/\//\\\\\//g'`
	sed -r \
		-e "s/\\$\_MONETDB\_INCLUDEDIR/${MYWD}\/MonetDB-${PV_M}\/include/g" \
		-e "s/\\$\_MONETDB\_VERSION/${PV_M}/g" \
		-e "s/\\$\_MONETDB\_LIBS/-L${MYWD}\/MonetDB-${PV_M}\/lib\/MonetDB -L${MYWD}\/MonetDB-${PV_M}\/lib/g" \
		-e "s/\\$\_MONETDB\_MOD_PATH/${MYWD}\/MonetDB-${PV_M}\/include/g" \
		-e "s/\\$\_MONETDB\_PREFIX/${MYWD}\/MonetDB-${PV_M}/g" \
		-e "s/\\$\_MONETDB\_CLASSPATH/${MYWD}\/MonetDB-${PV_M}\/src\/mapi\/clients\/java\/mapi.jar/g" \
		"${FILESDIR}/monetdb_config.sh" > \
			"${WORKDIR}/MonetDB-${PV_M}/bin/monetdb-config"
	chmod 744 "${WORKDIR}/MonetDB-${PV_M}/bin/monetdb-config"

	# configure and make SQL
	cd "${WORKDIR}/sql-${PV_SQL}"
	econf MONETDB_CONFIG="${WORKDIR}/MonetDB-${PV_M}/bin/monetdb-config" \
		"--with-monet=${WORKDIR}/MonetDB-${PV_M}" \
		${myconf} \
		|| die
	emake -j1 || die "emake sql failed"

	# configure and make XQuery
	cd "${WORKDIR}/pathfinder-${PV_XQ}"
	econf MONETDB_CONFIG="${WORKDIR}/MonetDB-${PV_M}/bin/monetdb-config" \
		"--with-monet=${WORKDIR}/MonetDB-${PV_M} " \
		${myconf} || die
	emake -j1 || die "emake xquery failed"
}

src_install() {
	# The tar has capitals, the ebuild doesn't...
	cd "${WORKDIR}/MonetDB-${PV_M}"
	emake -j1 DESTDIR="${D}" install || die "failed to install monetdb"

	cd "${WORKDIR}/sql-${PV_SQL}"
	emake -j1 DESTDIR="${D}" install || die "failed to install sql"

	cd "${WORKDIR}/pathfinder-${PV_XQ}"
	emake -j1 DESTDIR="${D}" install || die "failed to install xquery"

	exeinto /etc/init.d/
	newexe "${FILESDIR}/${PN}.init-4.8.2" monetdb || die "init.d script"

	insinto /etc/conf.d/
	newins "${FILESDIR}/${PN}.conf-4.8.2" monetdb || die "conf.d file"

	diropts -m750
	dodir "${DATA_DIR}" "/var/log/${PN}"

	exeinto "${DATA_DIR}"
	newexe "${FILESDIR}/${PN}-start.sh" "${PN}-start.sh" || die "start script"
	newexe "${FILESDIR}/${PN}-stop.sh" "${PN}-stop.sh" || die "stop script"

	insinto "${DATA_DIR}"
	newins "${FILESDIR}/${PN}-${PV_M}-startup.mil" "${PN}-startup.mil" \
		|| die "startup MIL script"

	if use java;
	then
		exeinto /usr/bin
		newexe "${FILESDIR}/${PN}.JdbcClient-4.10.0" "JdbcClient" \
			|| die "JdbcClient alias"
	fi

	# set right permissions
	chown -R monetdb:monetdb "${D}/${DATA_DIR}" \
		|| die "setting ownership on ${DATA_DIR} failed"
	fowners monetdb:monetdb "/var/log/${PN}" \
		|| die "setting ownership on /var/log/${PN} failed"

	# remove testing framework and compiled tests
	rm -f \
		"${D}/usr/bin/Mapprove.py" \
		"${D}/usr/bin/Mdiff" \
		"${D}/usr/bin/Mfilter.py" \
		"${D}/usr/bin/MkillUsers" \
		"${D}/usr/bin/Mlog" \
		"${D}/usr/bin/Mprofile.py" \
		"${D}/usr/bin/Mtest.py" \
		"${D}/usr/bin/Mtimeout" \
		"${D}/usr/bin/prof.py" \
		"${D}/usr/share/MonetDB/Mprofile-commands.lst" \
		|| die "removing testing tools"
	rm -Rf \
		"${D}/usr/lib/MonetDB/Tests" \
		"${D}/usr/lib/sql/Tests" \
		"${D}/usr/share/MonetDB/Tests" \
		"${D}/usr/share/sql/Tests" \
		|| die "removing tests"
	# remove windows cruft
	find "${D}" -name "*.bat" | xargs rm -f || die "removing windows stuff"
	# remove perl DBD on ppc-macos, since it gets installed in the wrong
	# location and getting it right is not just a simple thing
	use ppc-macos && rm -Rf "${D}/usr/Network" > /dev/null
}

src_test() {
	# Upstream has tests that work in their "lab-setting".  They prefer to wait
	# using it when they provide a set of tests that is meant to be used
	# outside their "labs".  Those tests will also be supposed not to fail...
	true
}

pkg_postinst() {
	while read line; do elog "${line}"; done <<EOF
MonetDB has been installed on your system, using data directory
${DATA_DIR}.
To get started using SQL, XQuery or MIL see:

http://monetdb.cwi.nl/GettingStarted/
EOF
}