diff options
author | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2014-09-06 02:44:44 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2014-09-06 02:44:44 -0300 |
commit | 35121ef5c75a7087c66fb82abe457add94d527d9 (patch) | |
tree | a517b01407a791de88b6b28c5c47b1213fcf7e24 /libre/java-common/install_java-common.sh | |
parent | 3361139c9128e0e158e47a4f279671b5b1af5e1f (diff) | |
parent | 479aa0a3446a654adcb5e1fe537309efb43a4d59 (diff) | |
download | abslibre-35121ef5c75a7087c66fb82abe457add94d527d9.tar.gz abslibre-35121ef5c75a7087c66fb82abe457add94d527d9.tar.bz2 abslibre-35121ef5c75a7087c66fb82abe457add94d527d9.zip |
Merge branch 'master' of ssh://lukeshu.com:1863/srv/git/mirror/parabola/abslibre
Diffstat (limited to 'libre/java-common/install_java-common.sh')
-rw-r--r-- | libre/java-common/install_java-common.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libre/java-common/install_java-common.sh b/libre/java-common/install_java-common.sh new file mode 100644 index 000000000..5ba935e2b --- /dev/null +++ b/libre/java-common/install_java-common.sh @@ -0,0 +1,47 @@ +JVM_DIR=/usr/lib/jvm +OLD_DEFAULT_NAME=java-default-runtime +OLD_DEFAULT_PATH=${JVM_DIR}/${OLD_DEFAULT_NAME} +DEFAULT_NAME=default +DEFAULT_PATH=${JVM_DIR}/${DEFAULT_NAME} +DEFAULT_NAME_JRE=default-runtime +DEFAULT_PATH_JRE=${JVM_DIR}/${DEFAULT_NAME_JRE} + +# $1: Java environment name to set as default +set_default_link_to() { + new_default=$1 + unlink ${DEFAULT_PATH} 2>/dev/null + ln -sf ${new_default} ${DEFAULT_PATH} + + unlink ${DEFAULT_PATH_JRE} 2>/dev/null + if [[ ${new_default} == */jre ]]; then + ln -sf ${new_default} ${DEFAULT_PATH_JRE} + else + ln -sf ${new_default}/jre ${DEFAULT_PATH_JRE} + fi +} + +pre_install() { + _curr_def=$(readlink ${OLD_DEFAULT_PATH} && true) + if [ -n "${_curr_def}" ]; then + unlink ${OLD_DEFAULT_PATH} > /dev/null 2>&1 + ln -sf ${DEFAULT_NAME} ${OLD_DEFAULT_PATH} + + set_default_link_to ${_curr_def} + fi +} + +pre_upgrade() { + pre_install "$@" +} + +post_install() { + echo 'Installing multiple non-conflicting Java environments is now supported' + echo 'Check the following wiki section for more info:' + echo ' https://wiki.parabolagnulinux.org/index.php/Java' + echo 'Please make sure JAVA_HOME is set to /usr/lib/jvm/default' + echo 'If not, you may have to logout and login again to set it according to /etc/profile.d/jre.sh' +} + +post_upgrade() { + post_install "$@" +} |