summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Riosa <vivo@gentoo.org>2006-01-30 17:47:13 +0000
committerFrancesco Riosa <vivo@gentoo.org>2006-01-30 17:47:13 +0000
commita82fd35fdf4b30f2c3e49d7f91999137bc9fc717 (patch)
treef0565a6db433734b20c997cd0c775dd3bf071898 /app-admin/eselect-mysql
parentre-added to ~ppc, bug #120857 (diff)
downloadgentoo-2-a82fd35fdf4b30f2c3e49d7f91999137bc9fc717.tar.gz
gentoo-2-a82fd35fdf4b30f2c3e49d7f91999137bc9fc717.tar.bz2
gentoo-2-a82fd35fdf4b30f2c3e49d7f91999137bc9fc717.zip
duplicate symlinking of libraries and include files from mysql eclasses
(Portage version: 2.1_pre3-r1)
Diffstat (limited to 'app-admin/eselect-mysql')
-rw-r--r--app-admin/eselect-mysql/ChangeLog6
-rw-r--r--app-admin/eselect-mysql/files/mysql.eselect87
2 files changed, 90 insertions, 3 deletions
diff --git a/app-admin/eselect-mysql/ChangeLog b/app-admin/eselect-mysql/ChangeLog
index 582fe022b934..47fae8c0f685 100644
--- a/app-admin/eselect-mysql/ChangeLog
+++ b/app-admin/eselect-mysql/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for app-admin/eselect-mysql
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-mysql/ChangeLog,v 1.4 2006/01/08 23:41:42 vivo Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-mysql/ChangeLog,v 1.5 2006/01/30 17:47:13 vivo Exp $
+
+ 30 Jan 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect:
+ Additional security, duplicated the code from mysql eclasses to symlink
+ required include files and libraries (always to the best version)
08 Jan 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect:
Added "remove" action to remove simlinks
diff --git a/app-admin/eselect-mysql/files/mysql.eselect b/app-admin/eselect-mysql/files/mysql.eselect
index 4ba4a8d4e5ba..80648179aa91 100644
--- a/app-admin/eselect-mysql/files/mysql.eselect
+++ b/app-admin/eselect-mysql/files/mysql.eselect
@@ -1,10 +1,10 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Id: mysql.eselect,v 1.4 2006/01/08 23:41:42 vivo Exp $
+# $Id: mysql.eselect,v 1.5 2006/01/30 17:47:13 vivo Exp $
DESCRIPTION="Manage the /usr/lib/*mysql* links"
MAINTAINER="vivo@gentoo.org"
-SVN_DATE='$Date: 2006/01/08 23:41:42 $'
+SVN_DATE='$Date: 2006/01/30 17:47:13 $'
VERSION=$(svn_date_to_version "${SVN_DATE}" )
MYSQL_SYMLINK_CHECKDIR="${ROOT}/usr/sbin"
ERR_NOT_FOUND="(not-found)"
@@ -67,6 +67,87 @@ check_symlink() {
return ${ret}
}
+# another one inherited from versionator.eclass (version_sort)
+# THERE IS A COPY OF THIS ONE IN MYSQL_FX.ECLASS, keep the two synced
+mysql_make_file_list() {
+ local items= left=0
+ items=( ${1}-[[:digit:]][[:digit:]][[:digit:]] )
+ [[ "${items}" == "${1}-[[:digit:]][[:digit:]][[:digit:]]" ]] && items=( )
+
+ while [[ ${left} -lt ${#items[@]} ]] ; do
+ local lowest_idx=${left}
+ local idx=$(( ${lowest_idx} + 1 ))
+ while [[ ${idx} -lt ${#items[@]} ]] ; do
+ [[ "${items[${lowest_idx}]}" > "${items[${idx}]}" ]] \
+ && lowest_idx=${idx}
+ idx=$(( ${idx} + 1 ))
+ done
+ local tmp=${items[${lowest_idx}]}
+ items[${lowest_idx}]=${items[${left}]}
+ items[${left}]=${tmp}
+ left=$(( ${left} + 1 ))
+ done
+ echo ${items[@]}
+}
+
+# THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
+mysql_choose_better_version() {
+ local items= better="" i
+ items="$( ls ${1}-[[:digit:]][[:digit:]][[:digit:]] )"
+ for i in ${items} ; do
+ if [[ "${i}" > "${better}" ]] ; then
+ better="${i}"
+ fi
+ done
+ echo "${better}"
+}
+
+# void mysql_lib_symlinks()
+#
+# To be called on the live filesystem, reassign symlinks to each mysql
+# library to the best version avaiable
+# 2005-12-30 <vivo at gentoo.org>
+# THERE IS A COPY OF THIS ONE IN MYSQL_FX.ECLASS, keep the two synced
+mysql_lib_symlinks() {
+ local d dirlist maxdots soname sonameln other better
+ pushd "${ROOT}/usr/lib/" &> /dev/null
+ # dirlist must contain the less significative directory left
+ dirlist="mysql $( mysql_make_file_list mysql )"
+
+ # waste some time in removing and recreating symlinks
+ for d in $dirlist ; do
+ for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
+ # maxdot is a limit versus infinite loop
+ maxdots=0
+ sonameln=${soname##*/}
+ # loop in version of the library to link it, similar to the
+ # libtool work
+ while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]]
+ do
+ rm -f "${sonameln}"
+ ln -s "${soname}" "${sonameln}"
+ (( ++maxdots ))
+ sonameln="${sonameln%.*}"
+ done
+ rm -f "${sonameln}"
+ ln -s "${soname}" "${sonameln}"
+ done
+ done
+ popd &> /dev/null
+
+ # "include"s and "mysql_config", needed to compile other sw
+ for other in "/usr/include/mysql" "/usr/bin/mysql_config" ; do
+ pushd "${ROOT}${other%/*}" &> /dev/null
+ if ! [[ -d "${other##*/}" ]] ; then
+ better=$( mysql_choose_better_version "${other##*/}" )
+ [[ -L "${other##*/}" ]] && rm -f "${other##*/}"
+ ! [[ -f "${other##*/}" ]] && ln -sf "${better}" "${other##*/}"
+ fi
+ popd &> /dev/null
+ done
+}
+
+
# work out which MYSQL version the user has chosen from the list
#
# $1: the list id that the user has chosen
@@ -216,6 +297,7 @@ do_set() {
fi
set_current_version "$(version4bash "${version}")"
+ mysql_lib_symlinks
}
### remove action ###
@@ -234,6 +316,7 @@ do_remove() {
fi
remove_current_version "$(version4bash "${version}")"
+ mysql_lib_symlinks
}
# vim: set ft=eselect :