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 08:17:17
Message-Id: 1656058614.387323902452153fceb1f61e3d6bb5b3bfeba786.flow@gentoo
1 commit: 387323902452153fceb1f61e3d6bb5b3bfeba786
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 08:16:54 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-java.git/commit/?id=38732390
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 | 18 +++++++++++++++++-
14 2 files changed, 18 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..571b26e 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,22 @@ 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 + if ! is_number "${1}"; then
49 + die -q ${usage}
50 + fi
51 +
52 + local kind
53 + if [[ ${UID} -eq 0 ]]; then
54 + kind="system"
55 + else
56 + kind="user"
57 + fi
58 + set -- ${kind} ${@}
59 + fi
60 +
61 if [[ ${#} != 2 ]]; then
62 die -q ${usage}
63 elif [[ ${1} == "system" ]]; then