When a java VM slot is depcleaned, it may leave the system in a state where the selected system VM is invalid. This can cause build errors like bug 853907. To avoid this, I think pkg_postrm in java-vm-2.eclass should make some effort to select a valid system VM to replace the one being removed.
It looks like java-vm_pkg_prerm emits a warning message when the system VM is being removed: java-vm-2_pkg_prerm() { 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" ewarn "\"eselect java-vm set system\" to set a new system-vm!" fi }
I have added support for "eselect java-vm update" to app-eselect/eselect-java in a development branch. The code can be currently found in the java-vm-update branch (https://gitweb.gentoo.org/proj/eselect-java.git/log/?h=java-vm-update). If this works as intended, then we could simply call "eselect java-vm update" in java-vm-2.eclass's pkg_postrm hook and eventually drop the current pkg_prerm hook. Feedback and reviews are appreciated. :)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/eselect-java.git/commit/?id=561e6cb5b3fefb6c248056aa4d790276433856b3 commit 561e6cb5b3fefb6c248056aa4d790276433856b3 Author: Florian Schmaus <flow@gentoo.org> AuthorDate: 2022-06-24 07:02:14 +0000 Commit: Florian Schmaus <flow@gentoo.org> CommitDate: 2022-06-24 08:16:33 +0000 Add "eselect java-vm update" Bug: https://bugs.gentoo.org/853928 Signed-off-by: Florian Schmaus <flow@gentoo.org> NEWS | 3 +++ src/modules/java-vm.eselect.in | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b81c6cda810dcb3e322a554b9cde88cd27c47248 commit b81c6cda810dcb3e322a554b9cde88cd27c47248 Author: Florian Schmaus <flow@gentoo.org> AuthorDate: 2022-06-24 10:34:16 +0000 Commit: Florian Schmaus <flow@gentoo.org> CommitDate: 2022-06-24 10:39:19 +0000 app-eselect/eselect-java: add 0.5.0 Bug: https://bugs.gentoo.org/853928 Signed-off-by: Florian Schmaus <flow@gentoo.org> app-eselect/eselect-java/Manifest | 1 + app-eselect/eselect-java/eselect-java-0.5.0.ebuild | 35 ++++++++++++++++++++++ 2 files changed, 36 insertions(+)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9fa13744b8265023142ad7050fa67cce67ce29fa commit 9fa13744b8265023142ad7050fa67cce67ce29fa Author: Florian Schmaus <flow@gentoo.org> AuthorDate: 2022-06-24 19:58:21 +0000 Commit: Florian Schmaus <flow@gentoo.org> CommitDate: 2022-06-29 06:45:21 +0000 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 eclass/java-vm-2.eclass | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)