summaryrefslogtreecommitdiff
blob: 8e0c15606277038009d99dad0b3a16f31a4011fc (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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/ingres/ingres-10.0.0.111.ebuild,v 1.1 2009/11/15 12:11:08 patrick Exp $

EAPI="2"

inherit eutils flag-o-matic versionator

# amd64 doesn't work yet
KEYWORDS="~x86"
SLOT="0"

# Several Ingres instances can be installed with different
# installation identifiers - default is II
# This is not the same as slotting because we have
# n installations of the same version which is not supported
# by portage (e.g. portage doesn't know which one to unmerge)
II_INSTALLATION=${II_INSTALLATION:-"II"}

# Getting the version strings from the package name
VERSION=$(get_version_component_range 1-3)
SHORT_VERSION=$(get_version_component_range 1-2)
BUILD=$(get_version_component_range 4)

DESCRIPTION="Ingres Relational Database Management System"
HOMEPAGE="http://www.ingres.com/"
SRC_DIR="ingres-${VERSION}-${BUILD}-gpl-src"
SRC_TGZ="${SRC_DIR}.tgz"
DOWNLOAD_URL="http://dev.gentooexperimental.org/~dreeevil/ingres/ingres-${VERSION}-${BUILD}-gpl-src.tgz"
SRC_URI="${DOWNLOAD_URL}/${SRC_TGZ}"
S="${WORKDIR}/${SRC_DIR}"
LICENSE="GPL-2"

# nodbms means client installation
IUSE="client net das odbc demodb"

RDEPEND="dev-libs/xerces-c
	app-arch/pax"

DEPEND="${RDEPEND}
	app-crypt/mit-krb5
	dev-util/ftjam"

PG_DIR="/var/lib/ingres"

pkg_setup() {
	if use client && use demodb; then
		eerror "Cannot install demodb without the dbms"
		die "Invalid USE flags"
	fi

	if [ -d "${PG_DIR}/Ingres${II_INSTALLATION}" ]; then
		einfo "Existing installation found in ${PG_DIR}/Ingres${II_INSTALLATION}."
		einfo "This installation will be upgraded."
		einfo "If that is not what you want press CTRL-C now!"
		epause 5
	fi

	if ps ax | grep -qe "iigc[n|c|d] ${II_INSTALLATION}"; then
		ewarn ""
		ewarn "Running instance of Ingres ${II_INSTALLATION} found!"
		ewarn "Ingres will be compiled and merged but not configured"
		ewarn "when another copy of the same instance is running."
		ewarn "You can do that afterwards with "
		ewarn "USE=\"...\" emerge --config ingres"
		epause 5
	fi

	enewgroup ingres
	enewuser ingres -1 /bin/bash ${PG_DIR} ingres
}

src_prepare() {
	epatch "${FILESDIR}/${SHORT_VERSION}-bldenv.patch"
	epatch "${FILESDIR}/${SHORT_VERSION}-sharelib.patch"
	epatch "${FILESDIR}/${SHORT_VERSION}-Jamdefs.patch"
	epatch "${FILESDIR}/sql.patch"
}

src_compile() {
	export ING_ROOT="${S}"

	local paxlocation=`which pax`
	export PAXLOC=`dirname ${paxlocation}`

	source src/tools/port/jam/bldenv || die "Setting of environment failed"

	cd tools/port/jam
	jam || die "Building of mkjams failed"
	mkjams || die "Creation of jam files failed"

	cd "$ING_SRC"

	grep -vE "gtk|rpm|deb|packman|pixmap" front/st/Jamfile > front/st/_Jamfile
	mv front/st/_Jamfile front/st/Jamfile

	einfo "Compiling Ingres..."

	jam -q || die "Building Ingres failed"

}

src_install() {

	einfo "Creating II_SYSTEM..."

	II_SYSTEM="${D}${PG_DIR}/Ingres${II_INSTALLATION}"

	II_LOC="${II_SYSTEM}/ingres"

	mkdir -p "${II_LOC}"

	DIRS="abf bin ckp data demo dmp files ice jnl lib log sig utility work vdba version.rel"

	for DIR in ${DIRS}; do
		echo -n "${DIR} "
		cp -rpLf "${S}/build/${DIR}" "${II_LOC}/" || die "Copying ${DIR} failed"
	done
	echo
	chown -R ingres:ingres "${II_LOC}"

	cat - > ${II_SYSTEM}/.ing${II_INSTALLATION}bash << EOF
export II_SYSTEM=${PG_DIR}/Ingres${II_INSTALLATION}
export PATH=\$II_SYSTEM/ingres/bin:\$II_SYSTEM/ingres/utility:\$PATH
if [ "\$LD_LIBRARY_PATH" ] ; then
    LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib:\$II_SYSTEM/ingres/lib
else
    LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:\$II_SYSTEM/ingres/lib
fi
export LD_LIBRARY_PATH
export TERM=vt100
export TERM_INGRES=vt100fx
EOF

	newinitd "${FILESDIR}/ingres-initd" ingres${II_INSTALLATION} || die "Adding init.d script failed"

	einfo "done."
}

pkg_config() {

	export II_SYSTEM="${PG_DIR}/Ingres${II_INSTALLATION}"

	ERRMSG="Installing Ingres failed
    You may find information in ${II_SYSTEM}/ingres/files/install.log.
    You can retry by executing USE=\"...\" emerge --config ingres"

	if ps ax | grep -qe "iigc[n|c|d] ${II_INSTALLATION}"; then
		eerror "Running instance of Ingres ${II_INSTALLATION} found!"
		eerror "Please stop that instance first, before upgrading."
		die "${ERRMSG}"
	fi

	einfo "Fixing file permissions..."
	chmod u+s "${II_SYSTEM}/ingres/bin/verifydb"
	chmod u+s "${II_SYSTEM}/ingres/bin/ingvalidpw"
	chmod u+s "${II_SYSTEM}/ingres/bin/iimerge"
	chmod u+s "${II_SYSTEM}/ingres/utility/csreport"

	einfo "Setting up Ingres (please wait - this will take a few minutes)"

	PARTS="tm"

	if ! use client; then
		PARTS="${PARTS} dbms"
	fi
	for FLAG in net das odbc demodb; do
		if use ${FLAG}; then
			PARTS="${PARTS} ${FLAG}"
		fi
	done

	for PART in ${PARTS}; do
		einfo "${PART}..."
		if [ ${PART} == "demodb" ]; then
			su ingres -c "
				. ${II_SYSTEM}/.ing${II_INSTALLATION}bash
				cd ${II_SYSTEM}/ingres/demo/data
				ingstart > /dev/null
				if createdb -n demodb > /dev/null; then
						sql demodb < copy.in > /dev/null
				fi" || die "${ERRMSG}"
		else
			su ingres -c "
				. ${II_SYSTEM}/.ing${II_INSTALLATION}bash
				export II_INSTALLATION=${II_INSTALLATION}
				${II_SYSTEM}/ingres/utility/iisu${PART} -batch" || die "${ERRMSG}"
		fi
	done

	einfo "Upgrading any existing databases"

	su ingres -c "
		. ${II_SYSTEM}/.ing${II_INSTALLATION}bash
		ingstart > /dev/null 2>&1
		upgradedb -all > /dev/null
		ingstop > /dev/null" || die "${ERRMSG}"

	su ingres -c "
		. ${II_SYSTEM}/.ing${II_INSTALLATION}bash
		ingsetenv ING_ABFDIR ${II_SYSTEM}/ingres/abf" || die "${ERRMSG}"

	"${II_SYSTEM}/ingres/bin/mkvalidpw" > /dev/null || die "${ERRMSG}"

	einfo "Done."

}

pkg_postinst() {

	pkg_config

	elog ""
	elog "Run '/etc/init.d/ingres${II_INSTALLATION} start' to start Ingres"
	elog ""
	elog "After that, as user ingres type"
	elog "  source ${PG_DIR}/Ingres${II_INSTALLATION}/.ing${II_INSTALLATION}bash"
	elog "to run the Ingres commands such as sql or createdb."

}