summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Schmaus <flow@gentoo.org>2022-06-24 21:58:21 +0200
committerFlorian Schmaus <flow@gentoo.org>2022-06-29 08:45:21 +0200
commit9fa13744b8265023142ad7050fa67cce67ce29fa (patch)
treec918cd3ea4f485df840389d9e855fc52528af7a7
parentdev-lang/spidermonkey: add 91.11.0 (diff)
downloadgentoo-9fa13744b8265023142ad7050fa67cce67ce29fa.tar.gz
gentoo-9fa13744b8265023142ad7050fa67cce67ce29fa.tar.bz2
gentoo-9fa13744b8265023142ad7050fa67cce67ce29fa.zip
java-vm-2.eclass: use "eselect java-vm update" if available
Note that IDEPEND="app-eselect/eselect-java" is not absolutely perfect. This is for two reasons. First, IDEPEND is an EAPI 8 feature, while the java-vm-2.eclass currently also supports older EAPIs. However, in those older EAPIs there is no equivalent of IDEPEND. Furthermore, even with EAPIs supporting IDEPEND, while the install-time dependencies specified with IDEPEND are allowed to be called in pkg_preinst and pkg_postinst, the Package Manger Specification (PMS) stats that for the pkg_*rm phases, "ebuilds … must not rely on them being available" [1]. And the java-vm-2.eclass only calls "eselect java-vm update" in pkg_postrm. Therefore, a PMS adhering package manager is able to unmerge IDEPEND packages before any of the pkg_*rm phases are invoked. However, declaring an IDEPEND on eselect-java is the next best thing we can do. Also, a typical package manager will likely not pro-actively remove IDEPEND dependencies, so those are available in the pkg_*rm phases. And since there is no harm in stating the IDEPEND, we declare it. Thanks to Mike Gilbert (floppym) for valuable feedback. 1: PMS 2021-06-13 § 8.1 Dependency Classes - https://projects.gentoo.org/pms/8/pms.html#x1-720008.1 Closes: https://bugs.gentoo.org/853928 Signed-off-by: Florian Schmaus <flow@gentoo.org> Closes: https://github.com/gentoo/gentoo/pull/26069
-rw-r--r--eclass/java-vm-2.eclass30
1 files changed, 28 insertions, 2 deletions
diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass
index 8196b1cdc72a..ad814d7efd1a 100644
--- a/eclass/java-vm-2.eclass
+++ b/eclass/java-vm-2.eclass
@@ -25,6 +25,7 @@ RDEPEND="
"
DEPEND="${RDEPEND}"
BDEPEND="app-arch/unzip"
+IDEPEND="app-eselect/eselect-java"
if [[ ${EAPI} == 6 ]]; then
DEPEND+=" ${BDEPEND}"
@@ -88,14 +89,35 @@ java-vm-2_pkg_postinst() {
xdg_desktop_database_update
}
+# @FUNCTION: has_eselect_java-vm_update
+# @INTERNAL
+# @DESCRIPTION:
+# Checks if an eselect-java version providing "eselect java-vm update"
+# is available.
+# @RETURN: 0 if >=app-eselect/eselect-java-0.5 is installed, 1 otherwise.
+has_eselect_java-vm_update() {
+ local has_version_args="-b"
+ if [[ ${EAPI} == 6 ]]; then
+ has_version_args="--host-root"
+ fi
+
+ has_version "${has_version_args}" ">=app-eselect/eselect-java-0.5"
+}
# @FUNCTION: java-vm-2_pkg_prerm
# @DESCRIPTION:
# default pkg_prerm
#
-# Warn user if removing system-vm.
+# Does nothing if eselect-java-0.5 or newer is available. Otherwise,
+# warn user if removing system-vm.
java-vm-2_pkg_prerm() {
+ if has_eselect_java-vm_update; then
+ # We will potentially switch to a new Java system VM in
+ # pkg_postrm().
+ return
+ fi
+
if [[ $(GENTOO_VM= java-config -f 2>/dev/null) == ${VMHANDLE} && -z ${REPLACED_BY_VERSION} ]]; then
ewarn "It appears you are removing your system-vm! Please run"
ewarn "\"eselect java-vm list\" to list available VMs, then use"
@@ -108,10 +130,14 @@ java-vm-2_pkg_prerm() {
# @DESCRIPTION:
# default pkg_postrm
#
-# Update mime database.
+# Invoke "eselect java-vm update" if eselect-java 0.5, or newer, is
+# available. Also update the mime database.
java-vm-2_pkg_postrm() {
xdg_desktop_database_update
+ if has_eselect_java-vm_update; then
+ eselect java-vm update
+ fi
}