diff options
Diffstat (limited to 'jdk.install')
-rw-r--r-- | jdk.install | 102 |
1 files changed, 39 insertions, 63 deletions
diff --git a/jdk.install b/jdk.install index 8dc4231f5b4c..e8adb3282b54 100644 --- a/jdk.install +++ b/jdk.install @@ -1,74 +1,50 @@ -VERSION='<version>' -THIS_JAVA="java-${VERSION}-jdk" -NAME='JDK' - -all_off="$(tput sgr0)" -bold="${all_off}$(tput bold)" -blue="${bold}$(tput setaf 4)" -yellow="${bold}$(tput setaf 3)" - -note() { - printf "${blue}::${yellow} archlinux-java:${bold} $1${all_off}\n" -} - -note2() { - printf "${blue}==>${yellow} NOTE:${bold} $1${all_off}\n" +THIS_JDK='java-11-jdk' + +fix_default() { + if [ ! -x /usr/bin/java ]; then + /usr/bin/archlinux-java unset + echo "" + else + /usr/bin/archlinux-java get + fi } post_install() { - default=$(archlinux-java get) - case ${default} in - "") - archlinux-java set ${THIS_JAVA} - note "${NAME} ('${THIS_JAVA}') set as default Java environment." - ;; - ${THIS_JAVA}) - note "${NAME} ('${THIS_JAVA}') set as default Java environment." - ;; - *) - note "Default Java environment already set to '${default}'. - To use ${NAME} ('${THIS_JAVA}'), run: - # archlinux-java set ${THIS_JAVA} - For status, use: - $ archlinux-java status" - ;; - esac - - if [[ ! -f /etc/ssl/certs/java/cacerts ]]; then - update-ca-trust - fi - - note2 "Since Oracle Java 9, some Qt 5 applications (such as the reader apps Zeal and - GoldenDict) will crash due to the existance of the Java NPAPI plugin symlink - (/usr/lib/mozilla/plugins/libnpjp2-jdk${VERSION}.so). - - See: - - https://github.com/zealdocs/zeal/issues/802 - - https://bbs.archlinux.org/viewtopic.php?id=231222" + default=$(fix_default) + case ${default} in + "") + /usr/bin/archlinux-java set ${THIS_JDK} + ;; + ${THIS_JDK}) + # Nothing + ;; + *) + echo "Default Java environment is already set to '${default}'" + echo "See 'archlinux-java help' to change it" + ;; + esac + + if [ ! -f /etc/ssl/certs/java/cacerts ]; then + /usr/bin/update-ca-trust + fi } post_upgrade() { - post_install + default=$(fix_default) + if [ -z "${default}" ]; then + /usr/bin/archlinux-java set ${THIS_JDK} + fi + + if [ ! -f /etc/ssl/certs/java/cacerts ]; then + /usr/bin/update-ca-trust + fi } pre_remove() { - default=$(archlinux-java get) - if [[ ${default} = ${THIS_JAVA} ]]; then - archlinux-java unset - fi -} - -post_remove() { - default=$(archlinux-java get) # reassign - if [[ ${default} ]]; then - note "Default Java environment is '${default}'." - else - archlinux-java fix - default=$(archlinux-java get) # re-reassign - if [[ ${default} ]]; then - note "Default Java environment left as '${default}'." - else - note "Java environment unset." - fi + if [ "x$(fix_default)" = "x${THIS_JDK}" ]; then + # Check JRE11 is still available + if [ -x /usr/lib/jvm/${THIS_JDK}/bin/java ]; then + /usr/bin/archlinux-java unset fi + fi } |