90 lines
1.9 KiB
Plaintext
90 lines
1.9 KiB
Plaintext
# -*-eselect-*- vim: ft=eselect
|
|
# Copyright 1999-2021 Gentoo Authors
|
|
# Distributed under the terms of the GNU GPL version 2 or later
|
|
|
|
DESCRIPTION="Manage the juceaide version"
|
|
MAINTAINER="flewkey@2a03.party"
|
|
VERSION="@V@"
|
|
|
|
find_targets() {
|
|
local target
|
|
for target in "${EROOT}/opt/juce-"*; do
|
|
[[ -f "${target}/juceaide" ]] && basename ${target}
|
|
done
|
|
}
|
|
|
|
remove_symlink() {
|
|
rm -f "${EROOT}/usr/bin/juceaide"
|
|
}
|
|
|
|
set_symlink() {
|
|
local target="${1}"
|
|
ln -s "${EROOT}/opt/${target}/juceaide" "${EROOT}/usr/bin/juceaide"
|
|
}
|
|
|
|
get_version() {
|
|
local path=$(canonicalise "${EROOT}/usr/bin/juceaide")
|
|
echo $(basename "${path::-8}")
|
|
}
|
|
|
|
validate_target() {
|
|
[[ -f "${EROOT}/opt/${1}/juceaide" ]] || die
|
|
}
|
|
|
|
# show
|
|
|
|
describe_show() {
|
|
echo "Show the current juceaide version"
|
|
}
|
|
|
|
do_show() {
|
|
write_list_start "Current juceaide version:"
|
|
if [[ -f "${EROOT}/usr/bin/juceaide" ]]; then
|
|
write_kv_list_entry $(get_version) ""
|
|
else
|
|
write_kv_list_entry "(unset)" ""
|
|
fi
|
|
}
|
|
|
|
# list
|
|
|
|
describe_list() {
|
|
echo "List available juceaide versions"
|
|
}
|
|
|
|
do_list() {
|
|
local i targets=( $(find_targets) )
|
|
write_list_start "Available juceaide versions:"
|
|
for (( i = 0; i < ${#targets[@]}; i++ )); do
|
|
[[ ${targets[i]} = $(get_version) ]] \
|
|
&& targets[i]=$(highlight_marker "${targets[i]}")
|
|
done
|
|
write_numbered_list -m "(none found)" "${targets[@]}"
|
|
}
|
|
|
|
# set
|
|
|
|
describe_set() {
|
|
echo "Set a new juceaide version"
|
|
}
|
|
|
|
describe_set_parameters() {
|
|
echo "<target>"
|
|
}
|
|
|
|
describe_set_options() {
|
|
echo "target : Target JUCE package"
|
|
}
|
|
|
|
do_set() {
|
|
[[ -z ${1} ]] && die -q "Please specify a version of JUCE"
|
|
local target="${1}"
|
|
if is_number "${target}" ; then
|
|
targets=( $(find_targets) )
|
|
target=${targets[$((${target}-1))]}
|
|
fi
|
|
validate_target ${target} || die -q "Invalid target"
|
|
remove_symlink || die -q "Failed to remove the existing symlink"
|
|
set_symlink "${target}" || die -q "Failed to set the new symlink"
|
|
}
|