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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Fri Dec 29 20:34:02 2006 UTC (11 years ago) by vivo
Branch: MAIN
Changes since 1.13: +48 -4 lines
merge of safe changes, mostly new functions

1 chtekk 1.13 # Copyright 1999-2006 Gentoo Foundation
2 vivo 1.1 # Distributed under the terms of the GNU General Public License v2
3 vivo 1.14 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.13 2006/05/05 19:49:43 chtekk Exp $
4 vivo 1.12
5 chtekk 1.13 # Author: Francesco Riosa <vivo@gentoo.org>
6     # Maintainer: Francesco Riosa <vivo@gentoo.org>
7 vivo 1.1
8 vivo 1.14 ECLASS="mysql_fx"
9     INHERITED="$INHERITED $ECLASS"
10 herbs 1.10 inherit multilib
11    
12 chtekk 1.13 # Helper function, version (integer) may have sections separated by dots
13     # for readability
14     #
15 vivo 1.1 stripdots() {
16     local dotver=${1:-"0"}
17 vivo 1.14 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 vivo 1.1 }
41    
42     #
43 chtekk 1.13 # 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 vivo 1.1 # Return true if inside the range
47 chtekk 1.13 # 2005-11-19 <vivo@gentoo.org>
48     #
49 vivo 1.1 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 chtekk 1.13 [[ ${lbound} -le ${my_ver} && ${my_ver} -le ${rbound} ]] && return 0
54 vivo 1.1 return 1
55     }
56    
57 chtekk 1.13 # * char mysql_strip_double_slash()
58 vivo 1.1 #
59 chtekk 1.13 # Strip double slashes from passed argument.
60     # 2005-11-19 <vivo@gentoo.org>
61 vivo 1.1 #
62     mysql_strip_double_slash() {
63     local path="${1}"
64     local newpath="${path/\/\///}"
65 chtekk 1.13 while [[ "${path}" != "${newpath}" ]] ; do
66     path="${newpath}"
67 vivo 1.1 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 chtekk 1.13 #
75 vivo 1.1 mysql_version_is_at_least() {
76 chtekk 1.13 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 vivo 1.1 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
79     }
80    
81 vivo 1.14 # 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 vivo 1.1 # void mysql_lib_symlinks()
104     #
105 chtekk 1.13 # 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 vivo 1.1 mysql_lib_symlinks() {
110 vivo 1.3 local d dirlist maxdots soname sonameln other better
111 herbs 1.10 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null
112 vivo 1.1
113 chtekk 1.13 # 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 vivo 1.1 rm -f "${sonameln}"
126     ln -s "${soname}" "${sonameln}"
127 chtekk 1.13 (( ++maxdots ))
128     sonameln="${sonameln%.*}"
129 vivo 1.1 done
130 chtekk 1.13 rm -f "${sonameln}"
131     ln -s "${soname}" "${sonameln}"
132 vivo 1.1 done
133 chtekk 1.13 done
134    
135 vivo 1.5 popd &> /dev/null
136 vivo 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20