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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (hide annotations) (download)
Mon Apr 23 19:35:05 2007 UTC (11 years, 7 months ago) by swegener
Branch: MAIN
Changes since 1.19: +4 -4 lines
Apply whitespace checks from repoman to eclasses.

1 chtekk 1.18 # Copyright 1999-2007 Gentoo Foundation
2 vivo 1.1 # Distributed under the terms of the GNU General Public License v2
3 swegener 1.20 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.19 2007/04/15 12:18:49 robbat2 Exp $
4 vivo 1.12
5 vivo 1.16 # Author: Francesco Riosa (Retired) <vivo@gentoo.org>
6 chtekk 1.18 # Maintainer: Luca Longinotti <chtekk@gentoo.org>
7 vivo 1.1
8 herbs 1.10 inherit multilib
9    
10 chtekk 1.18 #
11 chtekk 1.13 # Helper function, version (integer) may have sections separated by dots
12 chtekk 1.18 # for readability.
13 chtekk 1.13 #
14 vivo 1.1 stripdots() {
15     local dotver=${1:-"0"}
16 vivo 1.14 local v=""
17     local ret=0
18     if [[ "${dotver/./}" != "${dotver}" ]] ; then
19     # dotted version number
20     for i in 1000000 10000 100 1 ; do
21     v=${dotver%%\.*}
22     # remove leading zeroes
23 chtekk 1.18 while [[ ${#v} -gt 1 ]] && [[ ${v:0:1} == "0" ]] ; do v=${v#0} ; done
24 vivo 1.14 # increment integer version number
25     ret=$(( ${v} * ${i} + ${ret} ))
26     if [[ "${dotver}" == "${dotver/\.}" ]] ; then
27     dotver=0
28     else
29     dotver=${dotver#*\.}
30     fi
31     done
32 chtekk 1.18 echo "${ret}"
33 vivo 1.14 else
34     # already an integer
35     v=${dotver}
36 chtekk 1.18 while [[ ${#v} -gt 1 ]] && [[ ${v:0:1} == "0" ]] ; do v=${v#0} ; done
37     echo "${v}"
38 vivo 1.14 fi
39 vivo 1.1 }
40    
41     #
42 chtekk 1.13 # Check if a version number falls inside a given range.
43     # The range includes the extremes and must be specified as
44 chtekk 1.18 # "low_version to high_version" i.e. "4.1.2 to 5.1.99.99".
45     # Returns true if inside the range.
46 chtekk 1.13 #
47 vivo 1.1 mysql_check_version_range() {
48     local lbound="${1%% to *}" ; lbound=$(stripdots "${lbound}")
49     local rbound="${1#* to }" ; rbound=$(stripdots "${rbound}")
50     local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
51 vivo 1.16 [[ ${lbound} -le ${my_ver} ]] && [[ ${my_ver} -le ${rbound} ]] && return 0
52 vivo 1.1 return 1
53     }
54    
55 chtekk 1.18 #
56     # True if at least one applicable range is found for the patch.
57     #
58 vivo 1.16 _mysql_test_patch_ver_pn() {
59     local allelements=", version, package name"
60 robbat2 1.19 # So that it fails the directory test if none of them exist
61 swegener 1.20 local filesdir="/dev/null"
62 robbat2 1.19 for d in "${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" \
63     "${WORKDIR}/mysql-extras" ; do
64     if [ -d "${d}" ]; then
65     filesdir="${d}"
66     break
67     fi
68     done
69 vivo 1.16
70 chtekk 1.18 [[ -d "${filesdir}" ]] || die "Source dir must be a directory"
71 vivo 1.16 local flags=$1 pname=$2
72     if [[ $(( $flags & $(( 1 + 4 + 16 )) )) -eq 21 ]] ; then
73 chtekk 1.18 einfo "using '${pname}'"
74     mv -f "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "Couldn't move ${pname}"
75 vivo 1.16 return 0
76     fi
77    
78     [[ $(( $flags & $(( 2 + 4 )) )) -gt 0 ]] \
79     && allelements="${allelements//", version"}"
80 swegener 1.20
81 vivo 1.16 [[ $(( $flags & $(( 8 + 16 )) )) -gt 0 ]] \
82     && allelements="${allelements//", package name"}"
83 swegener 1.20
84 vivo 1.16 [[ -n "${allelements}" ]] && [[ "${flags}" -gt 0 ]] \
85 chtekk 1.18 && ewarn "QA notice: ${allelements} missing in ${pname} patch"
86 vivo 1.16
87     return 1
88     }
89    
90 vivo 1.1 #
91 chtekk 1.18 # Parse a "index_file" looking for patches to apply to the
92     # current MySQL version.
93     # If the patch applies, print its description.
94     #
95 vivo 1.16 mysql_mv_patches() {
96 robbat2 1.19 # So that it fails the directory test if none of them exist
97     local filesdir="/dev/null"
98     if [[ -z "${1}" ]]; then
99     for d in "${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" \
100     "${WORKDIR}/mysql-extras" ; do
101     if [ -d "${d}" ]; then
102     filesdir="${d}"
103     break
104     fi
105     done
106     [[ -d "${filesdir}" ]] || die "No patches directory found!"
107     fi
108    
109     local index_file="${1:-"${filesdir}/000_index.txt"}"
110 vivo 1.16 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
111     local my_test_fx=${3:-"_mysql_test_patch_ver_pn"}
112 robbat2 1.19 _mysql_mv_patches "${index_file}" "${my_ver}" "${my_test_fx}"
113     }
114    
115     _mysql_mv_patches() {
116     local index_file="${1}"
117     local my_ver="${2}"
118     local my_test_fx="${3}"
119 vivo 1.16 local dsc ndsc=0 i
120     dsc=( )
121    
122 chtekk 1.18 # Values for flags are (2^x):
123 vivo 1.16 # 1 - one patch found
124 chtekk 1.18 # 2 - at least one version range is wrong
125     # 4 - at least one version range is ok
126     # 8 - at least one ${PN} did not match
127     # 16 - at least one ${PN} has been matched
128     local flags=0 pname=""
129     while read row ; do
130 vivo 1.16 case "${row}" in
131     @patch\ *)
132     [[ -n "${pname}" ]] \
133 chtekk 1.18 && ${my_test_fx} ${flags} "${pname}" \
134 vivo 1.16 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
135     flags=1 ; ndsc=0 ; dsc=( )
136     pname=${row#"@patch "}
137     ;;
138     @ver\ *)
139     if mysql_check_version_range "${row#"@ver "}" "${my_ver}" ; then
140 chtekk 1.18 flags=$(( ${flags} | 4 ))
141 vivo 1.16 else
142 chtekk 1.18 flags=$(( ${flags} | 2 ))
143 vivo 1.16 fi
144     ;;
145     @pn\ *)
146     if [[ ${row#"@pn "} == "${PN}" ]] ; then
147 chtekk 1.18 flags=$(( ${flags} | 16 ))
148 vivo 1.16 else
149 chtekk 1.18 flags=$(( ${flags} | 8 ))
150 vivo 1.16 fi
151     ;;
152     # @use\ *) ;;
153     @@\ *)
154     dsc[$ndsc]="${row#"@@ "}"
155     (( ++ndsc ))
156     ;;
157     esac
158     done < "${index_file}"
159 chtekk 1.18
160     ${my_test_fx} ${flags} "${pname}" \
161     && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
162 vivo 1.1 }
163    
164 chtekk 1.18 #
165 vivo 1.1 # Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1?
166     # (nice) idea from versionator.eclass
167 chtekk 1.13 #
168 vivo 1.1 mysql_version_is_at_least() {
169 chtekk 1.13 local want_s=$(stripdots "$1") have_s=$(stripdots "${2:-${MYSQL_VERSION_ID}}")
170     [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value to check"
171 vivo 1.1 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
172     }
173    
174 chtekk 1.18 #
175     # To be called on the live filesystem, reassigning symlinks of each MySQL
176     # library to the best version available.
177     #
178 vivo 1.1 mysql_lib_symlinks() {
179 vivo 1.17 local d dirlist maxdots soname sonameln reldir
180 chtekk 1.18 reldir="${1}"
181     pushd "${reldir}/usr/$(get_libdir)" &> /dev/null
182 vivo 1.16 # dirlist must contain the less significative directory left
183 chtekk 1.18 dirlist="mysql"
184 vivo 1.1
185 vivo 1.16 # waste some time in removing and recreating symlinks
186     for d in $dirlist ; do
187 chtekk 1.18 for soname in $( find "${d}" -name "*.so*" -and -not -type "l" 2>/dev/null ) ; do
188 vivo 1.16 # maxdot is a limit versus infinite loop
189     maxdots=0
190     sonameln=${soname##*/}
191 chtekk 1.18 # loop in version of the library to link it, similar to how
192     # libtool works
193     while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]] ; do
194 vivo 1.16 rm -f "${sonameln}"
195     ln -s "${soname}" "${sonameln}"
196     (( ++maxdots ))
197     sonameln="${sonameln%.*}"
198     done
199 vivo 1.1 rm -f "${sonameln}"
200     ln -s "${soname}" "${sonameln}"
201     done
202     done
203 vivo 1.16 popd &> /dev/null
204 vivo 1.17 }

  ViewVC Help
Powered by ViewVC 1.1.20