summaryrefslogtreecommitdiff
blob: 10a512469e106c24a41f75310264c912218ef4a9 (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/monetdb/monetdb-4.8.2.ebuild,v 1.3 2005/09/10 15:28:11 grobian Exp $

inherit flag-o-matic eutils

DESCRIPTION="A main-memory relational database for SQL, XQuery and MIL"
HOMEPAGE="http://monetdb.cwi.nl/"
PV_SQL=2.8.2
PV_XQ=0.8.2
SRC_URI="mirror://sourceforge/monetdb/MonetDB-${PV}.tar.gz
		mirror://sourceforge/monetdb/MonetDB-SQL-${PV_SQL}.tar.gz
		mirror://sourceforge/monetdb/MonetDB-XQuery-${PV_XQ}.tar.gz
		ppc-macos? ( mirror://gentoo/monetdb-pathfinder-bison-sources-0.8.2.tar.bz2 )"
LICENSE="MonetDBPL-1.1 PathfinderPL-1.1"
SLOT="0"
KEYWORDS="~ppc-macos x86"
IUSE="java readline"

DEPEND="virtual/libc
		sys-devel/flex
		ppc-macos? ( sys-devel/bison )
		!ppc-macos? ( >=sys-devel/bison-1.33 )
		>=sys-devel/gcc-3.3
		java? ( >=virtual/jdk-1.4 )
		readline? ( >=sys-libs/readline-4.1 )
		dev-libs/libxml2"

DATA_DIR="/var/lib/MonetDB"

pkg_setup() {
	if [ -x ${DATA_DIR}/dbfarm ] || [ -x ${DATA_DIR}/log ]; 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".

If you have MIL BATs, aging from before MonetDB 4.8.0 your have to
convert those after upgrading.  See the following for more information
on upgrading from previous database versions:
http://monetdb.cwi.nl/TechDocs/FrontEnds/SQL/upgrade/
http://monetdb.cwi.nl/TechDocs/FrontEnds/mil/upgrade/

You must remove your entire database directory to continue.
(database directory = ${DATA_DIR}).
EOF
		die "Cannot upgrade automatically."
	fi

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

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

	epatch ${FILESDIR}/monetdb-${PV}-gentoo-conf.patch
	epatch ${FILESDIR}/monetdb-${PV}-gentoo-MapiClient.patch
}

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

	econf \
		"--enable-optimize" \
		$(use_with java) \
		$(use_with readline) \
		|| die "econf monetdb failed"

	emake || 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}
	mkdir -p lib/MonetDB
	cd lib/MonetDB
	find ../.. -name "lib_*" -exec ln -s {} ';' >& /dev/null
	ln -s . .libs

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

	cd ${WORKDIR}/MonetDB-${PV}
	mkdir bin
	cd bin
	ln -s ../src/mel/mel
	ln -s ../src/utils/Mx/Mx

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

	# configure and make SQL
	cd ${WORKDIR}/sql-${PV_SQL}
	econf MONETDB_CONFIG=${WORKDIR}/MonetDB-${PV}/bin/monetdb-config \
		"--with-monet=${WORKDIR}/MonetDB-${PV}" \
		"--enable-optimize" \
		`use_with java` || die
	emake || die "emake sql failed"

	# configure and make XQuery, because it relies on >=bison-1.33 which we
	# might not have, we apply a special patch with bison 2.0 generated
	# files.  This is especially useful for OSX users, as this allows
	# them to use this package without having to overwrite their system
	# installed bison 1.28
	cd ${WORKDIR}/pathfinder-${PV_XQ}
	# has_version/best_version do not take package.provided into
	# account! thus we assume OSX users don't have the right bison :(
	if use ppc-macos; then
		einfo "extracting extra files for older bison users"
		tar -jxf ${DISTDIR}/monetdb-pathfinder-bison-sources-${PV_XQ}.tar.bz2
	fi
	econf MONETDB_CONFIG=${WORKDIR}/MonetDB-${PV}/bin/monetdb-config \
		"--with-monet=${WORKDIR}/MonetDB-${PV} " \
		"--enable-optimize" || die
	emake || die "emake xquery failed"
}

src_install() {
	# The tar has capitals, the ebuild doesn't...
	cd ${WORKDIR}/MonetDB-${PV}
	einstall || die "failed to install monetdb"

	cd ${WORKDIR}/sql-${PV_SQL}
	einstall || die "failed to install sql"

	cd ${WORKDIR}/pathfinder-${PV_XQ}
	einstall || die "failed to install xquery"

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

	insinto /etc/conf.d/
	newins ${FILESDIR}/${PN}.conf-${PV} 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}-startup.mil ${PN}-startup.mil || die "startup MIL script"

	# set right permissions
	chown -R monetdb:monetdb ${D}/${DATA_DIR}
	fowners monetdb:monetdb /var/log/${PN}

	# remove Mx and mel, they are only needed for compilation
	rm -f ${D}/usr/bin/Mx ${D}/usr/bin/mel ${D}/usr/bin/idxmx
	# remove windows crap
	rm -f ${D}/usr/bin/*.bat
	# 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
}

pkg_postinst() {
	while read line; do einfo "${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/

If you have upgraded from version 4.6.2 or below you should restore your
SQL databases, as well as convert your MIL BATs.  See also:
http://monetdb.cwi.nl/TechDocs/FrontEnds/SQL/upgrade/
http://monetdb.cwi.nl/TechDocs/FrontEnds/mil/upgrade/
EOF
}