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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Fri Mar 10 12:29:44 2006 UTC (13 years, 1 month ago) by herbs
Branch: MAIN
Changes since 1.9: +5 -3 lines
s/lib/$(get_libdir)

1 # Copyright 1999-2005 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.9 2006/03/10 11:41:39 vivo Exp $
4
5 # Author: Francesco Riosa <vivo at gentoo.org>
6 # Maintainer: Francesco Riosa <vivo at gentoo.org>
7
8 inherit multilib
9
10 # helper function, version (integer) may have section separated by dots
11 # for readbility
12 stripdots() {
13 local dotver=${1:-"0"}
14 while [[ "${dotver/./}" != "${dotver}" ]] ; do dotver="${dotver/./}" ; done
15 echo "${dotver:-"0"}"
16 }
17
18 # bool mysql_check_version_range(char * range, int ver=MYSQL_VERSION_ID, int die_on_err=MYSQL_DIE_ON_RANGE_ERROR)
19 #
20 # Check if a version number fall inside a range.
21 # the range include the extremes and must be specified as
22 # "low_version to hi_version" i.e. "4.00.00.00 to 5.01.99.99"
23 # Return true if inside the range
24 # 2005-11-19 <vivo at gentoo.org>
25 mysql_check_version_range() {
26 local lbound="${1%% to *}" ; lbound=$(stripdots "${lbound}")
27 local rbound="${1#* to }" ; rbound=$(stripdots "${rbound}")
28 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
29 [[ $lbound -le $my_ver && $my_ver -le $rbound ]] && return 0
30 return 1
31 }
32
33 # private bool _mysql_test_patch_easy( int flags, char * pname )
34 #
35 # true if found at least one appliable range
36 # 2005-11-19 <vivo at gentoo.org>
37 _mysql_test_patch_easy() {
38 local filesdir="${WORKDIR}/mysql-extras"
39 [[ -d "${filesdir}" ]] || die 'sourcedir must be a directory'
40 local flags=$1 pname=$2
41 if [[ $(( $flags & 5 )) -eq 5 ]] ; then
42 einfo "using \"${pname}\""
43 mv "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "cannot move ${pname}"
44 return 0
45 fi
46 return 1
47 }
48
49 # void mysql_mv_patches(char * index_file, char * filesdir, int my_ver)
50 #
51 # parse a "index_file" looking for patches to apply to current
52 # version.
53 # If the patch apply then print it's description
54 # 2005-11-19 <vivo at gentoo.org>
55 mysql_mv_patches() {
56 local index_file="${1:-"${WORKDIR}/mysql-extras/index.txt"}"
57 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
58 local my_test_fx=${3:-"_mysql_test_patch_easy"}
59 local dsc ndsc=0 i
60 dsc=( )
61
62 # values for flags are (2^x):
63 # 1 - one patch found
64 # 2 - at least one version range is wrong
65 # 4 - at least one version range is _good_
66 local flags=0 pname='' comments=''
67 while read row; do
68 case "${row}" in
69 @patch\ *)
70 ${my_test_fx} $flags "${pname}" \
71 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
72 flags=1 ; ndsc=0 ; dsc=( )
73 pname=${row#"@patch "}
74 ;;
75 @ver\ *)
76 if mysql_check_version_range "${row#"@ver "}" "${my_ver}" ; then
77 flags=$(( $flags | 4 ))
78 else
79 flags=$(( $flags | 2 ))
80 fi
81 ;;
82 # @use\ *) ;;
83 @@\ *)
84 dsc[$ndsc]="${row#"@@ "}"
85 (( ++ndsc ))
86 ;;
87 esac
88 done < "${index_file}"
89 ${my_test_fx} $flags "${pname}" \
90 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
91 }
92
93 # * char mysql_strip_double_slash()
94 #
95 # initialize global variables
96 # 2005-11-19 <vivo at gentoo.org>
97 mysql_strip_double_slash() {
98 local path="${1}"
99 local newpath="${path/\/\///}"
100 while [[ ${path} != ${newpath} ]]; do
101 path=${newpath}
102 newpath="${path/\/\///}"
103 done
104 echo "${newpath}"
105 }
106
107 # Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1?
108 # (nice) idea from versionator.eclass
109 mysql_version_is_at_least() {
110 local want_s=$(stripdots "$1") have_s=$( stripdots "${2:-${MYSQL_VERSION_ID}}")
111 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value"
112 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
113 }
114
115 # another one inherited from versionator.eclass (version_sort)
116 # THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
117 mysql_make_file_list() {
118 local items= left=0
119 items=$( ls -d ${1}-[[:digit:]][[:digit:]][[:digit:]] 2>/dev/null )
120
121 while [[ ${left} -lt ${#items[@]} ]] ; do
122 local lowest_idx=${left}
123 local idx=$(( ${lowest_idx} + 1 ))
124 while [[ ${idx} -lt ${#items[@]} ]] ; do
125 [[ "${items[${lowest_idx}]}" > "${items[${idx}]}" ]] \
126 && lowest_idx=${idx}
127 idx=$(( ${idx} + 1 ))
128 done
129 local tmp=${items[${lowest_idx}]}
130 items[${lowest_idx}]=${items[${left}]}
131 items[${left}]=${tmp}
132 left=$(( ${left} + 1 ))
133 done
134 echo ${items[@]}
135 }
136
137 # THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
138 mysql_choose_better_version() {
139 local items= better="" i
140 items="$( ls -d ${1}-[[:digit:]][[:digit:]][[:digit:]] )"
141 for i in ${items} ; do
142 if [[ "${i}" > "${better}" ]] ; then
143 better="${i}"
144 fi
145 done
146 echo "${better}"
147 }
148
149
150 # void mysql_lib_symlinks()
151 #
152 # To be called on the live filesystem, reassign symlinks to each mysql
153 # library to the best version avaiable
154 # 2005-12-30 <vivo at gentoo.org>
155 # THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
156 mysql_lib_symlinks() {
157 local d dirlist maxdots soname sonameln other better
158 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null
159 # dirlist must contain the less significative directory left
160 dirlist="mysql $( mysql_make_file_list mysql )"
161
162 # waste some time in removing and recreating symlinks
163 for d in $dirlist ; do
164 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
165 # maxdot is a limit versus infinite loop
166 maxdots=0
167 sonameln=${soname##*/}
168 # loop in version of the library to link it, similar to the
169 # libtool work
170 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]]
171 do
172 rm -f "${sonameln}"
173 ln -s "${soname}" "${sonameln}"
174 (( ++maxdots ))
175 sonameln="${sonameln%.*}"
176 done
177 rm -f "${sonameln}"
178 ln -s "${soname}" "${sonameln}"
179 done
180 done
181 popd &> /dev/null
182
183 # "include"s and "mysql_config", needed to compile other sw
184 for other in "/usr/$(get_libdir)/mysql" "/usr/include/mysql" "/usr/bin/mysql_config" ; do
185 pushd "${ROOT}${other%/*}" &> /dev/null
186 better=$( mysql_choose_better_version "${other##*/}" )
187 if ! [[ -d "${other##*/}" ]] ; then
188 [[ -L "${other##*/}" ]] && rm -f "${other##*/}"
189 ! [[ -f "${other##*/}" ]] && ln -sf "${better}" "${other##*/}"
190 else
191 [[ -L "${other##*/}" ]] && rm -f "${other##*/}"
192 ! [[ -d "${other##*/}" ]] && ln -s "${better}" "${other##*/}"
193 fi
194 popd &> /dev/null
195 done
196 }

  ViewVC Help
Powered by ViewVC 1.1.20