/[gentoo-x86]/eclass/mysql.eclass
Gentoo

Diff of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.25 Revision 1.26
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.25 2006/03/16 20:39:00 vivo Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.26 2006/03/17 20:17:53 vivo Exp $
4 4
5# Author: Francesco Riosa <vivo at gentoo.org> 5# Author: Francesco Riosa <vivo at gentoo.org>
6# Maintainer: Francesco Riosa <vivo at gentoo.org> 6# Maintainer: Francesco Riosa <vivo at gentoo.org>
7 7
8# MYSQL_VERSION_ID will be
9# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo magic number, all [0..99]
10# this is an important piece, becouse from this variable depends many of the
11# choices the ebuild will do.
12# in particular the code below work only with PVR like "5.0.18-r3"
13# the result with the previous PVR is "5001803"
14if [[ -z ${MYSQL_VERSION_ID} ]] ; then
15 tpv=( ${PV//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
16 for vatom in 0 1 2 3; do
17 # pad to lenght 2
18 tpv[${vatom}]="00${tpv[${vatom}]}"
19 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
20 done
21 # strip leading "0" (otherwise it's considered an octal number from bash)
22 MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
23fi
24
25[[ -z ${MY_EXTRAS_VER} ]] && MY_EXTRAS_VER="20060316"
26
27DEPEND="${DEPEND}
28 >=sys-libs/readline-4.1
29 berkdb? ( sys-apps/ed )
30 ssl? ( >=dev-libs/openssl-0.9.6d )
31 userland_GNU? ( sys-process/procps )
32 >=sys-libs/zlib-1.2.3
33 >=sys-apps/texinfo-4.7-r1
34 >=sys-apps/sed-4"
35RDEPEND="${DEPEND} selinux? ( sec-policy/selinux-mysql )"
36# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
37PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
38
8inherit eutils flag-o-matic gnuconfig autotools mysql_fx 39inherit eutils flag-o-matic gnuconfig autotools mysql_fx
9 40
10#major, minor only in the slot 41SLOT=0
11SLOT=$(( ${MYSQL_VERSION_ID} / 10000 ))
12 42
13# shorten the path because the socket path length must be shorter than 107 chars 43# shorten the path because the socket path length must be shorter than 107 chars
14# and we will run a mysql server during test phase 44# and we will run a mysql server during test phase
15S="${WORKDIR}/${PN}" 45S="${WORKDIR}/${PN}"
16 46
33&& IUSE="${IUSE} max-idx-128" 63&& IUSE="${IUSE} max-idx-128"
34 64
35mysql_version_is_at_least "5.01.00.00" \ 65mysql_version_is_at_least "5.01.00.00" \
36&& IUSE="${IUSE} innodb" 66&& IUSE="${IUSE} innodb"
37 67
38EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_prerm pkg_postrm 68EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst \
69 pkg_postinst pkg_config pkg_postrm
39 70
40# void mysql_init_vars() 71# void mysql_init_vars()
41# 72#
42# initialize global variables 73# initialize global variables
43# 2005-11-19 <vivo at gentoo.org> 74# 2005-11-19 <vivo at gentoo.org>
44mysql_init_vars() { 75mysql_init_vars() {
45 76
46 if [[ ${SLOT} -eq 0 ]] ; then
47 MY_SUFFIX=""
48 else
49 MY_SUFFIX=${MY_SUFFIX:-"-${SLOT}"}
50 fi
51 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR:-"/usr/share/mysql${MY_SUFFIX}"} 77 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR:-"/usr/share/mysql"}
52 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql${MY_SUFFIX}"} 78 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"}
53 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql${MY_SUFFIX}"} 79 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql$"}
54 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql${MY_SUFFIX}"} 80 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"}
55 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql${MY_SUFFIX}"} 81 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"}
56 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql${MY_SUFFIX}"} 82 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"}
57 83
58 if [ -z "${DATADIR}" ]; then 84 if [ -z "${DATADIR}" ]; then
59 DATADIR="" 85 DATADIR=""
60 if [ -f "${MY_SYSCONFDIR}/my.cnf" ] ; then 86 if [ -f "${MY_SYSCONFDIR}/my.cnf" ] ; then
61 DATADIR=`"my_print_defaults${MY_SUFFIX}" mysqld 2>/dev/null | sed -ne '/datadir/s|^--datadir=||p' | tail -n1` 87 DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
88 | sed -ne '/datadir/s|^--datadir=||p' \
89 | tail -n1`
62 if [ -z "${DATADIR}" ]; then 90 if [ -z "${DATADIR}" ]; then
63 if useq "srvdir" ; then 91 if useq "srvdir" ; then
64 DATADIR="${ROOT}/srv/localhost/mysql${MY_SUFFIX}/datadir" 92 DATADIR="${ROOT}/srv/localhost/mysql/datadir"
65 else 93 else
66 DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" | sed -e 's/.*=\s*//'` 94 DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
95 | sed -e 's/.*=\s*//'`
67 fi 96 fi
68 fi 97 fi
69 fi 98 fi
70 if [ -z "${DATADIR}" ]; then 99 if [ -z "${DATADIR}" ]; then
71 if useq "srvdir" ; then 100 if useq "srvdir" ; then
72 DATADIR="${ROOT}/srv/localhost/mysql${MY_SUFFIX}/datadir" 101 DATADIR="${ROOT}/srv/localhost/mysql/datadir"
73 else 102 else
74 DATADIR="${MY_LOCALSTATEDIR}" 103 DATADIR="${MY_LOCALSTATEDIR}"
75 fi 104 fi
76 einfo "Using default DATADIR" 105 einfo "Using default DATADIR"
77 fi 106 fi
88 export PREVIOUS_DATADIR 117 export PREVIOUS_DATADIR
89 fi 118 fi
90 fi 119 fi
91 fi 120 fi
92 121
93 export MY_SUFFIX MY_SHAREDSTATEDIR MY_SYSCONFDIR 122 export MY_SHAREDSTATEDIR MY_SYSCONFDIR
94 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR 123 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
95 export MY_INCLUDEDIR 124 export MY_INCLUDEDIR
96 export DATADIR 125 export DATADIR
97} 126}
98 127
105 134
106mysql_src_unpack() { 135mysql_src_unpack() {
107 136
108 mysql_init_vars 137 mysql_init_vars
109 138
110 if useq static && useq ssl; then 139 if useq "static" && useq "ssl" ; then
111 local msg="MySQL does not support building statically with SSL support" 140 local msg="MySQL does not support building statically with SSL support"
112 eerror "${msg}" 141 eerror "${msg}"
113 die "${msg}" 142 die "${msg}"
114 fi 143 fi
115 144
116 if mysql_version_is_at_least "4.01.03.00" \ 145 if mysql_version_is_at_least "4.01.03.00" \
117 && useq cluster \ 146 && useq "cluster" \
118 || useq extraengine \ 147 || useq "extraengine" \
119 && useq minimal ; then 148 && useq "minimal" ; then
120 die "USEs cluster, extraengine conflicts with \"minimal\"" 149 die "USEs cluster, extraengine conflicts with \"minimal\""
121 fi 150 fi
122 151
123 unpack ${A} || die 152 unpack ${A} || die
124 153
139 find . -name 'Makefile.am' \ 168 find . -name 'Makefile.am' \
140 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \; 169 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
141 170
142 # Manage mysqlmanager 171 # Manage mysqlmanager
143 mysql_version_is_at_least "5.00.15.00" \ 172 mysql_version_is_at_least "5.00.15.00" \
144 && sed -i -e "s!@GENTOO_EXT@!${MY_SUFFIX}!g" \ 173 && sed -i -e "s!@GENTOO_EXT@!!g" \
145 -e "s!@GENTOO_SOCK_PATH@!var/run/mysqld!g" \ 174 -e "s!@GENTOO_SOCK_PATH@!var/run/mysqld!g" \
146 "${S}/server-tools/instance-manager/Makefile.am" 175 "${S}/server-tools/instance-manager/Makefile.am"
147 176
148 # remove what need to be recreated, so we are sure it's actually done 177 # remove what need to be recreated, so we are sure it's actually done
149 find . -name Makefile -o -name Makefile.in -o -name configure -exec rm -f {} \; 178 find . -name Makefile \
179 -o -name Makefile.in \
180 -o -name configure \
181 -exec rm -f {} \;
150 rm ltmain.sh 182 rm ltmain.sh
151 183
152 local rebuilddirlist d buildstep bdbdir 184 local rebuilddirlist d buildstep bdbdir
153 185
154 if mysql_version_is_at_least "5.01.00.00" ; then 186 if mysql_version_is_at_least "5.01.00.00" ; then
165 AT_GNUCONF_UPDATE="yes" eautoreconf 197 AT_GNUCONF_UPDATE="yes" eautoreconf
166 popd &>/dev/null 198 popd &>/dev/null
167 done 199 done
168 200
169 #TODO berkdb in 5.1 need to be worked on 201 #TODO berkdb in 5.1 need to be worked on
170 if useq berkdb && ! mysql_check_version_range "5.01.00.00 to 5.01.08.99" 202 if useq "berkdb" && ! mysql_check_version_range "5.01.00.00 to 5.01.08.99"
171 then 203 then
172 [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh" 204 [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh"
173 pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" &>/dev/null 205 pushd "${bdbdir}" \
206 && sh s_all \
207 || die "failed bdb reconfigure" \
208 &>/dev/null
174 popd &>/dev/null 209 popd &>/dev/null
175 fi 210 fi
176 211
177} 212}
178 213
179mysql_src_compile() { 214mysql_src_compile() {
180 215
181 mysql_init_vars 216 mysql_init_vars
182 local myconf 217 local myconf
183 218
184 if useq static ; then 219 if useq "static" ; then
185 myconf="${myconf} --with-mysqld-ldflags=-all-static" 220 myconf="${myconf} --with-mysqld-ldflags=-all-static"
186 myconf="${myconf} --with-client-ldflags=-all-static" 221 myconf="${myconf} --with-client-ldflags=-all-static"
187 myconf="${myconf} --disable-shared" 222 myconf="${myconf} --disable-shared"
188 else 223 else
189 myconf="${myconf} --enable-shared --enable-static" 224 myconf="${myconf} --enable-shared --enable-static"
190 fi 225 fi
191 226
192 #myconf="${myconf} `use_with tcpd libwrap`" 227 #myconf="${myconf} `use_with tcpd libwrap`"
193 myconf="${myconf} --without-libwrap" 228 myconf="${myconf} --without-libwrap"
194 229
195 if useq ssl ; then 230 if useq "ssl" ; then
196 # --with-vio is not needed anymore, it's on by default and 231 # --with-vio is not needed anymore, it's on by default and
197 # has been removed from configure 232 # has been removed from configure
198 mysql_version_is_at_least "5.00.04.00" || myconf="${myconf} --with-vio" 233 mysql_version_is_at_least "5.00.04.00" || myconf="${myconf} --with-vio"
199 if mysql_version_is_at_least "5.00.06.00" ; then 234 if mysql_version_is_at_least "5.00.06.00" ; then
200 # yassl-0.96 is young break with gcc-4.0 || amd64 235 # yassl-0.96 is young break with gcc-4.0 || amd64
205 fi 240 fi
206 else 241 else
207 myconf="${myconf} --without-openssl" 242 myconf="${myconf} --without-openssl"
208 fi 243 fi
209 244
210 if useq debug; then 245 if useq "debug"; then
211 myconf="${myconf} --with-debug=full" 246 myconf="${myconf} --with-debug=full"
212 else 247 else
213 myconf="${myconf} --without-debug" 248 myconf="${myconf} --without-debug"
214 mysql_version_is_at_least "4.01.03.00" && useq cluster && myconf="${myconf} --without-ndb-debug" 249 mysql_version_is_at_least "4.01.03.00" \
215 fi 250 && useq "cluster" \
216
217 # benchmarking stuff needs perl
218 # and shouldn't be bothered with on minimal builds
219 if useq perl && ! useq minimal; then
220 myconf="${myconf} --with-bench"
221 else
222 myconf="${myconf} --without-bench" 251 && myconf="${myconf} --without-ndb-debug"
223 fi 252 fi
224 253
225 # these are things we exclude from a minimal build 254 # these are things we exclude from a minimal build
226 # note that the server actually does get built and installed 255 # note that the server actually does get built and installed
227 # but we then delete it before packaging. 256 # but we then delete it before packaging.
228 local minimal_exclude_list="server embedded-server extra-tools innodb" 257 local minimal_exclude_list="server embedded-server extra-tools innodb bench"
258
229 if ! useq minimal; then 259 if ! useq "minimal" ; then
230 for i in ${minimal_exclude_list}; do
231 myconf="${myconf} --with-${i}" 260 myconf="${myconf} --with-server"
232 done 261 myconf="${myconf} --with-extra-tools"
233 262
234 if useq static ; then 263 if useq "static" ; then
235 myconf="${myconf} --without-raid" 264 myconf="${myconf} --without-raid"
236 ewarn "disabling raid support, has problem with static" 265 ewarn "disabling raid support, has problem with static"
237 else 266 else
238 if mysql_version_is_at_least "5.00.00.00" ; then 267 if mysql_version_is_at_least "5.00.00.00" ; then
239 myconf="${myconf} --without-raid" 268 myconf="${myconf} --without-raid"
263 myconf="${myconf} --with-extra-charsets=all" 292 myconf="${myconf} --with-extra-charsets=all"
264 293
265 #The following fix is due to a bug with bdb on sparc's. See: 294 #The following fix is due to a bug with bdb on sparc's. See:
266 #http://www.geocrawler.com/mail/msg.php3?msg_id=4754814&list=8 295 #http://www.geocrawler.com/mail/msg.php3?msg_id=4754814&list=8
267 # it comes down to non-64-bit safety problems 296 # it comes down to non-64-bit safety problems
268 if useq sparc || useq alpha || useq hppa || useq mips || useq amd64 \ 297 if useq "sparc" || useq "alpha" || useq "hppa" || useq "mips" \
269 || mysql_check_version_range "5.01.00.00 to 5.01.06.99" 298 || useq "amd64" || mysql_check_version_range "5.01.00.00 to 5.01.06.99"
270 then 299 then
271 ewarn "bdb berkeley-db disabled due to arch or version" 300 ewarn "bdb berkeley-db disabled due to arch or version"
272 myconf="${myconf} --without-berkeley-db" 301 myconf="${myconf} --without-berkeley-db"
273 else 302 else
274 #TODO berkdb in 5.1 need to be worked on 303 #TODO berkdb in 5.1 need to be worked on
275 useq berkdb && \ 304 useq "berkdb" && \
276 ! mysql_check_version_range "5.01.00.00 to 5.01.08.99" \ 305 ! mysql_check_version_range "5.01.00.00 to 5.01.08.99" \
277 && myconf="${myconf} --with-berkeley-db=./bdb" \ 306 && myconf="${myconf} --with-berkeley-db=./bdb" \
278 || myconf="${myconf} --without-berkeley-db" 307 || myconf="${myconf} --without-berkeley-db"
279 fi 308 fi
280 309
282 #myconf="${myconf} $(use_with geometry)" 311 #myconf="${myconf} $(use_with geometry)"
283 myconf="${myconf} --with-geometry" 312 myconf="${myconf} --with-geometry"
284 myconf="${myconf} $(use_with cluster ndbcluster)" 313 myconf="${myconf} $(use_with cluster ndbcluster)"
285 fi 314 fi
286 315
287 mysql_version_is_at_least "4.01.11.00" && myconf="${myconf} `use_with big-tables`" 316 mysql_version_is_at_least "4.01.11.00" \
317 && myconf="${myconf} `use_with big-tables`"
288 318
289 mysql_version_is_at_least "5.01.06.00" && myconf="${myconf} --with-ndb-binlog" 319 mysql_version_is_at_least "5.01.06.00" \
320 && myconf="${myconf} --with-ndb-binlog"
290 321
291 if useq embedded ; then 322 if useq "embedded" ; then
292 #REMIND, need the privilege control enabled ? 323 #REMIND, need the privilege control enabled ?
293 myconf="${myconf} --without-embedded-privilege-control" 324 myconf="${myconf} --without-embedded-privilege-control"
294 myconf="${myconf} --with-embedded-server" 325 myconf="${myconf} --with-embedded-server"
295 else 326 else
296 myconf="${myconf} --without-embedded-privilege-control" 327 myconf="${myconf} --without-embedded-privilege-control"
297 myconf="${myconf} --without-embedded-server" 328 myconf="${myconf} --without-embedded-server"
298 fi 329 fi
330
331 # benchmarking stuff needs perl
332 if useq "perl" ; then
333 myconf="${myconf} --with-bench"
334 else
335 myconf="${myconf} --without-bench"
336 fi
299 else 337 else
300 for i in ${minimal_exclude_list}; do 338 for i in ${minimal_exclude_list}; do
301 myconf="${myconf} --without-${i}" 339 myconf="${myconf} --without-${i}"
302 done 340 done
303 myconf="${myconf} --without-berkeley-db" 341 myconf="${myconf} --without-berkeley-db"
304 myconf="${myconf} --with-extra-charsets=none" 342 myconf="${myconf} --with-extra-charsets=none"
305 fi 343 fi
306 344
307 if mysql_version_is_at_least "4.01.03.00" && useq extraengine; then 345 if mysql_version_is_at_least "4.01.03.00" && useq "extraengine"; then
308 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html 346 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html
309 myconf="${myconf} --with-archive-storage-engine" 347 myconf="${myconf} --with-archive-storage-engine"
310 # http://dev.mysql.com/doc/mysql/en/csv-storage-engine.html 348 # http://dev.mysql.com/doc/mysql/en/csv-storage-engine.html
311 349
312 mysql_version_is_at_least "4.01.04.00" \ 350 mysql_version_is_at_least "4.01.04.00" \
336 374
337 if mysql_version_is_at_least "5.01.05.00" ; then 375 if mysql_version_is_at_least "5.01.05.00" ; then
338 myconf="${myconf} --with-row-based-replication" 376 myconf="${myconf} --with-row-based-replication"
339 fi 377 fi
340 378
341 #TODO rechek again later, had problem with assembler enabled 379 #TODO rechek again later, had problem with assembler enabled
342 # and some combination of use-flags with 5.1 380 # and some combination of use-flags with 5.1
343 if mysql_check_version_range "5.01.00.00 to 5.01.08.99" ; then 381 if mysql_check_version_range "5.01.00.00 to 5.01.08.99" ; then
344 myconf="${myconf} --disable-assembler" 382 myconf="${myconf} --disable-assembler"
345 else 383 else
346 myconf="${myconf} --enable-assembler" 384 myconf="${myconf} --enable-assembler"
356 export CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-exceptions -fno-rtti" 394 export CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-exceptions -fno-rtti"
357 mysql_version_is_at_least "5.00.00.00" \ 395 mysql_version_is_at_least "5.00.00.00" \
358 && export CXXFLAGS="${CXXFLAGS} -fno-implicit-templates" 396 && export CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
359 397
360 econf \ 398 econf \
361 --program-suffix="${MY_SUFFIX}" \
362 --libexecdir="/usr/sbin" \ 399 --libexecdir="/usr/sbin" \
363 --sysconfdir="${MY_SYSCONFDIR}" \ 400 --sysconfdir="${MY_SYSCONFDIR}" \
364 --localstatedir="${MY_LOCALSTATEDIR}" \ 401 --localstatedir="${MY_LOCALSTATEDIR}" \
365 --sharedstatedir="${MY_SHAREDSTATEDIR}" \ 402 --sharedstatedir="${MY_SHAREDSTATEDIR}" \
366 --libdir="${MY_LIBDIR}" \ 403 --libdir="${MY_LIBDIR}" \
370 --with-mysqld-user=mysql \ 407 --with-mysqld-user=mysql \
371 --with-client-ldflags=-lstdc++ \ 408 --with-client-ldflags=-lstdc++ \
372 --enable-thread-safe-client \ 409 --enable-thread-safe-client \
373 --with-comment="Gentoo Linux ${PF}" \ 410 --with-comment="Gentoo Linux ${PF}" \
374 --with-unix-socket-path="/var/run/mysqld/mysqld.sock" \ 411 --with-unix-socket-path="/var/run/mysqld/mysqld.sock" \
375 --with-lib-ccflags="-fPIC" \
376 --without-readline \ 412 --without-readline \
377 --without-docs \ 413 --without-docs \
378 ${myconf} || die "bad ./configure" 414 ${myconf} || die "bad ./configure"
379 415
380 # TODO Move this before autoreconf !!! 416 # TODO Move this before autoreconf !!!
392 428
393 insinto "${MY_INCLUDEDIR}" 429 insinto "${MY_INCLUDEDIR}"
394 doins "${MY_INCLUDEDIR}"/my_{config,dir}.h 430 doins "${MY_INCLUDEDIR}"/my_{config,dir}.h
395 431
396 # convenience links 432 # convenience links
397 dosym "/usr/bin/mysqlcheck${MY_SUFFIX}" "/usr/bin/mysqlanalyze${MY_SUFFIX}" 433 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
398 dosym "/usr/bin/mysqlcheck${MY_SUFFIX}" "/usr/bin/mysqlrepair${MY_SUFFIX}" 434 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
399 dosym "/usr/bin/mysqlcheck${MY_SUFFIX}" "/usr/bin/mysqloptimize${MY_SUFFIX}" 435 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
400 436
401 # various junk (my-*.cnf moved elsewhere) 437 # various junk (my-*.cnf moved elsewhere)
402 rm -rf "${D}/usr/share/info" 438 rm -rf "${D}/usr/share/info"
403 for removeme in "mysql-log-rotate" mysql.server* \ 439 for removeme in "mysql-log-rotate" mysql.server* \
404 binary-configure* my-*.cnf mi_test_all* 440 binary-configure* my-*.cnf mi_test_all*
405 do 441 do
406 rm -f ${D}/usr/share/mysql/${removeme} 442 rm -f ${D}/usr/share/mysql/${removeme}
407 done 443 done
408 444
409 # TODO change at Makefile-am level
410 for moveme in "mysql_fix_privilege_tables.sql" \
411 "fill_help_tables.sql" "ndb-config-2-node.ini"
412 do
413 mv -f "${D}/usr/share/mysql/${moveme}" "${D}/usr/share/mysql${MY_SUFFIX}/" 2>/dev/null
414 done
415
416 if [[ -n "${MY_SUFFIX}" ]] ; then
417 local notcatched=$(ls "${D}/usr/share/mysql"/*)
418 if [[ -n "${notcatched}" ]] ; then
419 ewarn "QA notice"
420 ewarn "${notcatched} files in /usr/share/mysql"
421 ewarn "bug mysql-herd to manage them"
422 fi
423 rm -rf "${D}/usr/share/mysql"
424 fi
425
426 # clean up stuff for a minimal build 445 # clean up stuff for a minimal build
427 # this is anything server-specific 446 # this is anything server-specific
428 if useq minimal; then 447 if useq "minimal" ; then
429 rm -rf ${D}${MY_SHAREDSTATEDIR}/{mysql-test,sql-bench} 448 rm -rf ${D}${MY_SHAREDSTATEDIR}/{mysql-test,sql-bench}
430 rm -f ${D}/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam} 449 rm -f ${D}/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
431 rm -f "${D}/usr/sbin/mysqld${MY_SUFFIX}" 450 rm -f "${D}/usr/sbin/mysqld"
432 rm -f ${D}${MY_LIBDIR}/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a 451 rm -f ${D}${MY_LIBDIR}/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
433 fi 452 fi
434 453
435 # config stuff 454 # config stuff
436 insinto "${MY_SYSCONFDIR}" 455 insinto "${MY_SYSCONFDIR}"
437 doins scripts/mysqlaccess.conf 456 doins scripts/mysqlaccess.conf
438 sed -e "s!@MY_SUFFIX@!${MY_SUFFIX}!g" \ 457 sed -e "s!@MY_SUFFIX@!!g" \
439 -e "s!@DATADIR@!${DATADIR}!g" \ 458 -e "s!@DATADIR@!${DATADIR}!g" \
440 "${FILESDIR}/my.cnf-4.1-r1" \ 459 "${FILESDIR}/my.cnf-4.1-r1" \
441 > "${TMPDIR}/my.cnf.ok" 460 > "${TMPDIR}/my.cnf.ok"
442 newins "${TMPDIR}/my.cnf.ok" my.cnf 461 newins "${TMPDIR}/my.cnf.ok" my.cnf
443 462
445 newins "${FILESDIR}/mysql.conf.d-r1" "mysql" 464 newins "${FILESDIR}/mysql.conf.d-r1" "mysql"
446 mysql_version_is_at_least "5.00.11.00" \ 465 mysql_version_is_at_least "5.00.11.00" \
447 && newins "${FILESDIR}/mysqlmanager.conf.d" "mysqlmanager" 466 && newins "${FILESDIR}/mysqlmanager.conf.d" "mysqlmanager"
448 467
449 # minimal builds don't have the server 468 # minimal builds don't have the server
450 if ! useq minimal; then 469 if ! useq "minimal" ; then
451 exeinto /etc/init.d 470 exeinto /etc/init.d
452 newexe "${FILESDIR}/mysql.rc6-r3" "mysql" 471 newexe "${FILESDIR}/mysql.rc6-r3" "mysql"
453 472
454 mysql_version_is_at_least "5.00.11.00" \ 473 mysql_version_is_at_least "5.00.11.00" \
455 && newexe "${FILESDIR}/mysqlmanager.rc6" "mysqlmanager" 474 && newexe "${FILESDIR}/mysqlmanager.rc6" "mysqlmanager"
456 insinto /etc/logrotate.d 475 insinto /etc/logrotate.d
457 sed -e "s!___MY_SUFFIX___!${MY_SUFFIX}!g" \
458 "${FILESDIR}/logrotate-slot.mysql" \
459 > "${TMPDIR}/logrotate.mysql"
460 newins "${TMPDIR}/logrotate.mysql" "mysql${MY_SUFFIX}" 476 newins "${FILESDIR}/logrotate.mysql" "mysql"
461 477
462 #empty dirs... 478 #empty dirs...
463 diropts "-m0750" 479 diropts "-m0750"
464 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then 480 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
465 dodir "${DATADIR}" 481 dodir "${DATADIR}"
476 fi 492 fi
477 493
478 # docs 494 # docs
479 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE 495 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE
480 # minimal builds don't have the server 496 # minimal builds don't have the server
481 if ! useq minimal; then 497 if ! useq "minimal" ; then
482 docinto "support-files" 498 docinto "support-files"
483 for script in \ 499 for script in \
484 support-files/my-*.cnf \ 500 support-files/my-*.cnf \
485 support-files/magic \ 501 support-files/magic \
486 support-files/ndb-config-2-node.ini 502 support-files/ndb-config-2-node.ini
492 for script in scripts/mysql* ; do 508 for script in scripts/mysql* ; do
493 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}" 509 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
494 done 510 done
495 fi 511 fi
496 512
497 # oops, temporary fix 513 ROOT="${D}" mysql_lib_symlinks
498 mysql_check_version_range "5.00.16.00 to 5.00.18.99" \
499 && cp -f \
500 "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0" \
501 "${D}/usr/share/mysql${MY_SUFFIX}/fill_help_tables.sql"
502
503 if [[ ${SLOT} -gt 0 ]] ; then
504 # MOVED HERE DUE TO BUG #121445
505 # create a list of files, to be used
506 # by external utilities
507 mkdir -p "${D}/var/lib/eselect/mysql/"
508 local filelist="${D}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist"
509 pushd "${D}/" &>/dev/null
510 find usr/bin/ usr/sbin/ \
511 -type f -name "*${MY_SUFFIX}*" \
512 -and -not -name "mysql_config${MY_SUFFIX}" \
513 > "${filelist}"
514 find usr/share/man \
515 -type f -name "*${MY_SUFFIX}*" \
516 | sed -e 's/$/.gz/' \
517 >> "${filelist}"
518 echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}"
519 echo "${MY_LIBDIR#"/"}" >> "${filelist}"
520 echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}"
521 popd &>/dev/null
522 fi
523
524 # It's safer portage wis doing this in instal, but we can't
525 # if it's a slotted install
526 [[ ${SLOT} -eq 0 ]] && ROOT="${D}" mysql_lib_symlinks
527} 514}
528 515
529mysql_pkg_preinst() { 516mysql_pkg_preinst() {
530 517
531 enewgroup mysql 60 || die "problem adding group mysql" 518 enewgroup mysql 60 || die "problem adding group mysql"
534} 521}
535 522
536mysql_pkg_postinst() { 523mysql_pkg_postinst() {
537 524
538 mysql_init_vars 525 mysql_init_vars
539 # slotted, manage lib symlinks on the real file-system
540 # to cope with other version installed
541 [[ ${SLOT} -ne 0 ]] && mysql_lib_symlinks
542 526
543 # mind at FEATURES=collision-protect before to remove this 527 # mind at FEATURES=collision-protect before to remove this
544 [ -d "${ROOT}/var/log/mysql" ] \ 528 [ -d "${ROOT}/var/log/mysql" ] \
545 || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 529 || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
546 530
547 #secure the logfiles... does this bother anybody? 531 #secure the logfiles... does this bother anybody?
548 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 532 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
549 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 533 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
550 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 534 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
551 535
552 if ! useq minimal; then 536 if ! useq "minimal" ; then
553 if [[ ${SLOT} -gt 0 ]] ; then
554 einfo "you may want to read:"
555 einfo "http://www.gentoo.org/doc/en/mysql-upgrade-slotted.xml"
556 einfo "you may want to run \"eselect mysql list\" followed by a "
557 einfo "\"eselect mysql set 1\" to choose the default mysql server"
558 fi
559
560 # your friendly public service announcement... 537 # your friendly public service announcement...
561 einfo 538 einfo
562 einfo "You might want to run:" 539 einfo "You might want to run:"
563 einfo "\"emerge --config =${CATEGORY}/${PF}\"" 540 einfo "\"emerge --config =${CATEGORY}/${PF}\""
564 einfo "if this is a new install." 541 einfo "if this is a new install."
609 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 586 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
610 || touch "${TMPDIR}/fill_help_tables.sql" 587 || touch "${TMPDIR}/fill_help_tables.sql"
611 help_tables="${TMPDIR}/fill_help_tables.sql" 588 help_tables="${TMPDIR}/fill_help_tables.sql"
612 589
613 pushd "${TMPDIR}" &>/dev/null 590 pushd "${TMPDIR}" &>/dev/null
614 ${ROOT}/usr/bin/mysql_install_db${MY_SUFFIX} | grep -B5 -A999 -i "ERROR" 591 ${ROOT}/usr/bin/mysql_install_db | grep -B5 -A999 -i "ERROR"
615 popd &>/dev/null 592 popd &>/dev/null
616 [[ -f ${ROOT}/${DATADIR}/mysql/user.frm ]] || die "MySQL databases not installed" 593 [[ -f ${ROOT}/${DATADIR}/mysql/user.frm ]] \
594 || die "MySQL databases not installed"
617 chown -R mysql:mysql ${ROOT}/${DATADIR} 2> /dev/null 595 chown -R mysql:mysql ${ROOT}/${DATADIR} 2> /dev/null
618 chmod 0750 ${ROOT}/${DATADIR} 2> /dev/null 596 chmod 0750 ${ROOT}/${DATADIR} 2> /dev/null
619 597
620 if mysql_version_is_at_least "4.01.03.00" ; then 598 if mysql_version_is_at_least "4.01.03.00" ; then
621 options="--skip-ndbcluster" 599 options="--skip-ndbcluster"
622 600
623 # Filling timezones, see 601 # Filling timezones, see
624 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 602 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
625 ${ROOT}/usr/bin/mysql_tzinfo_to_sql${MY_SUFFIX} ${ROOT}/usr/share/zoneinfo \ 603 ${ROOT}/usr/bin/mysql_tzinfo_to_sql ${ROOT}/usr/share/zoneinfo \
626 > "${sqltmp}" 2>/dev/null 604 > "${sqltmp}" 2>/dev/null
627 605
628 if [[ -r "${help_tables}" ]] ; then 606 if [[ -r "${help_tables}" ]] ; then
629 cat "${help_tables}" >> "${sqltmp}" 607 cat "${help_tables}" >> "${sqltmp}"
630 fi 608 fi
631 fi 609 fi
632 610
633 local socket=${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock 611 local socket=${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock
634 local pidfile=${ROOT}/var/run/mysqld/mysqld${MY_SUFFIX}${RANDOM}.pid 612 local pidfile=${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid
635 local mysqld="${ROOT}/usr/sbin/mysqld${MY_SUFFIX} \ 613 local mysqld="${ROOT}/usr/sbin/mysqld \
636 ${options} \ 614 ${options} \
637 --user=mysql \ 615 --user=mysql \
638 --skip-grant-tables \ 616 --skip-grant-tables \
639 --basedir=${ROOT}/usr \ 617 --basedir=${ROOT}/usr \
640 --datadir=${ROOT}/${DATADIR} \ 618 --datadir=${ROOT}/${DATADIR} \
652 sleep 1 630 sleep 1
653 done 631 done
654 632
655 # do this from memory we don't want clear text password in temp files 633 # do this from memory we don't want clear text password in temp files
656 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'" 634 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'"
657 ${ROOT}/usr/bin/mysql${MY_SUFFIX} \ 635 ${ROOT}/usr/bin/mysql \
658 --socket=${socket} \ 636 --socket=${socket} \
659 -hlocalhost \ 637 -hlocalhost \
660 -e "${sql}" 638 -e "${sql}"
661 639
662 einfo "Loading \"zoneinfo\" this step may require few seconds" 640 einfo "Loading \"zoneinfo\" this step may require few seconds"
663 641
664 ${ROOT}/usr/bin/mysql${MY_SUFFIX} \ 642 ${ROOT}/usr/bin/mysql \
665 --socket=${socket} \ 643 --socket=${socket} \
666 -hlocalhost \ 644 -hlocalhost \
667 -uroot \ 645 -uroot \
668 -p"${pwd1}" \ 646 -p"${pwd1}" \
669 mysql < "${sqltmp}" 647 mysql < "${sqltmp}"
674 einfo "stopping the server," 652 einfo "stopping the server,"
675 wait %1 653 wait %1
676 einfo "done" 654 einfo "done"
677} 655}
678 656
679mysql_pkg_prerm() {
680 if [[ ${SLOT} -gt 0 ]] ; then
681 # external program
682 eselect mysql slot_remove "${SLOT}"
683 fi
684}
685
686mysql_pkg_postrm() { 657mysql_pkg_postrm() {
687 mysql_lib_symlinks 658 mysql_lib_symlinks
688 if [[ ${SLOT} -gt 0 ]] ; then
689 einfo "you may want to run \"eselect mysql list\" followed by a "
690 einfo "\"eselect mysql list\" to choose the default mysql server"
691 fi
692} 659}

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.20