Gentoo Archives: gentoo-commits

From: Florian Schmaus <flow@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/eselect-java:java-vm-update commit in: /, src/modules/
Date: Fri, 24 Jun 2022 09:21:08
Message-Id: 1656062460.a9fd19b87c15c4c573ab43b8547a26d6ea894ebc.flow@gentoo
1 commit: a9fd19b87c15c4c573ab43b8547a26d6ea894ebc
2 Author: Florian Schmaus <flow <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 24 07:49:14 2022 +0000
4 Commit: Florian Schmaus <flow <AT> gentoo <DOT> org>
5 CommitDate: Fri Jun 24 09:21:00 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-java.git/commit/?id=a9fd19b8
7
8 Decide based on the UID if system or user VM should be modified
9
10 Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
11
12 NEWS | 1 +
13 src/modules/java-vm.eselect.in | 14 +++++++++++++-
14 2 files changed, 14 insertions(+), 1 deletion(-)
15
16 diff --git a/NEWS b/NEWS
17 index d8ea978..52fbfe5 100644
18 --- a/NEWS
19 +++ b/NEWS
20 @@ -1,5 +1,6 @@
21 NEXT:
22 * Add "eselect java-vm update" (#853928)
23 + * Decide on UID if system or user VM should be set
24
25 0.4.3:
26 * install jpackage symlink
27
28 diff --git a/src/modules/java-vm.eselect.in b/src/modules/java-vm.eselect.in
29 index c7d5a82..7c46ff1 100644
30 --- a/src/modules/java-vm.eselect.in
31 +++ b/src/modules/java-vm.eselect.in
32 @@ -116,7 +116,7 @@ describe_set_parameters() {
33 }
34
35 do_set() {
36 - local usage="Usage <user|system> <VM>"
37 + local usage="Usage [user|system] <VM>"
38 local ifunset=0
39
40 if [[ ${1} == "--if-unset" ]]; then
41 @@ -124,6 +124,18 @@ do_set() {
42 shift
43 fi
44
45 + # Automatically decide, based in the invoking user's UID, if the
46 + # user or system Java VM should be modified.
47 + if [[ ${#} -eq 1 ]]; then
48 + local kind
49 + if [[ ${UID} -eq 0 ]]; then
50 + kind="system"
51 + else
52 + kind="user"
53 + fi
54 + set -- ${kind} ${@}
55 + fi
56 +
57 if [[ ${#} != 2 ]]; then
58 die -q ${usage}
59 elif [[ ${1} == "system" ]]; then