From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4EE31158094 for ; Fri, 24 Jun 2022 10:33:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7585EE0886; Fri, 24 Jun 2022 10:33:39 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5DD2FE0886 for ; Fri, 24 Jun 2022 10:33:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7292A341A52 for ; Fri, 24 Jun 2022 10:33:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 11EE0510 for ; Fri, 24 Jun 2022 10:33:37 +0000 (UTC) From: "Florian Schmaus" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Florian Schmaus" Message-ID: <1656058593.561e6cb5b3fefb6c248056aa4d790276433856b3.flow@gentoo> Subject: [gentoo-commits] proj/eselect-java:master commit in: src/modules/, / X-VCS-Repository: proj/eselect-java X-VCS-Files: NEWS src/modules/java-vm.eselect.in X-VCS-Directories: src/modules/ / X-VCS-Committer: flow X-VCS-Committer-Name: Florian Schmaus X-VCS-Revision: 561e6cb5b3fefb6c248056aa4d790276433856b3 X-VCS-Branch: master Date: Fri, 24 Jun 2022 10:33:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b3f7541c-7839-4b52-a105-ca62cfa0c51a X-Archives-Hash: 450dba3ebf9582e14eeff1376aa86064 commit: 561e6cb5b3fefb6c248056aa4d790276433856b3 Author: Florian Schmaus gentoo org> AuthorDate: Fri Jun 24 07:02:14 2022 +0000 Commit: Florian Schmaus gentoo org> CommitDate: Fri Jun 24 08:16:33 2022 +0000 URL: https://gitweb.gentoo.org/proj/eselect-java.git/commit/?id=561e6cb5 Add "eselect java-vm update" Bug: https://bugs.gentoo.org/853928 Signed-off-by: Florian Schmaus gentoo.org> NEWS | 3 +++ src/modules/java-vm.eselect.in | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/NEWS b/NEWS index 6c331a2..d8ea978 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +NEXT: + * Add "eselect java-vm update" (#853928) + 0.4.3: * install jpackage symlink diff --git a/src/modules/java-vm.eselect.in b/src/modules/java-vm.eselect.in index e332c5a..c7d5a82 100644 --- a/src/modules/java-vm.eselect.in +++ b/src/modules/java-vm.eselect.in @@ -177,3 +177,58 @@ set_symlink() { die -q "Target \"${1}\" doesn't appear to be valid!" fi } + +describe_update() { + echo "Automatically update the Java system VM" +} + +do_update() { + local targets + targets=( $(find_targets) ) + + if [[ ${#targets[@]} -eq 0 ]]; then + echo "No installed Java VMs found, can not update" + return + fi + + if [[ -e "${VM_SYSTEM}" ]]; then + local current_system_vm_name=$(sym_to_vm "${VM_SYSTEM}") + echo "Current Java system VM ${current_system_vm_name} is valid, no need to update" + return + fi + + local new_target old_system_vm_name + if [[ -L "${VM_SYSTEM}" ]]; then + # There exists a Java system VM symlink that has become stale, + # try to find another available VM with the same slot. + old_system_vm_name=$(sym_to_vm "${VM_SYSTEM}") + + local old_system_vm_slot="${old_system_vm_name##*-}" + + local target + for target in "${targets[@]}"; do + local target_slot="${target##*-}" + if [[ ${target_slot} -eq ${old_system_vm_slot} ]]; then + new_target="${target}" + break + fi + done + fi + + if [[ -z "${new_target}" ]]; then + # There is no Java system VM symlink or we could not find a + # slot-matching replacement. But there are potential targets, + # simply choose the first. + # TODO: We could get more sophisticated here to select the "best" + # target, but that is far from trivial. + new_target="${targets[0]}" + fi + + local from_vm_text="" + if [[ -n "${old_system_vm_name}" ]]; then + from_vm_text="from ${old_system_vm_name} " + fi + + echo "Updating Java system VM ${from_vm_text}to ${new_target}" + set_symlink "${new_target}" "${VM_SYSTEM}" +} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C366C158094 for ; Fri, 24 Jun 2022 08:17:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 062EBE0839; Fri, 24 Jun 2022 08:17:16 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DD75CE0839 for ; Fri, 24 Jun 2022 08:17:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F0507340FC1 for ; Fri, 24 Jun 2022 08:17:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 58DB33C3 for ; Fri, 24 Jun 2022 08:17:13 +0000 (UTC) From: "Florian Schmaus" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Florian Schmaus" Message-ID: <1656058593.561e6cb5b3fefb6c248056aa4d790276433856b3.flow@gentoo> Subject: [gentoo-commits] proj/eselect-java:java-vm-update commit in: src/modules/, / X-VCS-Repository: proj/eselect-java X-VCS-Files: NEWS src/modules/java-vm.eselect.in X-VCS-Directories: src/modules/ / X-VCS-Committer: flow X-VCS-Committer-Name: Florian Schmaus X-VCS-Revision: 561e6cb5b3fefb6c248056aa4d790276433856b3 X-VCS-Branch: java-vm-update Date: Fri, 24 Jun 2022 08:17:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d7bbffe3-2f97-4675-a083-40caee9d51f9 X-Archives-Hash: 58273d7fb8aca82deaeeb69174619ef7 Message-ID: <20220624081713.LMQVXuCCJCN-sYIaQh_UbgWHc-KRiY2uWdbN7aWTDWM@z> commit: 561e6cb5b3fefb6c248056aa4d790276433856b3 Author: Florian Schmaus gentoo org> AuthorDate: Fri Jun 24 07:02:14 2022 +0000 Commit: Florian Schmaus gentoo org> CommitDate: Fri Jun 24 08:16:33 2022 +0000 URL: https://gitweb.gentoo.org/proj/eselect-java.git/commit/?id=561e6cb5 Add "eselect java-vm update" Bug: https://bugs.gentoo.org/853928 Signed-off-by: Florian Schmaus gentoo.org> NEWS | 3 +++ src/modules/java-vm.eselect.in | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/NEWS b/NEWS index 6c331a2..d8ea978 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +NEXT: + * Add "eselect java-vm update" (#853928) + 0.4.3: * install jpackage symlink diff --git a/src/modules/java-vm.eselect.in b/src/modules/java-vm.eselect.in index e332c5a..c7d5a82 100644 --- a/src/modules/java-vm.eselect.in +++ b/src/modules/java-vm.eselect.in @@ -177,3 +177,58 @@ set_symlink() { die -q "Target \"${1}\" doesn't appear to be valid!" fi } + +describe_update() { + echo "Automatically update the Java system VM" +} + +do_update() { + local targets + targets=( $(find_targets) ) + + if [[ ${#targets[@]} -eq 0 ]]; then + echo "No installed Java VMs found, can not update" + return + fi + + if [[ -e "${VM_SYSTEM}" ]]; then + local current_system_vm_name=$(sym_to_vm "${VM_SYSTEM}") + echo "Current Java system VM ${current_system_vm_name} is valid, no need to update" + return + fi + + local new_target old_system_vm_name + if [[ -L "${VM_SYSTEM}" ]]; then + # There exists a Java system VM symlink that has become stale, + # try to find another available VM with the same slot. + old_system_vm_name=$(sym_to_vm "${VM_SYSTEM}") + + local old_system_vm_slot="${old_system_vm_name##*-}" + + local target + for target in "${targets[@]}"; do + local target_slot="${target##*-}" + if [[ ${target_slot} -eq ${old_system_vm_slot} ]]; then + new_target="${target}" + break + fi + done + fi + + if [[ -z "${new_target}" ]]; then + # There is no Java system VM symlink or we could not find a + # slot-matching replacement. But there are potential targets, + # simply choose the first. + # TODO: We could get more sophisticated here to select the "best" + # target, but that is far from trivial. + new_target="${targets[0]}" + fi + + local from_vm_text="" + if [[ -n "${old_system_vm_name}" ]]; then + from_vm_text="from ${old_system_vm_name} " + fi + + echo "Updating Java system VM ${from_vm_text}to ${new_target}" + set_symlink "${new_target}" "${VM_SYSTEM}" +}