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

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Fri Mar 17 20:17:53 2006 UTC (13 years, 5 months ago) by vivo
Branch: MAIN
Changes since 1.10: +3 -53 lines
further cleanup, see MySQL changelog

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.10 2006/03/10 12:29:44 herbs 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 # void mysql_lib_symlinks()
116 #
117 # To be called on the live filesystem, reassign symlinks to each mysql
118 # library to the best version available
119 # 2005-12-30 <vivo at gentoo.org>
120 mysql_lib_symlinks() {
121 local d dirlist maxdots soname sonameln other better
122 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null
123 # dirlist must contain the less significative directory left
124 dirlist="mysql"
125
126 # waste some time in removing and recreating symlinks
127 for d in $dirlist ; do
128 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
129 # maxdot is a limit versus infinite loop
130 maxdots=0
131 sonameln=${soname##*/}
132 # loop in version of the library to link it, similar to the
133 # libtool work
134 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]]
135 do
136 rm -f "${sonameln}"
137 ln -s "${soname}" "${sonameln}"
138 (( ++maxdots ))
139 sonameln="${sonameln%.*}"
140 done
141 rm -f "${sonameln}"
142 ln -s "${soname}" "${sonameln}"
143 done
144 done
145 popd &> /dev/null
146 }

  ViewVC Help
Powered by ViewVC 1.1.20