1 |
commit: 9fa13744b8265023142ad7050fa67cce67ce29fa |
2 |
Author: Florian Schmaus <flow <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jun 24 19:58:21 2022 +0000 |
4 |
Commit: Florian Schmaus <flow <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 29 06:45:21 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9fa13744 |
7 |
|
8 |
java-vm-2.eclass: use "eselect java-vm update" if available |
9 |
|
10 |
Note that IDEPEND="app-eselect/eselect-java" is not absolutely |
11 |
perfect. This is for two reasons. First, IDEPEND is an EAPI 8 feature, |
12 |
while the java-vm-2.eclass currently also supports older EAPIs. However, |
13 |
in those older EAPIs there is no equivalent of IDEPEND. Furthermore, |
14 |
even with EAPIs supporting IDEPEND, while the install-time dependencies |
15 |
specified with IDEPEND are allowed to be called in pkg_preinst and |
16 |
pkg_postinst, the Package Manger Specification (PMS) stats that for the |
17 |
pkg_*rm phases, "ebuilds … must not rely on them being available" [1]. |
18 |
And the java-vm-2.eclass only calls "eselect java-vm update" in |
19 |
pkg_postrm. Therefore, a PMS adhering package manager is able to unmerge |
20 |
IDEPEND packages before any of the pkg_*rm phases are invoked. |
21 |
|
22 |
However, declaring an IDEPEND on eselect-java is the next best thing we |
23 |
can do. Also, a typical package manager will likely not pro-actively |
24 |
remove IDEPEND dependencies, so those are available in the pkg_*rm |
25 |
phases. And since there is no harm in stating the IDEPEND, we declare |
26 |
it. |
27 |
|
28 |
Thanks to Mike Gilbert (floppym) for valuable feedback. |
29 |
|
30 |
1: PMS 2021-06-13 § 8.1 Dependency Classes - https://projects.gentoo.org/pms/8/pms.html#x1-720008.1 |
31 |
|
32 |
Closes: https://bugs.gentoo.org/853928 |
33 |
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org> |
34 |
Closes: https://github.com/gentoo/gentoo/pull/26069 |
35 |
|
36 |
eclass/java-vm-2.eclass | 30 ++++++++++++++++++++++++++++-- |
37 |
1 file changed, 28 insertions(+), 2 deletions(-) |
38 |
|
39 |
diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass |
40 |
index 8196b1cdc72a..ad814d7efd1a 100644 |
41 |
--- a/eclass/java-vm-2.eclass |
42 |
+++ b/eclass/java-vm-2.eclass |
43 |
@@ -25,6 +25,7 @@ RDEPEND=" |
44 |
" |
45 |
DEPEND="${RDEPEND}" |
46 |
BDEPEND="app-arch/unzip" |
47 |
+IDEPEND="app-eselect/eselect-java" |
48 |
|
49 |
if [[ ${EAPI} == 6 ]]; then |
50 |
DEPEND+=" ${BDEPEND}" |
51 |
@@ -88,14 +89,35 @@ java-vm-2_pkg_postinst() { |
52 |
xdg_desktop_database_update |
53 |
} |
54 |
|
55 |
+# @FUNCTION: has_eselect_java-vm_update |
56 |
+# @INTERNAL |
57 |
+# @DESCRIPTION: |
58 |
+# Checks if an eselect-java version providing "eselect java-vm update" |
59 |
+# is available. |
60 |
+# @RETURN: 0 if >=app-eselect/eselect-java-0.5 is installed, 1 otherwise. |
61 |
+has_eselect_java-vm_update() { |
62 |
+ local has_version_args="-b" |
63 |
+ if [[ ${EAPI} == 6 ]]; then |
64 |
+ has_version_args="--host-root" |
65 |
+ fi |
66 |
+ |
67 |
+ has_version "${has_version_args}" ">=app-eselect/eselect-java-0.5" |
68 |
+} |
69 |
|
70 |
# @FUNCTION: java-vm-2_pkg_prerm |
71 |
# @DESCRIPTION: |
72 |
# default pkg_prerm |
73 |
# |
74 |
-# Warn user if removing system-vm. |
75 |
+# Does nothing if eselect-java-0.5 or newer is available. Otherwise, |
76 |
+# warn user if removing system-vm. |
77 |
|
78 |
java-vm-2_pkg_prerm() { |
79 |
+ if has_eselect_java-vm_update; then |
80 |
+ # We will potentially switch to a new Java system VM in |
81 |
+ # pkg_postrm(). |
82 |
+ return |
83 |
+ fi |
84 |
+ |
85 |
if [[ $(GENTOO_VM= java-config -f 2>/dev/null) == ${VMHANDLE} && -z ${REPLACED_BY_VERSION} ]]; then |
86 |
ewarn "It appears you are removing your system-vm! Please run" |
87 |
ewarn "\"eselect java-vm list\" to list available VMs, then use" |
88 |
@@ -108,10 +130,14 @@ java-vm-2_pkg_prerm() { |
89 |
# @DESCRIPTION: |
90 |
# default pkg_postrm |
91 |
# |
92 |
-# Update mime database. |
93 |
+# Invoke "eselect java-vm update" if eselect-java 0.5, or newer, is |
94 |
+# available. Also update the mime database. |
95 |
|
96 |
java-vm-2_pkg_postrm() { |
97 |
xdg_desktop_database_update |
98 |
+ if has_eselect_java-vm_update; then |
99 |
+ eselect java-vm update |
100 |
+ fi |
101 |
} |