Commit 8ee5dec9 authored by ZappeL's avatar ZappeL
Browse files

initial

parents
{
"files.associations": {
"*.eselect": "shellscript"
},
}
\ No newline at end of file
# eselect-vala
Eselect module for Vala (and vapigen).
## Install
This is part of the [zGnome](https://lab.retarded.farm/zappel/zGnome) overlay. Instructions can be found there.
## Contributing
Feel free to open issues or contact me directly.
# -*-eselect-*- vim: ft=eselect
# Copyright 2005-2019 Gentoo Foundation
# Distributed under the terms of the GNU GPL version 2 or later
DESCRIPTION="Creates symlinks for valac and vapigen"
MAINTAINER="zappel@simple-co.de"
VERSION="20190919"
# find a list of symlink targets
find_targets() {
local f
for f in "${EROOT}/usr/bin/${1}-"[[:digit:]]*; do
[[ -f ${f} ]] && basename "${f}"
done
}
# remove the symlinks
remove_symlink() {
rm "${EROOT}/usr/bin/${1}"
}
# set the symlinks (1: binary / 2: version)
set_symlink() {
local target=${2}
if is_number "${target}"; then
local targets=( $(find_targets ${1}) )
target=${targets[target-1]}
fi
[[ -z ${target} || ! -f ${EROOT}/usr/bin/${target} ]] \
&& die -q "Target \"${2}\" doesn't appear to be valid!"
ln -s "${target}" "${EROOT}/usr/bin/${1}"
}
### show action ###
describe_show() {
echo "Show the current symlinks"
}
do_show() {
write_list_start "Current symlinks:"
for bin in {valac,vapigen}; do
if [[ -L "${EROOT}/usr/bin/${bin}" ]]; then
local link=$(canonicalise "${EROOT}/usr/bin/${bin}")
write_kv_list_entry "${link%/}" ""
else
write_kv_list_entry "(unset)" ""
fi
done
}
### list action ###
describe_list() {
echo "List available symlink targets"
}
do_list() {
# list uses valac only
local i targets=( $(find_targets valac) )
write_list_start "Available symlink targets:"
for (( i = 0; i < ${#targets[@]}; i++ )); do
[[ ${targets[i]} = \
$(basename "$(canonicalise "${EROOT}/usr/bin/valac")") ]] \
&& targets[i]=$(highlight_marker "${targets[i]}")
done
write_numbered_list -m "(none found)" "${targets[@]}"
}
### set action ###
describe_set() {
echo "Set a new symlink target"
}
describe_set_parameters() {
echo "<target>"
}
describe_set_options() {
echo "target : Target name or number (from 'list' action)"
}
do_set() {
[[ -z ${1} ]] && die -q "You didn't tell me what to set the symlink to"
[[ $# -gt 1 ]] && die -q "Too many parameters"
for bin in {valac,vapigen}; do
if [[ -L ${EROOT}/usr/bin/${bin} ]]; then
remove_symlink "${bin}" || die -q "Couldn't remove existing symlink"
set_symlink "${bin}" "${1}" || die -q "Couldn't set a new symlink"
elif [[ -e ${EROOT}/usr/bin/${bin} ]]; then
die -q "${EROOT}/usr/bin/${bin} exists but is not a symlink"
else
set_symlink "${bin}" "${1}" || die -q "Couldn't set a new symlink"
fi
done
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment