1 # -*-eselect-*- vim: ft=eselect
2 # Copyright 1999-2015 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 DESCRIPTION="Manage /usr/bin/pdftex implementations"
6 MAINTAINER="tex@gentoo.org"
7 SVN_DATE='$Date: 2015/03/31 16:53:36 $'
8 VERSION=$(svn_date_to_version "${SVN_DATE}" )
10 # find a list of pdftex symlink targets, best first
13 for f in "${ROOT}"/usr/bin/pdftex-*; do
14 if [[ -f ${f} ]] ; then
15 echo "${f##*/pdftex-}"
20 # find version number of currently symlinked version
23 f="$(canonicalise "${ROOT}"/usr/bin/pdftex)"
24 echo "${f##*/pdftex-}"
27 # try to remove the pdftex symlink
29 rm -f "${ROOT}"/usr/bin/pdftex &>/dev/null
32 # set the pdftex symlink
34 local target="${1}" targets
35 if is_number "${target}" && [[ ${target} -ge 1 ]] ; then
36 targets=( $(find_targets ) )
37 target=${targets[$(( ${target} - 1 ))]}
39 if [[ -f "${ROOT}/usr/bin/pdftex-${target}" ]] ; then
41 ln -s "pdftex-${target}" "${ROOT}/usr/bin/pdftex" || \
42 die "Could not set ${target} /usr/bin/pdftex symlink"
43 echo "Updating TeX formats"
44 "${ROOT}"/usr/bin/fmtutil-sys --all &>/dev/null || write_warning_msg "Could not update TeX formats for some reason, pdftex may not work properly."
46 die -q "Target \"${target}\" doesn't appear to be valid!"
53 echo "Show the current pdftex version"
57 [[ -z "${@}" ]] || die -q "Too many parameters"
59 write_list_start "Current pdftex verson:"
60 if [[ -L "${ROOT}/usr/bin/pdftex" ]] ; then
61 write_kv_list_entry "$(identify_target)" ""
62 elif [[ -e "${ROOT}/usr/bin/pdftex" ]] ; then
63 write_kv_list_entry "(not a symlink)" ""
65 write_kv_list_entry "(unset)" ""
72 echo "List available pdftex versions"
76 [[ -z "${@}" ]] || die -q "Too many parameters"
78 local i targets current
79 targets=( $(find_targets ) )
80 current=$(identify_target)
81 for (( i = 0; i < ${#targets[@]}; i++ )); do
82 [[ ${targets[i]} = ${current} ]] \
83 && targets[i]=$(highlight_marker "${targets[i]}")
85 write_list_start "Available pdftex versions:"
86 write_numbered_list -m "(none found)" "${targets[@]}"
92 echo "Set a new pdftex version"
95 describe_set_options() {
96 echo "target : Target version number or index from 'list' action"
99 describe_set_parameters() {
104 if [[ -z "${1}" ]] ; then
105 die -q "You didn't give me a version number"
107 elif [[ -n "${2}" ]] ; then
108 die -q "Too many parameters"
110 elif [[ -L "${ROOT}/usr/bin/pdftex" ]] ; then
111 if ! remove_symlinks ; then
112 die -q "Can't remove existing version symlink"
113 elif ! set_symlinks "${1}" ; then
114 die -q "Can't set new version"
117 elif [[ -e "${ROOT}/usr/bin/pdftex" ]] ; then
118 die -q "${ROOT}/usr/bin/pdftex seems to be from an old ebuild, please remove manually"
120 set_symlinks "${1}" || die -q "Can't set new version"
124 ### update action ###
127 echo "Automatically update the pdftex version number"
130 describe_update_options() {
131 echo "--if-unset : Do not override currently selected version"
135 [[ -z "${1}" ]] || ( [[ -z "${2}" ]] && [[ "${1}" == "--if-unset" ]] ) || \
138 if [[ -L "${ROOT}/usr/bin/pdftex" ]] ; then
139 [[ ${1} == "--if-unset" ]] && return
140 remove_symlinks || die -q "Can't remove existing symlink"
142 if [[ -e "${ROOT}/usr/bin/pdftex" ]] ; then
143 die -q "${ROOT}/usr/bin/pdftex seems to be from an old ebuild, please remove manually"
144 elif ! [[ -z $(find_targets ) ]] ; then
145 set_symlinks 1 || die -q "Can't set a new version"