Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 853928

Summary: java-vm-2.eclass - pkg_postrm should ensure a valid system VM is selected
Product: Gentoo Linux Reporter: Mike Gilbert <floppym>
Component: EclassesAssignee: Java team <java>
Severity: normal CC: flow, gem, gentoo, sam
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also:
Package list:
Runtime testing required: ---

Description Mike Gilbert gentoo-dev 2022-06-23 20:05:58 UTC
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.
Comment 1 Mike Gilbert gentoo-dev 2022-06-23 23:16:30 UTC
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!"
Comment 2 Florian Schmaus gentoo-dev 2022-06-24 07:33:58 UTC
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 ( 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. :)
Comment 3 Larry the Git Cow gentoo-dev 2022-06-24 10:33:36 UTC
The bug has been referenced in the following commit(s):

commit 561e6cb5b3fefb6c248056aa4d790276433856b3
Author:     Florian Schmaus <>
AuthorDate: 2022-06-24 07:02:14 +0000
Commit:     Florian Schmaus <>
CommitDate: 2022-06-24 08:16:33 +0000

    Add "eselect java-vm update"
    Signed-off-by: Florian Schmaus <>

 NEWS                           |  3 +++
 src/modules/ | 55 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
Comment 4 Larry the Git Cow gentoo-dev 2022-06-24 10:40:29 UTC
The bug has been referenced in the following commit(s):

commit b81c6cda810dcb3e322a554b9cde88cd27c47248
Author:     Florian Schmaus <>
AuthorDate: 2022-06-24 10:34:16 +0000
Commit:     Florian Schmaus <>
CommitDate: 2022-06-24 10:39:19 +0000

    app-eselect/eselect-java: add 0.5.0
    Signed-off-by: Florian Schmaus <>

 app-eselect/eselect-java/Manifest                  |  1 +
 app-eselect/eselect-java/eselect-java-0.5.0.ebuild | 35 ++++++++++++++++++++++
 2 files changed, 36 insertions(+)
Comment 5 Larry the Git Cow gentoo-dev 2022-06-29 06:45:30 UTC
The bug has been closed via the following commit(s):

commit 9fa13744b8265023142ad7050fa67cce67ce29fa
Author:     Florian Schmaus <>
AuthorDate: 2022-06-24 19:58:21 +0000
Commit:     Florian Schmaus <>
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
    Thanks to Mike Gilbert (floppym) for valuable feedback.
    1: PMS 2021-06-13 § 8.1 Dependency Classes -
    Signed-off-by: Florian Schmaus <>

 eclass/java-vm-2.eclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)