* [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-zig/files/, app-eselect/eselect-zig/
@ 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: 0c82bebe7d8a44c57b0348a2bf2037e30cf409ec
Author: Eric Joldasov <bratishkaerik <AT> getgoogleoff <DOT> me>
AuthorDate: Tue Jan 24 11:55:41 2023 +0000
Commit: Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Thu Mar 9 10:53:57 2023 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0c82bebe
app-eselect/eselect-zig: new package, add 1
Signed-off-by: Eric Joldasov <bratishkaerik <AT> getgoogleoff.me>
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
app-eselect/eselect-zig/eselect-zig-1.ebuild | 24 +++++++
app-eselect/eselect-zig/files/zig.eselect-1 | 93 ++++++++++++++++++++++++++++
app-eselect/eselect-zig/metadata.xml | 13 ++++
3 files changed, 130 insertions(+)
diff --git a/app-eselect/eselect-zig/eselect-zig-1.ebuild b/app-eselect/eselect-zig/eselect-zig-1.ebuild
new file mode 100644
index 000000000000..6986fff09954
--- /dev/null
+++ b/app-eselect/eselect-zig/eselect-zig-1.ebuild
@@ -0,0 +1,24 @@
+# Copyright 2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Manages Zig versions"
+HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~riscv ~x86"
+
+RDEPEND="
+ app-admin/eselect
+ !dev-lang/zig:0
+ !dev-lang/zig-bin:0
+"
+
+S="${WORKDIR}"
+
+src_install() {
+ insinto /usr/share/eselect/modules/
+ newins "${FILESDIR}"/zig.eselect-${PVR} zig.eselect
+}
diff --git a/app-eselect/eselect-zig/files/zig.eselect-1 b/app-eselect/eselect-zig/files/zig.eselect-1
new file mode 100644
index 000000000000..f52ce2ee9652
--- /dev/null
+++ b/app-eselect/eselect-zig/files/zig.eselect-1
@@ -0,0 +1,93 @@
+# -*-eselect-*- vim: ft=eselect
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+DESCRIPTION="Manage Zig versions"
+MAINTAINER="bratishkaerik@getgoogleoff.me"
+
+show_selected_target() {
+ readlink "${EROOT}/usr/bin/zig"
+}
+
+find_targets() {
+ for f in "${EROOT}"/usr/bin/zig-*; do
+ [[ -f "${f}" ]] && basename "${f}"
+ done
+}
+
+remove_symlinks() {
+ rm "${EROOT}/usr/bin/zig"
+}
+
+set_symlinks() {
+ local target=$1
+ if is_number "${target}"; then
+ local targets=( $(find_targets) )
+ target=${targets[target-1]}
+ fi
+
+ [[ -z "${target}" || ! -f "${EROOT}/usr/bin/${target}" ]] \
+ && die -q "Target \"$1\" doesn't appear to be valid!"
+
+ ln -s "${target}" "${EROOT}/usr/bin/zig"
+}
+
+
+
+### show action ###
+
+describe_show() {
+ echo "Show current Zig version"
+}
+
+do_show() {
+ write_list_start "Current Zig version:"
+ if [[ -L "${EROOT}/usr/bin/zig" ]]; then
+ write_kv_list_entry "$(show_selected_target)" ""
+ else
+ write_kv_list_entry "(unset)" ""
+ fi
+}
+
+### list action ###
+
+describe_list() {
+ echo "List available Zig versions"
+}
+
+do_list() {
+ local targets=( $(find_targets) )
+ local selected_target
+ selected_target=$(show_selected_target)
+
+ write_list_start "Available Zig versions:"
+ for (( i = 0; i < ${#targets[@]}; i++ )); do
+ [[ ${targets[i]} == "${selected_target}" ]] && targets[i]=$(highlight_marker "${targets[i]}")
+ done
+ write_numbered_list -m "(none found)" "${targets[@]}"
+}
+
+
+### set action ###
+
+describe_set() {
+ echo "Set active Zig version"
+}
+
+describe_set_parameters() {
+ echo "<target>"
+}
+
+describe_set_options() {
+ echo "target: Target name or number (from 'list' action)"
+}
+
+do_set() {
+ [[ -z $1 ]] && die -q "You need to specify a target"
+ [[ $# -gt 1 ]] && die -q "Too many parameters"
+
+ 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"
+}
diff --git a/app-eselect/eselect-zig/metadata.xml b/app-eselect/eselect-zig/metadata.xml
new file mode 100644
index 000000000000..3a2ae2384d95
--- /dev/null
+++ b/app-eselect/eselect-zig/metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person" proxied="yes">
+ <email>bratishkaerik@getgoogleoff.me</email>
+ <name>Eric Joldasov</name>
+ </maintainer>
+ <maintainer type="project" proxied="proxy">
+ <email>proxy-maint@gentoo.org</email>
+ <name>Proxy Maintainers</name>
+ </maintainer>
+ <stabilize-allarches/>
+</pkgmetadata>
^ 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/, app-eselect/eselect-zig/ Florian Schmaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox