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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (show annotations) (download)
Fri Jan 12 20:51:28 2007 UTC (12 years, 7 months ago) by chtekk
Branch: MAIN
Changes since 1.17: +49 -95 lines
Revert slotted changes, cleanup.

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

  ViewVC Help
Powered by ViewVC 1.1.20