/[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.13 Revision 1.14
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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.13 2006/05/05 19:49:43 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.14 2006/12/29 20:34:02 vivo Exp $
4 4
5# Author: Francesco Riosa <vivo@gentoo.org> 5# Author: Francesco Riosa <vivo@gentoo.org>
6# Maintainer: Francesco Riosa <vivo@gentoo.org> 6# Maintainer: Francesco Riosa <vivo@gentoo.org>
7 7
8ECLASS="mysql_fx"
9INHERITED="$INHERITED $ECLASS"
8inherit multilib 10inherit multilib
9 11
10# Helper function, version (integer) may have sections separated by dots 12# Helper function, version (integer) may have sections separated by dots
11# for readability 13# for readability
12# 14#
13stripdots() { 15stripdots() {
14 local dotver=${1:-"0"} 16 local dotver=${1:-"0"}
15 while [[ "${dotver/./}" != "${dotver}" ]] ; do dotver="${dotver/./}" ; done 17 local v=""
16 echo "${dotver:-"0"}" 18 local ret=0
19 if [[ "${dotver/./}" != "${dotver}" ]] ; then
20 # dotted version number
21 for i in 1000000 10000 100 1 ; do
22 v=${dotver%%\.*}
23 # remove leading zeroes
24 while [[ ${#v} -gt 1 ]] && [[ ${v:0:1} == "0" ]]; do v=${v#0}; done
25 # increment integer version number
26 ret=$(( ${v} * ${i} + ${ret} ))
27 if [[ "${dotver}" == "${dotver/\.}" ]] ; then
28 dotver=0
29 else
30 dotver=${dotver#*\.}
31 fi
32 done
33 echo ${ret}
34 else
35 # already an integer
36 v=${dotver}
37 while [[ ${#v} -gt 1 ]] && [[ ${v:0:1} == "0" ]]; do v=${v#0}; done
38 echo ${v}
39 fi
17} 40}
18 41
19# bool mysql_check_version_range(char * range, int ver=MYSQL_VERSION_ID, int die_on_err=MYSQL_DIE_ON_RANGE_ERROR)
20# 42#
21# Check if a version number falls inside a given range. 43# Check if a version number falls inside a given range.
22# The range includes the extremes and must be specified as 44# The range includes the extremes and must be specified as
23# "low_version to high_version" i.e. "4.00.00.00 to 5.01.99.99" 45# "low_version to high_version" i.e. "4.00.00.00 to 5.01.99.99"
24# Return true if inside the range 46# Return true if inside the range
54 local want_s=$(stripdots "$1") have_s=$(stripdots "${2:-${MYSQL_VERSION_ID}}") 76 local want_s=$(stripdots "$1") have_s=$(stripdots "${2:-${MYSQL_VERSION_ID}}")
55 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value to check" 77 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value to check"
56 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1 78 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
57} 79}
58 80
81# THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
82# crappy sorting file list per version
83mysql_make_file_list() {
84 local base="${1}-"
85 local n=( )
86 echo $( for i in $( ls -d ${1}-[[:digit:]]_[[:digit:]]{,[[:digit:]]}_[[:digit:]]{,[[:digit:]]} 2>/dev/null )
87 do
88 n=${i#${base}}
89 n=( ${n//_/ } )
90 # prepend the file name with its numeric version number to make
91 # it sortable
92 echo "$(( 100000 + ${n[0]} * 10000 + ${n[1]} * 100 + ${n[2]} ))$i"
93 # sort and cut the numeric version we added in the previous line
94 done | sort | cut -c 7- )
95}
96
97# THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
98mysql_choose_better_version() {
99 local better=$(mysql_make_file_list ${1})
100 echo ${better##* }
101}
102
59# void mysql_lib_symlinks() 103# void mysql_lib_symlinks()
60# 104#
61# To be called on the live filesystem, reassigning symlinks of each MySQL 105# To be called on the live filesystem, reassigning symlinks of each MySQL
62# library to the best version available. 106# library to the best version available.
63# 2005-12-30 <vivo@gentoo.org> 107# 2005-12-30 <vivo@gentoo.org>

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20