/[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.12 Revision 1.13
1# Copyright 1999-2005 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.12 2006/04/10 21:35:55 vivo Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.13 2006/05/05 19:49:43 chtekk Exp $
4# $ID: $
5 4
6
7# Author: Francesco Riosa <vivo at gentoo.org> 5# Author: Francesco Riosa <vivo@gentoo.org>
8# Maintainer: Francesco Riosa <vivo at gentoo.org> 6# Maintainer: Francesco Riosa <vivo@gentoo.org>
9 7
10inherit multilib 8inherit multilib
11 9
12# helper function, version (integer) may have section separated by dots 10# Helper function, version (integer) may have sections separated by dots
13# for readbility 11# for readability
12#
14stripdots() { 13stripdots() {
15 local dotver=${1:-"0"} 14 local dotver=${1:-"0"}
16 while [[ "${dotver/./}" != "${dotver}" ]] ; do dotver="${dotver/./}" ; done 15 while [[ "${dotver/./}" != "${dotver}" ]] ; do dotver="${dotver/./}" ; done
17 echo "${dotver:-"0"}" 16 echo "${dotver:-"0"}"
18} 17}
19 18
20# bool mysql_check_version_range(char * range, int ver=MYSQL_VERSION_ID, int die_on_err=MYSQL_DIE_ON_RANGE_ERROR) 19# bool mysql_check_version_range(char * range, int ver=MYSQL_VERSION_ID, int die_on_err=MYSQL_DIE_ON_RANGE_ERROR)
21# 20#
22# Check if a version number fall inside a range. 21# Check if a version number falls inside a given range.
23# the range include the extremes and must be specified as 22# The range includes the extremes and must be specified as
24# "low_version to hi_version" i.e. "4.00.00.00 to 5.01.99.99" 23# "low_version to high_version" i.e. "4.00.00.00 to 5.01.99.99"
25# Return true if inside the range 24# Return true if inside the range
26# 2005-11-19 <vivo at gentoo.org> 25# 2005-11-19 <vivo@gentoo.org>
26#
27mysql_check_version_range() { 27mysql_check_version_range() {
28 local lbound="${1%% to *}" ; lbound=$(stripdots "${lbound}") 28 local lbound="${1%% to *}" ; lbound=$(stripdots "${lbound}")
29 local rbound="${1#* to }" ; rbound=$(stripdots "${rbound}") 29 local rbound="${1#* to }" ; rbound=$(stripdots "${rbound}")
30 local my_ver="${2:-"${MYSQL_VERSION_ID}"}" 30 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
31 [[ $lbound -le $my_ver && $my_ver -le $rbound ]] && return 0 31 [[ ${lbound} -le ${my_ver} && ${my_ver} -le ${rbound} ]] && return 0
32 return 1 32 return 1
33}
34
35# private bool _mysql_test_patch_easy( int flags, char * pname )
36#
37# true if found at least one appliable range
38# 2005-11-19 <vivo at gentoo.org>
39_mysql_test_patch_easy() {
40 local filesdir="${WORKDIR}/mysql-extras"
41 [[ -d "${filesdir}" ]] || die 'sourcedir must be a directory'
42 local flags=$1 pname=$2
43 if [[ $(( $flags & 5 )) -eq 5 ]] ; then
44 einfo "using \"${pname}\""
45 mv "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "cannot move ${pname}"
46 return 0
47 fi
48 return 1
49}
50
51# void mysql_mv_patches(char * index_file, char * filesdir, int my_ver)
52#
53# parse a "index_file" looking for patches to apply to current
54# version.
55# If the patch apply then print it's description
56# 2005-11-19 <vivo at gentoo.org>
57mysql_mv_patches() {
58 local index_file="${1:-"${WORKDIR}/mysql-extras/index.txt"}"
59 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
60 local my_test_fx=${3:-"_mysql_test_patch_easy"}
61 local dsc ndsc=0 i
62 dsc=( )
63
64 # values for flags are (2^x):
65 # 1 - one patch found
66 # 2 - at least one version range is wrong
67 # 4 - at least one version range is _good_
68 local flags=0 pname='' comments=''
69 while read row; do
70 case "${row}" in
71 @patch\ *)
72 ${my_test_fx} $flags "${pname}" \
73 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
74 flags=1 ; ndsc=0 ; dsc=( )
75 pname=${row#"@patch "}
76 ;;
77 @ver\ *)
78 if mysql_check_version_range "${row#"@ver "}" "${my_ver}" ; then
79 flags=$(( $flags | 4 ))
80 else
81 flags=$(( $flags | 2 ))
82 fi
83 ;;
84 # @use\ *) ;;
85 @@\ *)
86 dsc[$ndsc]="${row#"@@ "}"
87 (( ++ndsc ))
88 ;;
89 esac
90 done < "${index_file}"
91 ${my_test_fx} $flags "${pname}" \
92 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
93} 33}
94 34
95# * char mysql_strip_double_slash() 35# * char mysql_strip_double_slash()
96# 36#
97# initialize global variables 37# Strip double slashes from passed argument.
98# 2005-11-19 <vivo at gentoo.org> 38# 2005-11-19 <vivo@gentoo.org>
39#
99mysql_strip_double_slash() { 40mysql_strip_double_slash() {
100 local path="${1}" 41 local path="${1}"
101 local newpath="${path/\/\///}" 42 local newpath="${path/\/\///}"
102 while [[ ${path} != ${newpath} ]]; do 43 while [[ "${path}" != "${newpath}" ]] ; do
103 path=${newpath} 44 path="${newpath}"
104 newpath="${path/\/\///}" 45 newpath="${path/\/\///}"
105 done 46 done
106 echo "${newpath}" 47 echo "${newpath}"
107} 48}
108 49
109# Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1? 50# Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1?
110# (nice) idea from versionator.eclass 51# (nice) idea from versionator.eclass
52#
111mysql_version_is_at_least() { 53mysql_version_is_at_least() {
112 local want_s=$(stripdots "$1") have_s=$( stripdots "${2:-${MYSQL_VERSION_ID}}") 54 local want_s=$(stripdots "$1") have_s=$(stripdots "${2:-${MYSQL_VERSION_ID}}")
113 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value" 55 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value to check"
114 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1 56 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
115} 57}
116 58
117# void mysql_lib_symlinks() 59# void mysql_lib_symlinks()
118# 60#
119# To be called on the live filesystem, reassign symlinks to each mysql 61# To be called on the live filesystem, reassigning symlinks of each MySQL
120# library to the best version available 62# library to the best version available.
121# 2005-12-30 <vivo at gentoo.org> 63# 2005-12-30 <vivo@gentoo.org>
64#
122mysql_lib_symlinks() { 65mysql_lib_symlinks() {
123 local d dirlist maxdots soname sonameln other better 66 local d dirlist maxdots soname sonameln other better
124 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null 67 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null
125 # dirlist must contain the less significative directory left
126 dirlist="mysql"
127 68
69 # dirlist must contain the less significative directory left
70 dirlist="mysql"
71
128 # waste some time in removing and recreating symlinks 72 # waste some time in removing and recreating symlinks
129 for d in $dirlist ; do 73 for d in $dirlist ; do
130 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do 74 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
131 # maxdot is a limit versus infinite loop 75 # maxdot is a limit versus infinite loop
132 maxdots=0 76 maxdots=0
133 sonameln=${soname##*/} 77 sonameln=${soname##*/}
134 # loop in version of the library to link it, similar to the 78 # loop in version of the library to link it, similar to how
135 # libtool work 79 # libtool works
136 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]] 80 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]] ; do
137 do
138 rm -f "${sonameln}"
139 ln -s "${soname}" "${sonameln}"
140 (( ++maxdots ))
141 sonameln="${sonameln%.*}"
142 done
143 rm -f "${sonameln}" 81 rm -f "${sonameln}"
144 ln -s "${soname}" "${sonameln}" 82 ln -s "${soname}" "${sonameln}"
83 (( ++maxdots ))
84 sonameln="${sonameln%.*}"
145 done 85 done
86 rm -f "${sonameln}"
87 ln -s "${soname}" "${sonameln}"
146 done 88 done
89 done
90
147 popd &> /dev/null 91 popd &> /dev/null
148} 92}

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

  ViewVC Help
Powered by ViewVC 1.1.20