# HG changeset patch # User holger # Date 1272462236 -7200 # Node ID e47d333b24b0f46b3f126c8b34960df1020c1e39 # Parent 68c3ea31610e86a318dd058303c7ac5d76b7acb3 update eselect-maven to allow for mvn3 diff -r 68c3ea31610e -r e47d333b24b0 app-admin/eselect-maven/Manifest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app-admin/eselect-maven/Manifest Wed Apr 28 15:43:56 2010 +0200 @@ -0,0 +1,2 @@ +AUX maven-0.2.eselect 3756 RMD160 7103857aedf3f6a64b9caa470059853723113c8d SHA1 298e66372b96dcf266b8b6a351557c5ae11dd864 SHA256 4bb50475a8582ca7aacfc98c6a41731ccf3693e39044a90a9fb4926cf1425e50 +EBUILD eselect-maven-0.2.ebuild 768 RMD160 b273335d9414a25486a0cb21b077902ce0bb870e SHA1 2fb6284dd9736e8fc0fd6161ea3421c059d17453 SHA256 fd229fe63d4756f102b142153f004819239e985b91fa43265913cc63f2253472 diff -r 68c3ea31610e -r e47d333b24b0 app-admin/eselect-maven/eselect-maven-0.2.ebuild --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app-admin/eselect-maven/eselect-maven-0.2.ebuild Wed Apr 28 15:43:56 2010 +0200 @@ -0,0 +1,30 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-maven/eselect-maven-0.2.ebuild,v 1.2 2010/04/26 07:50:50 phajdan.jr Exp $ + +EAPI=3 + +DESCRIPTION="Manages Maven symlinks" +HOMEPAGE="http://www.gentoo.org/" +SRC_URI="" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~ppc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" +IUSE="" + +RDEPEND=">=app-admin/eselect-1.2.8 + ! /dev/null) ; do + if [[ -f "${f}" ]] ; then + echo $(basename "${f}") + fi + done +} + +# get a named or numbered target. +find_target() { + local target=${1} + + if is_number "${target}" && [[ ${target} -ge 1 ]] ; then + targets=( $(find_targets ) ) + [[ -z "${targets}" ]] && die -q "No targets found!" + target=${targets[target-1]} + fi + + if [[ "${target}" = mvn-[0-9]* ]] && [[ -f "${EROOT}/usr/bin/${target}" ]] ; then + echo ${target} + else + die -q "Target \"${1}\" doesn't appear to be valid!" + fi +} + +# try to remove the mvn symlink. +remove_symlink() { + rm "${MVN}" &>/dev/null +} + +# determine the current target. +get_target() { + local canonicalised=$(canonicalise "${MVN}") + echo $(basename "${canonicalised}") +} + +# set the Maven symlink. +set_symlink() { + local target=$(find_target "${1}") + remove_symlink + ln -s "${target}" "${MVN}" || die "Couldn't set ${target} symlink." +} + +### show action ### + +describe_show() { + echo "Show current Maven target" +} + +do_show() { + if [[ ${#} -gt 0 ]]; then + die -q "No parameters allowed." + fi + + if [[ -L "${MVN}" ]] ; then + get_target + return 0 + elif [[ -e "${MVN}" ]] ; then + echo "(not a symlink)" >&2 + return 1 + else + echo "(unset)" >&2 + return 1 + fi +} + +### list action ### + +describe_list() { + echo "List available Maven targets" +} + +do_list() { + if [[ ${#} -gt 0 ]]; then + die -q "Usage error: no parameters allowed." + fi + + local i targets + targets=( $(find_targets) ) + + for (( i = 0; i < ${#targets[@]}; i++ )); do + [[ ${targets[i]} = $(basename "$(canonicalise "${MVN}")") ]] \ + && targets[i]=$(highlight_marker "${targets[i]}") + done + + write_list_start "Available Maven targets:" + write_numbered_list -m "(none found)" "${targets[@]}" +} + +### set action ### + +describe_set() { + echo "Set a new Maven target" +} + +describe_set_options() { + echo "target : Target name or number (from 'list' action)" +} + +describe_set_parameters() { + echo "" +} + +do_set() { + if [[ $# -gt 1 ]]; then + die -q "Too many parameters. Expected only one." + fi + + local target=${1} + + if [[ -z "${target}" ]] ; then + die -q "You didn't give me a target name or number." + elif [[ -L "${MVN}" ]] ; then + if ! remove_symlink ; then + die -q "Can't remove existing Maven provider." + elif ! set_symlink "${1}" ; then + die -q "Can't set new Maven provider." + fi + elif [[ -e "${MVN}" ]] ; then + write_warning_msg "Can't set a new Maven provider. There's a file in the way at ${MVN}. You can try removing it manually, and then re-running this command." + else + set_symlink "${target}" || die -q "Wasn't able to set a new provider." + fi +} + +### update action ### + +describe_update() { + echo "Set the Maven target to the latest if the current target is invalid or if the given target is the latest" +} + +describe_update_options() { + echo "target (optional) : Target name (from 'list' action)" +} + +describe_update_parameters() { + echo "" +} + +do_update() { + if [[ $# -gt 1 ]] ; then + die -q "Too many parameters. Expected only one." + fi + + # For pkg_postrm + if [[ ! $(find_targets) ]]; then + remove_symlink + return + fi + + local canonicalised=$(canonicalise "${MVN}") + + if [[ ! -L "${MVN}" ]] || [[ ! -f "${canonicalised}" ]] ; then + do_set 1 + elif [[ -n "${1}" ]] ; then + # Check whether target name is valid. + find_target "${1}" > /dev/null + + if [[ "${1}" == "$(find_target 1)" ]] ; then + do_set 1 + fi + fi +}