+++ /dev/null
-# ChangeLog for app-admin/eselect-mysql
-# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-mysql/ChangeLog,v 1.12 2007/01/02 11:37:13 vivo Exp $
-
-*eselect-mysql-1.1.8 (02 Jan 2007)
-
- 02 Jan 2007; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect,
- +eselect-mysql-1.1.8.ebuild:
- Updating for new slotted kind; 500 => 5_0_26
-
-*eselect-mysql-1.1.0 (15 Feb 2006)
-
- 15 Feb 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect,
- -eselect-mysql-1.0.0-r5.ebuild, +eselect-mysql-1.1.0.ebuild:
- added "distclean" action to remove stale files from previous installs
-
-*eselect-mysql-1.0.0-r5 (14 Feb 2006)
-
- 14 Feb 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect,
- -eselect-mysql-1.0.0-r4.ebuild, +eselect-mysql-1.0.0-r5.ebuild:
- -r4 was not working at all
-
-*eselect-mysql-1.0.0-r3 (06 Feb 2006)
-
- 06 Feb 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect,
- -eselect-mysql-1.0.0-r2.ebuild, +eselect-mysql-1.0.0-r3.ebuild:
- fix for bug #121754, eselect mysql don't work with USE="minimal"
-
-*eselect-mysql-1.0.0-r2 (05 Feb 2006)
-
- 05 Feb 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect,
- -eselect-mysql-1.0.0-r1.ebuild, +eselect-mysql-1.0.0-r2.ebuild:
- Added function slot_remove to be used inside MySQL eclass/ebuild
-
-*eselect-mysql-1.0.0-r1 (01 Feb 2006)
-
- 01 Feb 2006; Francesco Riosa <vivo@gentoo.org>
- -eselect-mysql-1.0.0.ebuild, +eselect-mysql-1.0.0-r1.ebuild:
- version bump
-
- 01 Feb 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect:
- bad symlinking solved, missed a commit before.
-
- 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
- removed need to check for both plain and .gz files for manpages due to a move
- as a consequence of a mysql eclass change.
-
- 07 Jan 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect:
- Many changes after chatting with kugelfang in irc
-
- 07 Jan 2006; Francesco Riosa <vivo@gentoo.org> files/mysql.eselect,
- eselect-mysql-1.0.0.ebuild:
- Removed unused function, added support for manpages and directoryes
- Reverse order of version shown, "eselect mysql set 1" set the best version now
-
-*eselect-mysql-1.0.0 (07 Jan 2006)
-
- 07 Jan 2006; Francesco Riosa <vivo@gentoo.org> ChangeLog:
- This module will be used to switch between MySQL slotted versions.
-
+++ /dev/null
-# Copyright 1999-2005 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id: mysql.eselect,v 1.13 2007/01/02 11:37:13 vivo Exp $
-
-[[ -d "${ROOT}/lib64" ]] && LIBDIR="lib64" || LIBDIR="lib"
-
-DESCRIPTION="Manage the /usr/${LIBDIR}/*mysql* links"
-MAINTAINER="vivo@gentoo.org"
-SVN_DATE='$Date: 2007/01/02 11:37:13 $'
-VERSION=$(svn_date_to_version "${SVN_DATE}" )
-MYSQL_SYMLINK_CHECKDIR="${ROOT}/usr/bin"
-ERR_NOT_FOUND="(not-found)"
-# "unset" is grepped by the MySQL ebuild so don't touch it
-ERR_UNSET="(unset)"
-
-# return a human oriented version
-#
-# $1 - version to transform
-function version4human() {
- echo "${1//_/.}"
-}
-
-# return a integer version
-#
-# $1 - version to transform
-
-function version4bash() {
- echo "${1//./_}"
-}
-
-# Return the versions currently installed
-find_versions() {
- local versions list
- # TODO: "eselect mysql set 1" will always set the best version
- list=$( mysql_make_file_list ${MYSQL_SYMLINK_CHECKDIR}/perror 2>/dev/null )
- for x in ${list} ; do
- versions=( $( version4human ${x##*-}) ${versions[@]} )
- done
- echo ${versions[@]}
-}
-
-# Check if a symlink could be created for a specific file
-#
-# $1 - original file name
-# $2 - MySQL version
-check_symlink() {
- local filename=${1}
- local version=${2}
- local linkname=${filename/"-${version}"/}
- local ret=0
-
- [[ -z ${filename} ]] || [[ -z ${version} ]] && return 1
-
- # check link source
- [[ -f "${filename}" ]] || [[ -f "${filename}.gz" ]] || [[ -d ${filename} ]] || ret=$(( ${ret} + 1 ))
-
- # check link targe
- # not checking for directory (want to keep "/etc/mysql")
- [[ -a ${linkname} ]] && [[ ! -L ${linkname} ]] && [[ ! -d ${linkname} ]] \
- && ret=$(( ${ret} +2 ))
-
- return ${ret}
-}
-
-# THERE IS A COPY OF THIS ONE IN MYSQL_FX.ECLASS, keep the two synced
-mysql_make_file_list() {
- local base="${1}-"
- local items
- local ret
- echo $( for i in $( ls -d ${1}-[[:digit:]]_[[:digit:]]{,[[:digit:]]}_[[:digit:]]{,[[:digit:]]} 2>/dev/null )
- do
- n=${i#${base}}
- n=( ${n//_/ } )
- echo "$(( ${n[0]} * 10000 + 100 + ${n[1]} * 100 + 100 + ${n[2]} ))$i"
- done | sort | cut -c 6- )
-}
-
-# THERE IS A COPY OF THIS ONE IN ESELECT-MYSQL, keep the two synced
-mysql_choose_better_version() {
- local better=$(mysql_make_file_list ${1})
- 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/${LIBDIR}" &> /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" 2>/dev/null )
- 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/${LIBDIR}/mysql" "/usr/include/mysql" "/usr/bin/mysql_config" ; do
- pushd "${ROOT}${other%/*}" &> /dev/null
- better=$( mysql_choose_better_version "${other##*/}" )
- if ! [[ -d "${other##*/}" ]] ; then
- [[ -L "${other##*/}" ]] && rm -f "${other##*/}"
- ! [[ -f "${other##*/}" ]] && ln -sf "${better}" "${other##*/}"
- else
- [[ -L "${other##*/}" ]] && rm -f "${other##*/}"
- ! [[ -d "${other##*/}" ]] && ln -s "${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
-get_version_fromlist() {
- local version=${1}
- local -a versions=( $(find_versions) )
-
- if is_number ${version} ; then
- if [[ ${version} -gt 0 ]] && [[ ${version} -le ${#versions[@]} ]] ; then
- version=${versions[(( ${version} - 1 ))]}
- echo "${version}"
- return
- fi
- fi
-
- for (( i = 0 ; i < ${#versions[@]} ; i = i + 1 )) ; do
- [[ ${versions[$i]} == ${version} ]] || continue
- echo ${version}
- return
- done
-
- echo "${ERR_NOT_FOUND}"
-}
-
-get_current_version() {
- link=$(readlink ${MYSQL_SYMLINK_CHECKDIR}/perror)
- version=${link##*-}
-
- if ! is_number "${version//_/}" || [[ "${version}" == "" ]] ; then
- version="${ERR_UNSET}"
- echo "${version}"
- else
- echo $(version4human "${version}")
- fi
-}
-
-set_current_version() {
-
- local version=${1}
- is_number "${version//_/}" || die -q "No usable version: ${version}"
- local CWD=$(pwd)
- local lastdir dir linkname
- local list=$(< $ROOT/var/lib/eselect/mysql/mysql-${version}.filelist )
-
- # perform a check on the entire file list
- for filename in $list ; do
- dir="${ROOT}/$(dirname "${filename}")"
- if [[ "${dir}" != "${lastdir}" ]] ; then
- cd "${dir}"
- lastdir="${dir}"
- fi
- check_symlink "$(basename "${filename}")" "${version}"
- ret=$?
- if [[ $ret -ne 0 ]] ; then
- cd "${CWD}"
- die -q \
- "File \"${ROOT}/${filename}\" is not suitable for symlink (${ret})"
- fi
- done
-
- # it's ok to do the effective work now
- for filename in $list ; do
- dir="${ROOT}/$(dirname "${filename}")"
- if [[ "${dir}" != "${lastdir}" ]] ; then
- cd "${dir}"
- lastdir="${dir}"
- fi
- linkname="$(basename "${filename}")"
- if ! [[ -f "${linkname}" ]] && ! [[ -d "${linkname}" ]] \
- && [[ -f "${linkname}.gz" ]]
- then
- linkname="${linkname}.gz"
- fi
- if [[ -a "${linkname}" ]] ; then
- # rm needed for directory
- rm -f "${linkname/"-${version}"/}" &> /dev/null
- ln -sf "${linkname}" "${linkname/"-${version}"/}"
- [[ ! -L "${linkname/"-${version}"/}" ]] \
- && write_warning_msg "FAILED: cd \"${dir}\" && ln -sf \"${linkname}\" \"${linkname/"-${version}"/}\""
- fi
- done
-
- cd "${CWD}"
-}
-
-remove_current_version() {
-
- local version=${1}
- is_number "${version//_/}" || die -q "No usable version: ${version}"
- local CWD=$(pwd)
- local lastdir dir linkname
- local list=$(< $ROOT/var/lib/eselect/mysql/mysql-${version}.filelist )
-
- for filename in $list ; do
- linkname="${ROOT}/${filename/"-${version}"/}"
- [[ -L "${linkname}" ]] && rm -f "${linkname}"
- linkname="${ROOT}/${filename/"-${version}"/}.gz"
- [[ -L "${linkname}" ]] && rm -f "${linkname}"
- done
-
- cd "${CWD}"
-}
-
-### show action ###
-
-describe_show() {
- echo "Show the current default version for MySQL"
-}
-
-do_show() {
- write_list_start "Current default MySQL version:"
- version=$(get_current_version)
- write_kv_list_entry "$version" ""
-}
-
-### list action ###
-
-describe_list() {
- echo "List available MySQL versions to link to"
-}
-
-do_list() {
- versions=( $(find_versions) )
- current=$(get_current_version)
-
- write_list_start "Available MySQL versions:"
-
- if [[ -n "${versions[@]}" ]] ; then
- local i
- for (( i = 0 ; i < ${#versions[@]} ; i = i + 1 )) ; do
- [[ ${versions[${i}]} == ${current} ]] && \
- versions[${i}]="${versions[${i}]} $(highlight '*' )"
- done
- write_numbered_list "${versions[@]}"
- else
- write_kv_list_entry "(none found)" ""
- fi
-}
-
-### set action ###
-
-describe_set() {
- echo "Set MYSQL version used"
-}
-
-do_set() {
- [[ ${#@} -lt 1 ]] &&
- die -q "Wrong count of paramters."
- local version
- version=$(get_version_fromlist ${1})
-
- if [[ ${version} == "${ERR_NOT_FOUND}" ]] ; then
- die -q "I don't recognise that version of MYSQL"
- fi
-
- set_current_version "$(version4bash "${version}")"
- mysql_lib_symlinks
-}
-
-### remove action ###
-
-describe_remove() {
- echo "Remove symlinks of the default server"
-}
-
-do_remove() {
-
- local version=$(readlink "${MYSQL_SYMLINK_CHECKDIR}/perror")
- version=$(version4human "${version##*-}")
-
- if [[ -z "${version}" ]] ; then
- die -q "No symlinks found"
- fi
-
- remove_current_version "$(version4bash "${version}")"
- mysql_lib_symlinks
-}
-
-### slot_remove action ###
-
-describe_slot_remove() {
- echo "Remove symlinks given a MySQL slot (used in the ebuild)"
-}
-
-do_slot_remove() {
-
- [[ ${#@} -lt 1 ]] &&
- die -q "Wrong count of paramters."
- local version=$( version4human ${1} )
- version=$( get_version_fromlist ${version} )
- local cur_version=$( get_current_version )
-
- if [[ ${version} == "${ERR_NOT_FOUND}" ]] ; then
- die -q "I don't recognise that version of MYSQL"
- fi
-
- if [[ -z "${version}" ]] ; then
- die -q "No symlinks found"
- fi
-
- if [[ "${version}" != "${cur_version}" ]] ; then
- die -q "The version specified is not the current one"
- fi
-
- remove_current_version "$( version4bash "${version}" )"
- mysql_lib_symlinks
-}
-
-describe_distclean() {
- echo "Remove ANY non slotted mysql and slotted symlinks, DANGEROUS"
-}
-
-do_distclean() {
- local bckfile="${HOME}/eselect-mysql-distclean-backup.tar.bz2"
- local list=$( cat $ROOT/var/lib/eselect/mysql/mysql-*.filelist \
- | sed -e 's/-[0123456789][0123456789][0123456789]//' \
- | sort | uniq )
- touch "${bckfile}" || die -q "cannot create \"${bckfile}\""
- rm -f "${bckfile}"
- pushd ${ROOT}/ &> /dev/null
- tar -jcpf "${bckfile}" ${list} 2> /dev/null
- for f in ${list} ; do
- [[ "${f:0:3}" == "usr" ]] && rm -rf "${f}"
- done
- popd &> /dev/null
- echo "backup created in \"${bckfile}\""
-}
-
-# vim: set ft=eselect :