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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download)
Mon Jan 1 22:27:01 2007 UTC (12 years, 6 months ago) by swegener
Branch: MAIN
Changes since 1.14: +11 -11 lines
Apply whitespace checks from repoman to eclasses.

1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.14 2006/12/29 20:34:02 vivo Exp $
4
5 # Author: Francesco Riosa <vivo@gentoo.org>
6 # Maintainer: Francesco Riosa <vivo@gentoo.org>
7
8 ECLASS="mysql_fx"
9 INHERITED="$INHERITED $ECLASS"
10 inherit multilib
11
12 # Helper function, version (integer) may have sections separated by dots
13 # for readability
14 #
15 stripdots() {
16 local dotver=${1:-"0"}
17 local v=""
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
40 }
41
42 #
43 # Check if a version number falls inside a given range.
44 # The range includes the extremes and must be specified as
45 # "low_version to high_version" i.e. "4.00.00.00 to 5.01.99.99"
46 # Return true if inside the range
47 # 2005-11-19 <vivo@gentoo.org>
48 #
49 mysql_check_version_range() {
50 local lbound="${1%% to *}" ; lbound=$(stripdots "${lbound}")
51 local rbound="${1#* to }" ; rbound=$(stripdots "${rbound}")
52 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
53 [[ ${lbound} -le ${my_ver} && ${my_ver} -le ${rbound} ]] && return 0
54 return 1
55 }
56
57 # * char mysql_strip_double_slash()
58 #
59 # Strip double slashes from passed argument.
60 # 2005-11-19 <vivo@gentoo.org>
61 #
62 mysql_strip_double_slash() {
63 local path="${1}"
64 local newpath="${path/\/\///}"
65 while [[ "${path}" != "${newpath}" ]] ; do
66 path="${newpath}"
67 newpath="${path/\/\///}"
68 done
69 echo "${newpath}"
70 }
71
72 # Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1?
73 # (nice) idea from versionator.eclass
74 #
75 mysql_version_is_at_least() {
76 local want_s=$(stripdots "$1") have_s=$(stripdots "${2:-${MYSQL_VERSION_ID}}")
77 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value to check"
78 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
79 }
80
81 # THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
82 # crappy sorting file list per version
83 mysql_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
98 mysql_choose_better_version() {
99 local better=$(mysql_make_file_list ${1})
100 echo ${better##* }
101 }
102
103 # void mysql_lib_symlinks()
104 #
105 # To be called on the live filesystem, reassigning symlinks of each MySQL
106 # library to the best version available.
107 # 2005-12-30 <vivo@gentoo.org>
108 #
109 mysql_lib_symlinks() {
110 local d dirlist maxdots soname sonameln other better
111 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null
112
113 # dirlist must contain the less significative directory left
114 dirlist="mysql"
115
116 # waste some time in removing and recreating symlinks
117 for d in $dirlist ; do
118 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
119 # maxdot is a limit versus infinite loop
120 maxdots=0
121 sonameln=${soname##*/}
122 # loop in version of the library to link it, similar to how
123 # libtool works
124 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]] ; do
125 rm -f "${sonameln}"
126 ln -s "${soname}" "${sonameln}"
127 (( ++maxdots ))
128 sonameln="${sonameln%.*}"
129 done
130 rm -f "${sonameln}"
131 ln -s "${soname}" "${sonameln}"
132 done
133 done
134
135 popd &> /dev/null
136 }

  ViewVC Help
Powered by ViewVC 1.1.20