Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-eselect/eselect-pdftex/files: pdftex.eselect-0.3
Date: Tue, 31 Mar 2015 16:53:39
Message-Id: 20150331165336.409C014EE2@oystercatcher.gentoo.org
1 ulm 15/03/31 16:53:36
2
3 Added: pdftex.eselect-0.3
4 Log:
5 Move package from app-admin to app-eselect category.
6
7 (Portage version: 2.2.18/cvs/Linux x86_64, RepoMan options: --force, signed Manifest commit with key 9433907D693FB5B8!)
8
9 Revision Changes Path
10 1.1 app-eselect/eselect-pdftex/files/pdftex.eselect-0.3
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-pdftex/files/pdftex.eselect-0.3?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-pdftex/files/pdftex.eselect-0.3?rev=1.1&content-type=text/plain
14
15 Index: pdftex.eselect-0.3
16 ===================================================================
17 # -*-eselect-*- vim: ft=eselect
18 # Copyright 1999-2015 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Id: pdftex.eselect-0.3,v 1.1 2015/03/31 16:53:36 ulm Exp $
21
22 DESCRIPTION="Manage /usr/bin/pdftex implementations"
23 MAINTAINER="tex@g.o"
24 SVN_DATE='$Date: 2015/03/31 16:53:36 $'
25 VERSION=$(svn_date_to_version "${SVN_DATE}" )
26
27 # find a list of pdftex symlink targets, best first
28 find_targets() {
29 local f
30 for f in "${ROOT}"/usr/bin/pdftex-*; do
31 if [[ -f ${f} ]] ; then
32 echo "${f##*/pdftex-}"
33 fi
34 done | sort
35 }
36
37 # find version number of currently symlinked version
38 identify_target() {
39 local f
40 f="$(canonicalise "${ROOT}"/usr/bin/pdftex)"
41 echo "${f##*/pdftex-}"
42 }
43
44 # try to remove the pdftex symlink
45 remove_symlinks() {
46 rm -f "${ROOT}"/usr/bin/pdftex &>/dev/null
47 }
48
49 # set the pdftex symlink
50 set_symlinks() {
51 local target="${1}" targets
52 if is_number "${target}" && [[ ${target} -ge 1 ]] ; then
53 targets=( $(find_targets ) )
54 target=${targets[$(( ${target} - 1 ))]}
55 fi
56 if [[ -f "${ROOT}/usr/bin/pdftex-${target}" ]] ; then
57 remove_symlinks
58 ln -s "pdftex-${target}" "${ROOT}/usr/bin/pdftex" || \
59 die "Could not set ${target} /usr/bin/pdftex symlink"
60 echo "Updating TeX formats"
61 "${ROOT}"/usr/bin/fmtutil-sys --all &>/dev/null || write_warning_msg "Could not update TeX formats for some reason, pdftex may not work properly."
62 else
63 die -q "Target \"${target}\" doesn't appear to be valid!"
64 fi
65 }
66
67 ### show action ###
68
69 describe_show() {
70 echo "Show the current pdftex version"
71 }
72
73 do_show() {
74 [[ -z "${@}" ]] || die -q "Too many parameters"
75
76 write_list_start "Current pdftex verson:"
77 if [[ -L "${ROOT}/usr/bin/pdftex" ]] ; then
78 write_kv_list_entry "$(identify_target)" ""
79 elif [[ -e "${ROOT}/usr/bin/pdftex" ]] ; then
80 write_kv_list_entry "(not a symlink)" ""
81 else
82 write_kv_list_entry "(unset)" ""
83 fi
84 }
85
86 ### list action ###
87
88 describe_list() {
89 echo "List available pdftex versions"
90 }
91
92 do_list() {
93 [[ -z "${@}" ]] || die -q "Too many parameters"
94
95 local i targets current
96 targets=( $(find_targets ) )
97 current=$(identify_target)
98 for (( i = 0; i < ${#targets[@]}; i++ )); do
99 [[ ${targets[i]} = ${current} ]] \
100 && targets[i]=$(highlight_marker "${targets[i]}")
101 done
102 write_list_start "Available pdftex versions:"
103 write_numbered_list -m "(none found)" "${targets[@]}"
104 }
105
106 ### set action ###
107
108 describe_set() {
109 echo "Set a new pdftex version"
110 }
111
112 describe_set_options() {
113 echo "target : Target version number or index from 'list' action"
114 }
115
116 describe_set_parameters() {
117 echo "<target>"
118 }
119
120 do_set() {
121 if [[ -z "${1}" ]] ; then
122 die -q "You didn't give me a version number"
123
124 elif [[ -n "${2}" ]] ; then
125 die -q "Too many parameters"
126
127 elif [[ -L "${ROOT}/usr/bin/pdftex" ]] ; then
128 if ! remove_symlinks ; then
129 die -q "Can't remove existing version symlink"
130 elif ! set_symlinks "${1}" ; then
131 die -q "Can't set new version"
132 fi
133
134 elif [[ -e "${ROOT}/usr/bin/pdftex" ]] ; then
135 die -q "${ROOT}/usr/bin/pdftex seems to be from an old ebuild, please remove manually"
136 else
137 set_symlinks "${1}" || die -q "Can't set new version"
138 fi
139 }
140
141 ### update action ###
142
143 describe_update() {
144 echo "Automatically update the pdftex version number"
145 }
146
147 describe_update_options() {
148 echo "--if-unset : Do not override currently selected version"
149 }
150
151 do_update() {
152 [[ -z "${1}" ]] || ( [[ -z "${2}" ]] && [[ "${1}" == "--if-unset" ]] ) || \
153 die -q "Usage error"
154
155 if [[ -L "${ROOT}/usr/bin/pdftex" ]] ; then
156 [[ ${1} == "--if-unset" ]] && return
157 remove_symlinks || die -q "Can't remove existing symlink"
158 fi
159 if [[ -e "${ROOT}/usr/bin/pdftex" ]] ; then
160 die -q "${ROOT}/usr/bin/pdftex seems to be from an old ebuild, please remove manually"
161 elif ! [[ -z $(find_targets ) ]] ; then
162 set_symlinks 1 || die -q "Can't set a new version"
163 fi
164 }