/[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.2 Revision 1.3
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_fx.eclass,v 1.2 2006/01/04 20:40:26 vivo Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.3 2006/01/14 19:00:32 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# helper function, version (integer) may have section separated by dots 8# helper function, version (integer) may have section separated by dots
159 local want_s=$(stripdots "$1") have_s=$( stripdots "${2:-${MYSQL_VERSION_ID}}") 159 local want_s=$(stripdots "$1") have_s=$( stripdots "${2:-${MYSQL_VERSION_ID}}")
160 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value" 160 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value"
161 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1 161 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
162} 162}
163 163
164# another one inherited from versionator.eclass (version_sort)
165mysql_make_file_list() {
166 local items= left=0
167 items=( ${1}-[[:digit:]][[:digit:]][[:digit:]] )
168 [[ "${items}" == "${1}-[[:digit:]][[:digit:]][[:digit:]]" ]] && items=( )
169
170 while [[ ${left} -lt ${#items[@]} ]] ; do
171 local lowest_idx=${left}
172 local idx=$(( ${lowest_idx} + 1 ))
173 while [[ ${idx} -lt ${#items[@]} ]] ; do
174 [[ "${items[${lowest_idx}]}" > "${items[${idx}]}" ]] \
175 && lowest_idx=${idx}
176 idx=$(( ${idx} + 1 ))
177 done
178 local tmp=${items[${lowest_idx}]}
179 items[${lowest_idx}]=${items[${left}]}
180 items[${left}]=${tmp}
181 left=$(( ${left} + 1 ))
182 done
183 echo ${items[@]}
184}
185
186mysql_choose_better_version() {
187 local items= better="" i
188 items=${1}-[[:digit:]][[:digit:]][[:digit:]]
189 [[ "${items}" == "${1}-[[:digit:]][[:digit:]][[:digit:]]" ]] && items=""
190 for i in ${items} ; do
191 if [[ "${i}" > "${better}" ]] ; then
192 better="${i}"
193 fi
194 done
195 echo "${better}"
196}
197
198
164# void mysql_lib_symlinks() 199# void mysql_lib_symlinks()
165# 200#
166# To be called on the live filesystem, reassign symlinks to each mysql 201# To be called on the live filesystem, reassign symlinks to each mysql
167# library to the best version avaiable 202# library to the best version avaiable
168# 2005-12-30 <vivo at gentoo.org> 203# 2005-12-30 <vivo at gentoo.org>
169mysql_lib_symlinks() { 204mysql_lib_symlinks() {
170 local d dirlist maxdots soname sonameln 205 local d dirlist maxdots soname sonameln other better
171 pushd "${ROOT}/usr/$(get_libdir)/" 206 pushd "${ROOT}/usr/$(get_libdir)/"
172 # dirlist must contain the less significative directory left 207 # dirlist must contain the less significative directory left
173 dirlist="mysql $(ls -d mysql-[[:digit:]][[:digit:]][[:digit:]] | sort)" 208 dirlist="mysql (mysql_make_file_list mysql)"
174 209
175 # waste some time in removing and recreating symlinks 210 # waste some time in removing and recreating symlinks
176 for d in $dirlist ; do 211 for d in $dirlist ; do
177 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do 212 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
178 # maxdot is a limit versus infinite loop 213 # maxdot is a limit versus infinite loop
179 maxdots=0 214 maxdots=0
180 sonameln=${soname##*/} 215 sonameln=${soname##*/}
181 # loop in version of the library to link it, similar to the 216 # loop in version of the library to link it, similar to the
182 # libtool work 217 # libtool work
183 while [[ ${sonameln:(-3)} != '.so' ]] && [[ ${maxdots} -lt 6 ]] 218 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]]
184 do 219 do
185 rm -f "${sonameln}" 220 rm -f "${sonameln}"
186 ln -s "${soname}" "${sonameln}" 221 ln -s "${soname}" "${sonameln}"
187 (( ++maxdots )) 222 (( ++maxdots ))
188 sonameln="${sonameln%.*}" 223 sonameln="${sonameln%.*}"
190 rm -f "${sonameln}" 225 rm -f "${sonameln}"
191 ln -s "${soname}" "${sonameln}" 226 ln -s "${soname}" "${sonameln}"
192 done 227 done
193 done 228 done
194 popd 229 popd
230
231 # "include"s and "mysql_config", needed to compile other sw
232 for other in "/usr/include/mysql" "/usr/bin/mysql_config" ; do
233 pushd "${ROOT}${other%/*}" &> /dev/null
234 if ! [[ -d "${other##*/}" ]] ; then
235 better=$( mysql_choose_better_version "${other##*/}" )
236 [[ -L "${other##*/}" ]] && rm -f "${other##*/}"
237 ! [[ -f "${other##*/}" ]] && ln -sf "${better}" "${other##*/}"
238 fi
239 popd &> /dev/null
240 done
195} 241}

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.20