diff options
author | Francesco Riosa <vivo@gentoo.org> | 2006-01-07 14:22:20 +0000 |
---|---|---|
committer | Francesco Riosa <vivo@gentoo.org> | 2006-01-07 14:22:20 +0000 |
commit | b09bc213b07edf42d23397a148a55be956ce40fc (patch) | |
tree | 13d3b413df46b113cdc2d15a2f4bafb7891361c7 /app-admin/eselect-mysql | |
parent | Marked ppc (diff) | |
download | gentoo-2-b09bc213b07edf42d23397a148a55be956ce40fc.tar.gz gentoo-2-b09bc213b07edf42d23397a148a55be956ce40fc.tar.bz2 gentoo-2-b09bc213b07edf42d23397a148a55be956ce40fc.zip |
Initial commit
(Portage version: 2.0.53)
Diffstat (limited to 'app-admin/eselect-mysql')
-rw-r--r-- | app-admin/eselect-mysql/ChangeLog | 9 | ||||
-rw-r--r-- | app-admin/eselect-mysql/Manifest | 5 | ||||
-rw-r--r-- | app-admin/eselect-mysql/eselect-mysql-1.0.0.ebuild | 22 | ||||
-rw-r--r-- | app-admin/eselect-mysql/files/digest-eselect-mysql-1.0.0 | 0 | ||||
-rw-r--r-- | app-admin/eselect-mysql/files/mysql.eselect | 236 | ||||
-rw-r--r-- | app-admin/eselect-mysql/metadata.xml | 10 |
6 files changed, 282 insertions, 0 deletions
diff --git a/app-admin/eselect-mysql/ChangeLog b/app-admin/eselect-mysql/ChangeLog new file mode 100644 index 000000000000..e75f965b4701 --- /dev/null +++ b/app-admin/eselect-mysql/ChangeLog @@ -0,0 +1,9 @@ +# 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.1 2006/01/07 14:22:20 vivo Exp $ + +*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. + diff --git a/app-admin/eselect-mysql/Manifest b/app-admin/eselect-mysql/Manifest new file mode 100644 index 000000000000..81a4e376862d --- /dev/null +++ b/app-admin/eselect-mysql/Manifest @@ -0,0 +1,5 @@ +MD5 cffb0fa2e135a5a3f7e8d3d8708fd80c ChangeLog 290 +MD5 c3a8243e8e803e23b734bd351648f12b eselect-mysql-1.0.0.ebuild 516 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-eselect-mysql-1.0.0 0 +MD5 9a89457da671f55eeea95e8da9096573 files/mysql.eselect 5022 +MD5 fa97fe3e6f213f79ccf7ffbd53838095 metadata.xml 338 diff --git a/app-admin/eselect-mysql/eselect-mysql-1.0.0.ebuild b/app-admin/eselect-mysql/eselect-mysql-1.0.0.ebuild new file mode 100644 index 000000000000..02960e4cabe5 --- /dev/null +++ b/app-admin/eselect-mysql/eselect-mysql-1.0.0.ebuild @@ -0,0 +1,22 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-mysql/eselect-mysql-1.0.0.ebuild,v 1.1 2006/01/07 14:22:20 vivo Exp $ + +DESCRIPTION="Utility to change the default MySQL server being used" +HOMEPAGE="http://www.gentoo.org/" + +SRC_URI="" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~s390 ~sh ~sparc ~x86" +IUSE="" + +RDEPEND=">=app-admin/eselect-1.0_rc1" + +src_install() { + pushd "${FILESDIR}" 1>/dev/null + insinto /usr/share/eselect/modules + doins mysql.eselect + popd 1>/dev/null +} diff --git a/app-admin/eselect-mysql/files/digest-eselect-mysql-1.0.0 b/app-admin/eselect-mysql/files/digest-eselect-mysql-1.0.0 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/app-admin/eselect-mysql/files/digest-eselect-mysql-1.0.0 diff --git a/app-admin/eselect-mysql/files/mysql.eselect b/app-admin/eselect-mysql/files/mysql.eselect new file mode 100644 index 000000000000..b3ded855f095 --- /dev/null +++ b/app-admin/eselect-mysql/files/mysql.eselect @@ -0,0 +1,236 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: mysql.eselect,v 1.1 2006/01/07 14:22:20 vivo Exp $ + +DESCRIPTION="Manage the /usr/lib/*mysql* links" +MAINTAINER="vivo@gentoo.org" +SVN_DATE='$Date: 2006/01/07 14:22:20 $' +VERSION=$(svn_date_to_version "${SVN_DATE}" ) +MYSQL_SYMLINK_CHECKDIR="${ROOT}/usr/sbin" +ERR_NOT_FOUND="(not-found)" +ERR_UNSET="(unset)" + +# return a human oriented version +# +# $1 - version to transform + +function version4human() { + local x=${1} + local y=$(( x % 100 )) + x=$(( x / 100 )) + echo "MySQL-${x}.${y}.x" +} + +# return a integer version +# +# $1 - version to transform + +function version4bash() { + local version="${1}" + version=${version##*MySQL-} + version=${version%%.x*} + version=${version//./"00+"} + version=$(( $version )) + echo "${version}" +} + +# Return the versions currently installed + +find_versions() { + for servers in "${MYSQL_SYMLINK_CHECKDIR}/mysqld-"* ; do + echo "$(version4human "${servers##*-}")" + done +} + +# Create a symlink for a given file +# +# $1 - original file name +# $2 - MySQL version + +add_symlink() { + local fname="${1}" + local ver="${2}" + local lname + + [[ -z "${fname}" ]] || [[ -z "${ver}" ]] && return 1 + + if [[ -f "${fname}" ]] ; then + pushd $( dirname "${fname}" ) 1> /dev/null + lname="$( basename "${fname}" )" + ln -sf "${lname}" "${lname%"-${ver}"}" + popd 1> /dev/null + fi +} + +# Check if a symlink could be created for a specific file +# +# $1 - original file name +# $2 - MySQL version + +check_symlink() { + local fname="${1}" + local ver="${2}" + local ret=0 + + [[ -z "${fname}" ]] || [[ -z "${ver}" ]] && return 1 + + local lname="${fname%"-${ver}"}" + + # check link source + [[ -f ${fname} ]] || ret=$(( ret +1 )) + + # check link target + [[ ! -L "${lname}" ]] && [[ -f "${lname}" ]] && ret=$(( ret +2 )) + [[ -d "${lname}" ]] && ret=$(( ret +4 )) + #[[ -L "${lname}" ]] && return 0 + + return $ret + +} + +# work out which MYSQL version the user has chosen from the list +# +# $1: the list id that the user has chosen + +get_mysqlversion_fromlist() { + + local version=$1 + # don't try to create the array in the declaration + # of versions, doesn't work + local versions + versions=( $(find_versions) ) + local maxver=${#versions[@]} + + if is_number "${version}" \ + && [[ ${version} -gt 0 ]] \ + && [[ ${version} -le ${maxver} ]] + then + version=${versions[(( ${version} - 1 ))]} + echo "${version}" + return + fi + + for (( i = 0 ; i < ${maxver} ; i = i + 1 )) ; do + if [[ "${versions[$i]}" == "(${version})" ]] ; then + echo ${version} + return + fi + done + + echo "${ERR_NOT_FOUND}" +} + +get_current_mysqlversion() { + link=$(readlink ${MYSQL_SYMLINK_CHECKDIR}/mysqld) + version=${link##*-} + + if ! is_number "${version}" || [[ "${version}" == "" ]] ; then + version="(unset)" + echo "${version}" + else + echo $(version4human "${version}") + fi +} + +set_current_mysqlversion() { + + local version="${1}" + is_number "${version}" || die -q "Not usable version" + local CWD=$(pwd) + local lastdir dir lname + + # perform a check on the entire file list + while read fname ; do + dir="${ROOT}/$(dirname "${fname}")" + if [[ "${dir}" != "${lastdir}" ]] ; then + cd "${dir}" + lastdir="${dir}" + fi + check_symlink "$(basename "${fname}")" "${version}" + ret=$? + if [[ $ret -ne 0 ]] ; then + cd "${CWD}" + die -q \ + "File \"${ROOT}/${fname}\" is not suitable for symlink (${ret})" + fi + done < "$ROOT/usr/share/mysql-${version}/.exe-list" + + # it's ok to do the effective work now + while read fname ; do + dir="${ROOT}/$(dirname "${fname}")" + if [[ "${dir}" != "${lastdir}" ]] ; then + cd "${dir}" + lastdir="${dir}" + fi + lname="$(basename "${fname}")" + ln -sf "${lname}" "${lname%"-${version}"}" + done < "$ROOT/usr/share/mysql-${version}/.exe-list" + + 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_mysqlversion) + 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_mysqlversion) + + write_list_start "Available MYSQL versions:" + + if [[ -n ${versions[@]} ]] ; then + local i + for (( i = 0 ; i < ${#versions[@]} ; i = i + 1 )) ; do + linkversion=${versions[${i}]} + + [[ $linkversion == $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() { + + local version versions + versions=( $(find_versions) ) + + if [[ -z ${1} ]] ; then + # no parameter + die -q "You didn't tell me which version of MYSQL to use" + fi + + version=$(get_mysqlversion_fromlist $1) + + if [[ ${version} == "${ERR_NOT_FOUND}" ]] ; then + die -q "I don't recognise that version of MYSQL" + fi + + set_current_mysqlversion "$(version4bash "${version}")" +} + +# vim: set ft=eselect : diff --git a/app-admin/eselect-mysql/metadata.xml b/app-admin/eselect-mysql/metadata.xml new file mode 100644 index 000000000000..da8ca5633ac4 --- /dev/null +++ b/app-admin/eselect-mysql/metadata.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> +<herd>mysql</herd> +<maintainer> + <email>vivo@gentoo.org</email> + <name>Francesco Riosa</name> +</maintainer> +<longdescription>Utility to switch betwen slotted mysql installations.</longdescription> +</pkgmetadata> |