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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

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 chtekk 1.18 # $Header: $
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 filesdir="${WORKDIR}/mysql-extras"
60     local allelements=", version, package name"
61    
62 chtekk 1.18 [[ -d "${filesdir}" ]] || die "Source dir must be a directory"
63 vivo 1.16 local flags=$1 pname=$2
64     if [[ $(( $flags & $(( 1 + 4 + 16 )) )) -eq 21 ]] ; then
65 chtekk 1.18 einfo "using '${pname}'"
66     mv -f "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "Couldn't move ${pname}"
67 vivo 1.16 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 chtekk 1.18 && ewarn "QA notice: ${allelements} missing in ${pname} patch"
78 vivo 1.16
79     return 1
80     }
81    
82 vivo 1.1 #
83 chtekk 1.18 # 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 vivo 1.16 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 chtekk 1.18 # Values for flags are (2^x):
95 vivo 1.16 # 1 - one patch found
96 chtekk 1.18 # 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 vivo 1.16 case "${row}" in
103     @patch\ *)
104     [[ -n "${pname}" ]] \
105 chtekk 1.18 && ${my_test_fx} ${flags} "${pname}" \
106 vivo 1.16 && 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 chtekk 1.18 flags=$(( ${flags} | 4 ))
113 vivo 1.16 else
114 chtekk 1.18 flags=$(( ${flags} | 2 ))
115 vivo 1.16 fi
116     ;;
117     @pn\ *)
118     if [[ ${row#"@pn "} == "${PN}" ]] ; then
119 chtekk 1.18 flags=$(( ${flags} | 16 ))
120 vivo 1.16 else
121 chtekk 1.18 flags=$(( ${flags} | 8 ))
122 vivo 1.16 fi
123     ;;
124     # @use\ *) ;;
125     @@\ *)
126     dsc[$ndsc]="${row#"@@ "}"
127     (( ++ndsc ))
128     ;;
129     esac
130     done < "${index_file}"
131 chtekk 1.18
132     ${my_test_fx} ${flags} "${pname}" \
133     && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
134 vivo 1.1 }
135    
136 chtekk 1.18 #
137 vivo 1.1 # Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1?
138     # (nice) idea from versionator.eclass
139 chtekk 1.13 #
140 vivo 1.1 mysql_version_is_at_least() {
141 chtekk 1.13 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 vivo 1.1 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
144     }
145    
146 chtekk 1.18 #
147     # To be called on the live filesystem, reassigning symlinks of each MySQL
148     # library to the best version available.
149     #
150 vivo 1.1 mysql_lib_symlinks() {
151 vivo 1.17 local d dirlist maxdots soname sonameln reldir
152 chtekk 1.18 reldir="${1}"
153     pushd "${reldir}/usr/$(get_libdir)" &> /dev/null
154 vivo 1.16 # dirlist must contain the less significative directory left
155 chtekk 1.18 dirlist="mysql"
156 vivo 1.1
157 vivo 1.16 # waste some time in removing and recreating symlinks
158     for d in $dirlist ; do
159 chtekk 1.18 for soname in $( find "${d}" -name "*.so*" -and -not -type "l" 2>/dev/null ) ; do
160 vivo 1.16 # maxdot is a limit versus infinite loop
161     maxdots=0
162     sonameln=${soname##*/}
163 chtekk 1.18 # 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 vivo 1.16 rm -f "${sonameln}"
167     ln -s "${soname}" "${sonameln}"
168     (( ++maxdots ))
169     sonameln="${sonameln%.*}"
170     done
171 vivo 1.1 rm -f "${sonameln}"
172     ln -s "${soname}" "${sonameln}"
173     done
174     done
175 vivo 1.16 popd &> /dev/null
176 vivo 1.17 }

  ViewVC Help
Powered by ViewVC 1.1.20