summarylogtreecommitdiffstats
path: root/jre.install
diff options
context:
space:
mode:
Diffstat (limited to 'jre.install')
-rw-r--r--jre.install71
1 files changed, 71 insertions, 0 deletions
diff --git a/jre.install b/jre.install
new file mode 100644
index 00000000000..144c80d240c
--- /dev/null
+++ b/jre.install
@@ -0,0 +1,71 @@
+THIS_JAVA='java-8-jre/jre'
+NAME='JRE'
+
+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"
+}
+
+update_desktop() {
+ update-desktop-database -q
+ update-mime-database /usr/share/mime >/dev/null
+ xdg-icon-resource forceupdate &>/dev/null
+}
+
+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
+
+ update_desktop
+}
+
+post_upgrade() {
+ post_install
+}
+
+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
+ fi
+
+ update_desktop
+}