From e34976ee88fe4af11ac893a5d14d433b8fb0ff4d Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Wed, 13 Feb 2013 21:07:40 +0000 Subject: Prefixify run-java-tool svn path=/projects/eselect-java/trunk/; revision=9207 --- Makefile.am | 13 ++++++++-- configure.ac | 2 ++ src/scripts/run-java-tool.bash | 50 --------------------------------------- src/scripts/run-java-tool.bash.in | 50 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 52 deletions(-) delete mode 100644 src/scripts/run-java-tool.bash create mode 100644 src/scripts/run-java-tool.bash.in diff --git a/Makefile.am b/Makefile.am index c65c41c..a257f86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,9 @@ dist_pkglibexec_SCRIPTS= \ src/scripts/run-java-tool.bash +EXTRA_DIST = \ + src/scripts/run-java-tool.bash.in + modulesdir=$(datadir)/eselect/modules/ modules_DATA = \ @@ -9,13 +12,13 @@ modules_DATA = \ src/modules/java-vm.eselect \ src/modules/maven.eselect -EXTRA_DIST = \ +EXTRA_DIST += \ src/modules/ecj.eselect.in \ src/modules/java-nsplugin.eselect.in \ src/modules/java-vm.eselect.in \ src/modules/maven.eselect.in -CLEANFILES = $(modules_DATA) +CLEANFILES = $(dist_pkglibexec_SCRIPTS) $(modules_DATA) MAINTAINERCLEANFILES = \ aclocal.m4 \ @@ -35,6 +38,12 @@ EXTRA_DIST += \ README +create-scripts-dir: + $(MKDIR_P) $(top_builddir)/src/scripts + +$(dist_pkglibexec_SCRIPTS): | create-scripts-dir + $(SED) "s|\@GENTOO_PORTAGE_EPREFIX\@|@EPREFIX@|g" $(top_srcdir)/$@.in >$@ + create-modules-dir: $(MKDIR_P) $(top_builddir)/src/modules diff --git a/configure.ac b/configure.ac index cb1a32c..b38fc94 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,8 @@ AC_PROG_LN_S AC_PROG_MKDIR_P AC_PROG_SED +AC_ARG_VAR([EPREFIX],[Gentoo Prefix offset]) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/src/scripts/run-java-tool.bash b/src/scripts/run-java-tool.bash deleted file mode 100644 index 57106a9..0000000 --- a/src/scripts/run-java-tool.bash +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -user_vm="${HOME}/.gentoo/java-config-2/current-user-vm" -system_vm="/etc/java-config-2/current-system-vm" -# Try GENTOO_VM -if [[ -n ${GENTOO_VM} ]]; then - vmpath="/usr/lib/jvm/${GENTOO_VM}/" -# Then user VM -elif [[ -h ${user_vm} ]]; then - vmpath=$(readlink ${user_vm}) -# And fall back to the system VM -else - vmpath=$(readlink ${system_vm}) -fi -tool=$(basename $0) -bin=${vmpath}/bin/${tool} -jrebin=${vmpath}/jre/bin/${tool} - -vm_handle=$(basename ${vmpath}) -if [[ -x ${bin} ]]; then - exec ${bin} "${@}" -elif [[ -x ${jrebin} ]]; then - exec ${jrebin} "${@}" -else - if [[ ! -d ${vmpath} ]]; then - echo "* Home for VM '${vm_handle}' does not exist: ${vmpath}" >&2 - if [[ -n ${GENTOO_VM} ]]; then - echo "* Invalid value for GENTOO_VM: ${GENTOO_VM}" - elif [[ -h ${user_vm} ]]; then - echo "* Invalid User VM: ${vm_handle}" >&2 - else - echo "* Invalid System VM: ${vm_handle}" >&2 - fi - else - if [[ ${tool} = "run-java-tool.bash" ]]; then - echo "* run-java-tool was invoked directly" >&2 - echo "* run-java-tool should only be used via symlinks to it" >&2 - else - echo "* ${tool} is not available for ${vm_handle} on $(uname -m)" >&2 - echo "* IMPORTANT: some Java tools are not available on some VMs on some architectures" >&2 - if (( ${EUID} != 0 )) && [[ "${DISPLAY}" ]] && type -p notify-send > /dev/null; then - notify-send -i java-icon48 "Gentoo Java Launcher" "${tool} is not available for ${vm_handle} -Gentoo Java User Guide" - fi - fi - fi - exit 1 -fi - - diff --git a/src/scripts/run-java-tool.bash.in b/src/scripts/run-java-tool.bash.in new file mode 100644 index 0000000..d6b41d4 --- /dev/null +++ b/src/scripts/run-java-tool.bash.in @@ -0,0 +1,50 @@ +#!@GENTOO_PORTAGE_EPREFIX@/bin/bash + +user_vm="${HOME}/.gentoo@GENTOO_PORTAGE_EPREFIX@/java-config-2/current-user-vm" +system_vm="@GENTOO_PORTAGE_EPREFIX@/etc/java-config-2/current-system-vm" +# Try GENTOO_VM +if [[ -n ${GENTOO_VM} ]]; then + vmpath="@GENTOO_PORTAGE_EPREFIX@/usr/lib/jvm/${GENTOO_VM}/" +# Then user VM +elif [[ -h ${user_vm} ]]; then + vmpath=$(readlink ${user_vm}) +# And fall back to the system VM +else + vmpath=$(readlink ${system_vm}) +fi +tool=$(basename $0) +bin=${vmpath}/bin/${tool} +jrebin=${vmpath}/jre/bin/${tool} + +vm_handle=$(basename ${vmpath}) +if [[ -x ${bin} ]]; then + exec ${bin} "${@}" +elif [[ -x ${jrebin} ]]; then + exec ${jrebin} "${@}" +else + if [[ ! -d ${vmpath} ]]; then + echo "* Home for VM '${vm_handle}' does not exist: ${vmpath}" >&2 + if [[ -n ${GENTOO_VM} ]]; then + echo "* Invalid value for GENTOO_VM: ${GENTOO_VM}" + elif [[ -h ${user_vm} ]]; then + echo "* Invalid User VM: ${vm_handle}" >&2 + else + echo "* Invalid System VM: ${vm_handle}" >&2 + fi + else + if [[ ${tool} = "run-java-tool.bash" ]]; then + echo "* run-java-tool was invoked directly" >&2 + echo "* run-java-tool should only be used via symlinks to it" >&2 + else + echo "* ${tool} is not available for ${vm_handle} on $(uname -m)" >&2 + echo "* IMPORTANT: some Java tools are not available on some VMs on some architectures" >&2 + if (( ${EUID} != 0 )) && [[ "${DISPLAY}" ]] && type -p notify-send > /dev/null; then + notify-send -i java-icon48 "Gentoo Java Launcher" "${tool} is not available for ${vm_handle} +Gentoo Java User Guide" + fi + fi + fi + exit 1 +fi + + -- cgit v1.2.3-65-gdbad