public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-zig/files/
@ 2023-03-09 10:54 Florian Schmaus
  0 siblings, 0 replies; only message in thread
From: Florian Schmaus @ 2023-03-09 10:54 UTC (permalink / raw
  To: gentoo-commits

commit:     f779d7181f27de5c7d950933383e357843025754
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Thu Mar  9 10:47:05 2023 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Thu Mar  9 10:53:59 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f779d718

app-eselect/eselect-zig: add 'update' action

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>

 app-eselect/eselect-zig/files/zig.eselect-1 | 41 ++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/app-eselect/eselect-zig/files/zig.eselect-1 b/app-eselect/eselect-zig/files/zig.eselect-1
index f52ce2ee9652..938a0d665226 100644
--- a/app-eselect/eselect-zig/files/zig.eselect-1
+++ b/app-eselect/eselect-zig/files/zig.eselect-1
@@ -1,5 +1,5 @@
 # -*-eselect-*-  vim: ft=eselect
-# Copyright 2022 Gentoo Authors
+# Copyright 2022-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 DESCRIPTION="Manage Zig versions"
@@ -85,9 +85,48 @@ describe_set_options() {
 do_set() {
 	[[ -z $1 ]] && die -q "You need to specify a target"
 	[[ $# -gt 1 ]] && die -q "Too many parameters"
+	test_usr_bin_writeable
 
 	if [[ -L "${EROOT}/usr/bin/zig" ]]; then
 		remove_symlinks || die -q "Couldn't remove symlink"
 	fi
 	set_symlinks "$1" || die -q "Couldn't set a new symlink"
 }
+
+
+### update action ###
+
+describe_update() {
+    echo "Automatically update the zig symlink"
+}
+
+describe_update_options() {
+    echo "ifunset: Do not override currently set version"
+}
+
+do_update() {
+    [[ -z $1 || $1 == ifunset ]] || die -q "Usage error"
+    [[ $# -gt 1 ]] && die -q "Too many parameters"
+	test_usr_bin_writeable
+
+    if [[ -L ${EROOT}/usr/bin/zig ]]; then
+        if [[ $1 == ifunset && -e ${EROOT}/usr/bin/zig ]]; then
+            return
+        fi
+        remove_symlink
+    elif [[ -e ${EROOT}/usr/bin/zig ]]; then
+        die -q "${EROOT}/usr/bin/zig exists but is not a symlink"
+    fi
+
+    local targets=( $(find_targets) )
+    if [[ ${#targets[@]} -gt 0 ]]; then
+        set_symlinks "${targets[${#targets[@]}-1]}"
+    fi
+}
+
+
+### helper functions ###
+
+test_usr_bin_writeable() {
+    [[ -w ${EROOT}/usr/bin ]] || die -q "${EROOT}/usr/bin not writeable by current user. Are you root?"
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-09 10:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09 10:54 [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-zig/files/ Florian Schmaus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox