--- app-admin/eselect-maven/files/maven-0.2.eselect 2010-02-28 20:31:04.000000000 +0100 +++ app-admin/eselect-maven/files/maven-0.3.eselect 2013-01-05 17:26:26.511902394 +0100 @@ -8,6 +8,7 @@ VERSION="0.2" MVN="${EROOT}/usr/bin/mvn" +MVNDEBUG="${EROOT}/usr/bin/mvnDebug" # find a list of mvn symlink targets, best first. find_targets() { @@ -35,11 +36,32 @@ fi } +# get a named or numbered target for the debug script. +find_debug_target() { + local target=$(find_target ${1} | sed -r 's/(mvn)(-.*)/\1Debug\2/') + + if [[ -n "${target}" ]] && [[ -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 } +# try to remove the mvnDebug symlink. +remove_debug_symlink() { + rm "${MVNDEBUG}" &>/dev/null +} + +# try to remove the mvn symlink. +remove_symlinks() { + remove_symlink && remove_debug_symlink +} + # determine the current target. get_target() { local canonicalised=$(canonicalise "${MVN}") @@ -53,6 +75,13 @@ ln -s "${target}" "${MVN}" || die "Couldn't set ${target} symlink." } +# set the Maven debug (mvnDebug) symlink. +set_debug_symlink() { + local target=$(find_debug_target "${1}") + remove_debug_symlink + ln -s "${target}" "${MVNDEBUG}" || die "Couldn't set ${target} symlink." +} + ### show action ### describe_show() { @@ -122,16 +151,12 @@ 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 + elif [[ -e "${MVN}" && ! -L "${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." + elif [[ -e "${MVNDEBUG}" && ! -L "${MVNDEBUG}" ]] ; then + write_warning_msg "Can't set a new Maven provider. There's a file in the way at ${MVNDEBUG}. You can try removing it manually, and then re-running this command." + elif ! set_symlink "${target}" || ! set_debug_symlink "${target}" ; then + die -q "Wasn't able to set a new provider." fi } @@ -156,7 +181,7 @@ # For pkg_postrm if [[ ! $(find_targets) ]]; then - remove_symlink + remove_symlinks return fi