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

Diff of /eclass/mysql_fx.eclass

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

Revision 1.20 Revision 1.26
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 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_fx.eclass,v 1.20 2007/04/23 19:35:05 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.26 2011/09/30 02:10:24 jmbsvicetto Exp $
4 4
5# Author: Francesco Riosa (Retired) <vivo@gentoo.org> 5# Author: Francesco Riosa (Retired) <vivo@gentoo.org>
6# Maintainer:
7# - MySQL Team <mysql-bugs@gentoo.org>
6# Maintainer: Luca Longinotti <chtekk@gentoo.org> 8# - Luca Longinotti <chtekk@gentoo.org>
7 9
8inherit multilib 10inherit multilib
9 11
10# 12#
11# Helper function, version (integer) may have sections separated by dots 13# Helper function, version (integer) may have sections separated by dots
69 71
70 [[ -d "${filesdir}" ]] || die "Source dir must be a directory" 72 [[ -d "${filesdir}" ]] || die "Source dir must be a directory"
71 local flags=$1 pname=$2 73 local flags=$1 pname=$2
72 if [[ $(( $flags & $(( 1 + 4 + 16 )) )) -eq 21 ]] ; then 74 if [[ $(( $flags & $(( 1 + 4 + 16 )) )) -eq 21 ]] ; then
73 einfo "using '${pname}'" 75 einfo "using '${pname}'"
74 mv -f "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "Couldn't move ${pname}" 76 ln -sf "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "Couldn't move ${pname}"
75 return 0 77 return 0
76 fi 78 fi
77 79
78 [[ $(( $flags & $(( 2 + 4 )) )) -gt 0 ]] \ 80 [[ $(( $flags & $(( 2 + 4 )) )) -gt 0 ]] \
79 && allelements="${allelements//", version"}" 81 && allelements="${allelements//", version"}"
104 fi 106 fi
105 done 107 done
106 [[ -d "${filesdir}" ]] || die "No patches directory found!" 108 [[ -d "${filesdir}" ]] || die "No patches directory found!"
107 fi 109 fi
108 110
109 local index_file="${1:-"${filesdir}/000_index.txt"}" 111 for i in "$1" "${filesdir}/0000_index.txt" "${filesdir}/000_index.txt" ; do
112 if [ -n "$i" -a -f "$i" ]; then
113 local index_file="$i"
114 break
115 fi
116 done
117
110 local my_ver="${2:-"${MYSQL_VERSION_ID}"}" 118 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
111 local my_test_fx=${3:-"_mysql_test_patch_ver_pn"} 119 local my_test_fx=${3:-"_mysql_test_patch_ver_pn"}
112 _mysql_mv_patches "${index_file}" "${my_ver}" "${my_test_fx}" 120 _mysql_mv_patches "${index_file}" "${my_ver}" "${my_test_fx}"
113} 121}
114 122
174# 182#
175# To be called on the live filesystem, reassigning symlinks of each MySQL 183# To be called on the live filesystem, reassigning symlinks of each MySQL
176# library to the best version available. 184# library to the best version available.
177# 185#
178mysql_lib_symlinks() { 186mysql_lib_symlinks() {
187
179 local d dirlist maxdots soname sonameln reldir 188 local d dirlist maxdots libname libnameln libsuffix reldir
189 libsuffix=$(get_libname)
190
191 einfo "libsuffix = ${libsuffix}"
192 einfo "Updating MySQL libraries symlinks"
193
180 reldir="${1}" 194 reldir="${1}"
181 pushd "${reldir}/usr/$(get_libdir)" &> /dev/null 195 pushd "${reldir}/usr/$(get_libdir)" &> /dev/null
196
182 # dirlist must contain the less significative directory left 197 # dirlist must contain the less significative directory left
183 dirlist="mysql" 198 dirlist="mysql"
184 199
185 # waste some time in removing and recreating symlinks 200 # waste some time in removing and recreating symlinks
186 for d in $dirlist ; do 201 for d in $dirlist ; do
187 for soname in $( find "${d}" -name "*.so*" -and -not -type "l" 2>/dev/null ) ; do 202 for libname in $( find "${d}" -mindepth 1 -maxdepth 1 -name "*${libsuffix}*" -and -not -type "l" 2>/dev/null ) ; do
188 # maxdot is a limit versus infinite loop 203 # maxdot is a limit versus infinite loop
189 maxdots=0 204 maxdots=0
190 sonameln=${soname##*/} 205 libnameln=${libname##*/}
191 # loop in version of the library to link it, similar to how 206 # loop in version of the library to link it, similar to how
192 # libtool works 207 # libtool works
193 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]] ; do 208 while [[ ${libnameln:0-3} != '${libsuffix}' ]] && [[ ${maxdots} -lt 6 ]] ; do
194 rm -f "${sonameln}" 209 rm -f "${libnameln}"
195 ln -s "${soname}" "${sonameln}" 210 ln -s "${libname}" "${libnameln}"
196 (( ++maxdots )) 211 (( ++maxdots ))
197 sonameln="${sonameln%.*}" 212 libnameln="${libnameln%.*}"
198 done
199 rm -f "${sonameln}"
200 ln -s "${soname}" "${sonameln}"
201 done 213 done
214 rm -f "${libnameln}"
215 ln -s "${libname}" "${libnameln}"
202 done 216 done
217 done
218
203 popd &> /dev/null 219 popd &> /dev/null
204} 220}
221
222# @FUNCTION: mysql_init_vars
223# @DESCRIPTION:
224# void mysql_init_vars()
225# Initialize global variables
226# 2005-11-19 <vivo@gentoo.org>
227mysql_init_vars() {
228 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"}
229 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"}
230 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"}
231 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"}
232 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"}
233 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"}
234
235 if [[ -z "${MY_DATADIR}" ]] ; then
236 MY_DATADIR=""
237 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
238 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
239 | sed -ne '/datadir/s|^--datadir=||p' \
240 | tail -n1`
241 if [[ -z "${MY_DATADIR}" ]] ; then
242 MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
243 | sed -e 's/.*=\s*//' \
244 | tail -n1`
245 fi
246 fi
247 if [[ -z "${MY_DATADIR}" ]] ; then
248 MY_DATADIR="${MY_LOCALSTATEDIR}"
249 einfo "Using default MY_DATADIR"
250 fi
251 elog "MySQL MY_DATADIR is ${MY_DATADIR}"
252
253 if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
254 if [[ -e "${MY_DATADIR}" ]] ; then
255 # If you get this and you're wondering about it, see bug #207636
256 elog "MySQL datadir found in ${MY_DATADIR}"
257 elog "A new one will not be created."
258 PREVIOUS_DATADIR="yes"
259 else
260 PREVIOUS_DATADIR="no"
261 fi
262 export PREVIOUS_DATADIR
263 fi
264 else
265 if [[ ${EBUILD_PHASE} == "config" ]]; then
266 local new_MY_DATADIR
267 new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
268 | sed -ne '/datadir/s|^--datadir=||p' \
269 | tail -n1`
270
271 if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
272 ewarn "MySQL MY_DATADIR has changed"
273 ewarn "from ${MY_DATADIR}"
274 ewarn "to ${new_MY_DATADIR}"
275 MY_DATADIR="${new_MY_DATADIR}"
276 fi
277 fi
278 fi
279
280 if [ "${MY_SOURCEDIR:-unset}" == "unset" ]; then
281 MY_SOURCEDIR=${SERVER_URI##*/}
282 MY_SOURCEDIR=${MY_SOURCEDIR%.tar*}
283 fi
284
285 export MY_SHAREDSTATEDIR MY_SYSCONFDIR
286 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
287 export MY_INCLUDEDIR MY_DATADIR MY_SOURCEDIR
288}

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

  ViewVC Help
Powered by ViewVC 1.1.20