1 |
Thanks to Mike Gilbert (floppym) for valuable feedback. |
2 |
|
3 |
Closes: https://bugs.gentoo.org/853928 |
4 |
Closes: https://github.com/gentoo/gentoo/pull/26069 |
5 |
Signed-off-by: Florian Schmaus <flow@g.o> |
6 |
--- |
7 |
eclass/java-vm-2.eclass | 30 ++++++++++++++++++++++++++++-- |
8 |
1 file changed, 28 insertions(+), 2 deletions(-) |
9 |
|
10 |
diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass |
11 |
index 8196b1cdc72a..dc0d87f4caf5 100644 |
12 |
--- a/eclass/java-vm-2.eclass |
13 |
+++ b/eclass/java-vm-2.eclass |
14 |
@@ -25,6 +25,7 @@ RDEPEND=" |
15 |
" |
16 |
DEPEND="${RDEPEND}" |
17 |
BDEPEND="app-arch/unzip" |
18 |
+IDEPEND="app-eselect/eselect-java" |
19 |
|
20 |
if [[ ${EAPI} == 6 ]]; then |
21 |
DEPEND+=" ${BDEPEND}" |
22 |
@@ -88,14 +89,35 @@ java-vm-2_pkg_postinst() { |
23 |
xdg_desktop_database_update |
24 |
} |
25 |
|
26 |
+# @FUNCTION: has_eselect_java-vm_update |
27 |
+# @INTERNAL |
28 |
+# @DESCRIPTION: |
29 |
+# Checks if an eselect-java version providing "eselect java-vm update" |
30 |
+# is available. |
31 |
+# @RETURN: 0 if >=app-eselect/eselect-java-0.5 is installed, 1 otherwise. |
32 |
+has_eselect_java-vm_update() { |
33 |
+ local has_version_args="-b" |
34 |
+ if [[ ${EAPI} == 6 ]]; then |
35 |
+ has_version_args="--host-root" |
36 |
+ fi |
37 |
+ |
38 |
+ has_version "${has_version_args}" ">=app-eselect/eselect-java-0.5" |
39 |
+} |
40 |
|
41 |
# @FUNCTION: java-vm-2_pkg_prerm |
42 |
# @DESCRIPTION: |
43 |
# default pkg_prerm |
44 |
# |
45 |
-# Warn user if removing system-vm. |
46 |
+# Does nothing if eselect-java-0.5 or newer is available. Otherwhise, |
47 |
+# warn user if removing system-vm. |
48 |
|
49 |
java-vm-2_pkg_prerm() { |
50 |
+ if has_eselect_java-vm_update; then |
51 |
+ # We will potentially switch to a new Java system VM in |
52 |
+ # pkg_postrm(). |
53 |
+ return |
54 |
+ fi |
55 |
+ |
56 |
if [[ $(GENTOO_VM= java-config -f 2>/dev/null) == ${VMHANDLE} && -z ${REPLACED_BY_VERSION} ]]; then |
57 |
ewarn "It appears you are removing your system-vm! Please run" |
58 |
ewarn "\"eselect java-vm list\" to list available VMs, then use" |
59 |
@@ -108,10 +130,14 @@ java-vm-2_pkg_prerm() { |
60 |
# @DESCRIPTION: |
61 |
# default pkg_postrm |
62 |
# |
63 |
-# Update mime database. |
64 |
+# Invoke "eselect java-vm update" if eselect-java 0.5, or newer, is |
65 |
+# available. Also update the mime database. |
66 |
|
67 |
java-vm-2_pkg_postrm() { |
68 |
xdg_desktop_database_update |
69 |
+ if has_eselect_java-vm_update; then |
70 |
+ eselect --root="${EROOT}" java-vm update |
71 |
+ fi |
72 |
} |
73 |
|
74 |
|
75 |
-- |
76 |
2.35.1 |