diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-03-09 12:02:14 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-03-09 12:02:14 +0000 |
commit | 0fd62365fc104d7e6d5f3ef67800df09225a4019 (patch) | |
tree | 163b4a5055e07325ae1dc4f9bbbc2021ca1b6afa /app-eselect/eselect-zig | |
parent | 442eaf1780a48ddbd7a39f5a3f34d959c3c6d27e (diff) |
gentoo auto-resync : 09:03:2023 - 12:02:14
Diffstat (limited to 'app-eselect/eselect-zig')
-rw-r--r-- | app-eselect/eselect-zig/Manifest | 3 | ||||
-rw-r--r-- | app-eselect/eselect-zig/eselect-zig-1.ebuild | 24 | ||||
-rw-r--r-- | app-eselect/eselect-zig/files/zig.eselect-1 | 132 | ||||
-rw-r--r-- | app-eselect/eselect-zig/metadata.xml | 13 |
4 files changed, 172 insertions, 0 deletions
diff --git a/app-eselect/eselect-zig/Manifest b/app-eselect/eselect-zig/Manifest new file mode 100644 index 000000000000..205f46fad026 --- /dev/null +++ b/app-eselect/eselect-zig/Manifest @@ -0,0 +1,3 @@ +AUX zig.eselect-1 2860 BLAKE2B 2b873f3719f00c7ed9054329ccd26bf7f771c11f1258a04dee603992d76d0a4c3228e1088caa13996f23e9450cde9cfe7a0eaf57e882d7270f4ff124f1c4189e SHA512 c5b75d178010cbe0dec643f80f0348ff4b86893ae714f28387211a2e8ad5022220650dbb5eb2efeb039f924f7525c81325da26f7a201bf472622965a6097b9ef +EBUILD eselect-zig-1.ebuild 458 BLAKE2B 52a3d5a98860b863784de6d686fa420501c68b2e7816c0c9d7bbaa67817c942e3877583a04a8db552bfd2a4669f29471295e312eaf2be0e63851e0f245b27d0e SHA512 8281d834c396e9de3a813cf92e18c14beaa385ee36a2a64dfe748158fb809d2102a6439b112d9c2d7d45a6846fd02e4b567da54c61fc897d9594f0659b10b571 +MISC metadata.xml 430 BLAKE2B 1babe1d0968ae0b34f660e07873f79457134f2f9684029903b8a8747710bfd1ac14642d4ad49851935a42787b6fba77926754ceb80d12a335943cc73e959971d SHA512 ccc634b9a183ea5012749759a510499b7cad1cc6b86e3c40bbda1428a9320949f8e04a15a862670d03ce17a85ce861ac45d497979ac047717106432fba19ec82 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..938a0d665226 --- /dev/null +++ b/app-eselect/eselect-zig/files/zig.eselect-1 @@ -0,0 +1,132 @@ +# -*-eselect-*- vim: ft=eselect +# Copyright 2022-2023 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" + 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?" +} 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> |