diff options
-rw-r--r-- | app-eselect/eselect-luajit/eselect-luajit-1.ebuild | 23 | ||||
-rw-r--r-- | app-eselect/eselect-luajit/files/luajit-1.eselect | 117 | ||||
-rw-r--r-- | app-eselect/eselect-luajit/metadata.xml | 14 |
3 files changed, 154 insertions, 0 deletions
diff --git a/app-eselect/eselect-luajit/eselect-luajit-1.ebuild b/app-eselect/eselect-luajit/eselect-luajit-1.ebuild new file mode 100644 index 0000000..76fa0f9 --- /dev/null +++ b/app-eselect/eselect-luajit/eselect-luajit-1.ebuild @@ -0,0 +1,23 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: This ebuild is from Lua overlay; Bumped by mva; $ + +EAPI="4" + +DESCRIPTION="Manages LuaJIT symlinks" +HOMEPAGE="http://www.gentoo.org/" +SRC_URI="" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~ia64 ~ppc ~ppc64 ~x86 ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~sparc-solaris ~x86-solaris" +IUSE="" + +RDEPEND=">=app-admin/eselect-1.2.3" + +S="${WORKDIR}" + +src_install() { + insinto /usr/share/eselect/modules + newins "${FILESDIR}/luajit-${PV}.eselect" luajit.eselect || die "newins failed" +} diff --git a/app-eselect/eselect-luajit/files/luajit-1.eselect b/app-eselect/eselect-luajit/files/luajit-1.eselect new file mode 100644 index 0000000..722ae02 --- /dev/null +++ b/app-eselect/eselect-luajit/files/luajit-1.eselect @@ -0,0 +1,117 @@ +# -*-eselect-*- vim: ft=eselect +# Copyright 2005-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 or later +# $Id: luajit.eselect mva $ + +DESCRIPTION="Manage the LuaJIT symlink" +MAINTAINER="mva@mva.name" +VERSION="1" + +# sort function for luajit versions, to be used in a pipe +sort_luajit_versions() { + local vsort="sort --version-sort" + ${vsort} </dev/null &>/dev/null || vsort=sort + sed -e 's/^\(luajit-\)\?\([[:digit:].]\+\)[-_]beta/\2 0 &/' \ + -e 't;s/^\(luajit-\)\?\([[:digit:].]\+\)/\2 1 &/' \ + | LC_ALL=C ${vsort} | sed 's/.* //' +} + +# find a list of luajit symlink targets +find_targets() { + local f + for f in $(find "${EROOT}"/usr/bin/ -type f -iname 'luajit-[[:digit:]]*'); do + basename "${f}" + done | sort_luajit_versions +} + +# remove the luajit symlink +remove_symlink() { + rm "${EROOT}/usr/bin/luajit" +} + +# set the luajit symlink +set_symlink() { + local target=$1 + + if is_number "${target}"; then + local targets=( $(find_targets) ) + target=${targets[target-1]} + fi + + if [[ -z ${target} ]]; then + die -q "Target \"$1\" doesn't appear to be valid!" + elif [[ -f ${EROOT}/usr/bin/${target} ]]; then + ln -s "${target}" "${EROOT}/usr/bin/luajit" + [[ -f "${EROOT}/usr/lib32/lib${target}.so" ]] && ln -s "lib${target}.so" "${EROOT}/usr/lib32/libluajit-5.1.so" + [[ -f "${EROOT}/usr/lib32/lib${target}.a" ]] && ln -s "lib${target}.a" "${EROOT}/usr/lib32/libluajit-5.1.a" + [[ -f "${EROOT}/usr/lib/lib${target}.so" ]] && ln -s "lib${target}.so" "${EROOT}/usr/lib/libluajit-5.1.so" + [[ -f "${EROOT}/usr/lib/lib${target}.a" ]] && ln -s "lib${target}.a" "${EROOT}/usr/lib/libluajit-5.1.a" + else + die -q "Target \"$1\" doesn't appear to be valid!" + fi +} + +### show action ### + +describe_show() { + echo "Show the current luajit symlink" +} + +do_show() { + write_list_start "Current luajit symlink:" + if [[ -L ${EROOT}/usr/bin/luajit ]]; then + local SV=$(readlink "${EROOT}/usr/bin/luajit") + write_kv_list_entry "${SV%/}" + else + write_kv_list_entry "(unset)" + fi +} + +### list action ### + +describe_list() { + echo "List available luajit symlink targets" +} + +do_list() { + local i targets=( $(find_targets) ) + + write_list_start "Available luajit symlink targets:" + local SV=$(readlink "${EROOT}/usr/bin/luajit") + for (( i = 0; i < ${#targets[@]}; i++ )); do + [[ ${targets[i]} = \ + $(basename "${SV}") ]] \ + && targets[i]=$(highlight_marker "${targets[i]}") + done + write_numbered_list -m "(none found)" "${targets[@]}" +} + +### set action ### + +describe_set() { + echo "Set a new luajit symlink target" +} + +describe_set_parameters() { + echo "<target>" +} + +describe_set_options() { + echo "target : Target name or number (from 'list' action)" +} + +do_set() { + [[ -z $1 ]] && die -q "You didn't tell me what to set the symlink to" + [[ $# -gt 1 ]] && die -q "Too many parameters" + + if [[ -L ${EROOT}/usr/bin/luajit ]]; then + # existing symlink + remove_symlink || die -q "Couldn't remove existing symlink" + set_symlink "$1" || die -q "Couldn't set a new symlink" + elif [[ -e ${EROOT}/usr/bin/luajit ]]; then + # we have something strange + die -q "${EROOT}/usr/bin/luajit exists but is not a symlink" + else + set_symlink "$1" || die -q "Couldn't set a new symlink" + fi +} diff --git a/app-eselect/eselect-luajit/metadata.xml b/app-eselect/eselect-luajit/metadata.xml new file mode 100644 index 0000000..23da526 --- /dev/null +++ b/app-eselect/eselect-luajit/metadata.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> +<maintainer> + <email>mva@mva.name</email> + <description> + If you have any issues, please contact me, or try to find me in IRC on Freenode, OFTC or RusNet. + </description> + <name>Vadim A. Misbakh-Soloviov</name> +</maintainer> +<longdescription>FIXME</longdescription> +<use> +</use> +</pkgmetadata> |