1 |
aballier |
1.8 |
# Copyright 1999-2008 Gentoo Foundation |
2 |
aballier |
1.1 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
aballier |
1.16 |
# $Header: /var/cvsroot/gentoo-x86/eclass/texlive-module.eclass,v 1.15 2008/08/22 11:31:40 aballier Exp $ |
4 |
aballier |
1.1 |
|
5 |
aballier |
1.8 |
# @ECLASS: texlive-module.eclass |
6 |
|
|
# @MAINTAINER: |
7 |
|
|
# tex@gentoo.org |
8 |
aballier |
1.1 |
# |
9 |
|
|
# Original Author: Alexis Ballier <aballier@gentoo.org> |
10 |
aballier |
1.8 |
# @BLURB: Provide generic install functions so that modular texlive's texmf ebuild will only have to inherit this eclass |
11 |
aballier |
1.15 |
# @DESCRIPTION: |
12 |
aballier |
1.1 |
# Purpose: Provide generic install functions so that modular texlive's texmf ebuilds will |
13 |
|
|
# only have to inherit this eclass. |
14 |
|
|
# Ebuilds have to provide TEXLIVE_MODULE_CONTENTS variable that contains the list |
15 |
aballier |
1.8 |
# of packages that it will install. (See below) |
16 |
|
|
# |
17 |
aballier |
1.1 |
# What is assumed is that it unpacks texmf and texmf-dist directories to |
18 |
|
|
# ${WORKDIR}. |
19 |
|
|
# |
20 |
aballier |
1.8 |
# It inherits texlive-common |
21 |
|
|
|
22 |
|
|
# @ECLASS-VARIABLE: TEXLIVE_MODULE_CONTENTS |
23 |
|
|
# @DESCRIPTION: |
24 |
|
|
# The list of packages that will be installed. This variable will be expanded to |
25 |
|
|
# SRC_URI: |
26 |
|
|
# |
27 |
aballier |
1.11 |
# For TeX Live 2007: foo -> texlive-module-foo-${PV}.zip |
28 |
|
|
# For TeX Live 2008: foo -> texlive-module-foo-${PV}.tar.lzma |
29 |
aballier |
1.1 |
|
30 |
aballier |
1.13 |
# @ECLASS-VARIABLE: TEXLIVE_MODULE_DOC_CONTENTS |
31 |
|
|
# @DESCRIPTION: |
32 |
|
|
# The list of packages that will be installed if the doc useflag is enabled. |
33 |
|
|
# Expansion to SRC_URI is the same as for TEXLIVE_MODULE_CONTENTS. This is only |
34 |
|
|
# valid for TeX Live 2008 |
35 |
|
|
|
36 |
|
|
# @ECLASS-VARIABLE: TEXLIVE_MODULE_SRC_CONTENTS |
37 |
|
|
# @DESCRIPTION: |
38 |
|
|
# The list of packages that will be installed if the source useflag is enabled. |
39 |
|
|
# Expansion to SRC_URI is the same as for TEXLIVE_MODULE_CONTENTS. This is only |
40 |
|
|
# valid for TeX Live 2008 |
41 |
|
|
|
42 |
aballier |
1.1 |
inherit texlive-common |
43 |
|
|
|
44 |
|
|
HOMEPAGE="http://www.tug.org/texlive/" |
45 |
|
|
|
46 |
aballier |
1.9 |
COMMON_DEPEND=">=app-text/texlive-core-${PV} |
47 |
|
|
${TEXLIVE_MODULES_DEPS}" |
48 |
|
|
|
49 |
aballier |
1.12 |
IUSE="" |
50 |
|
|
|
51 |
aballier |
1.9 |
# TeX Live 2007 was providing .zip files of CTAN packages. For 2008 they are now |
52 |
|
|
# .tar.lzma |
53 |
|
|
if [ -z "${PV##2007*}" ] ; then |
54 |
aballier |
1.1 |
for i in ${TEXLIVE_MODULE_CONTENTS}; do |
55 |
|
|
SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.zip" |
56 |
|
|
done |
57 |
|
|
DEPEND="${COMMON_DEPEND} |
58 |
|
|
app-arch/unzip" |
59 |
aballier |
1.9 |
else |
60 |
|
|
for i in ${TEXLIVE_MODULE_CONTENTS}; do |
61 |
|
|
SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.tar.lzma" |
62 |
|
|
done |
63 |
|
|
DEPEND="${COMMON_DEPEND} |
64 |
|
|
app-arch/lzma-utils" |
65 |
aballier |
1.12 |
IUSE="${IUSE} source" |
66 |
aballier |
1.13 |
|
67 |
|
|
# Forge doc SRC_URI |
68 |
|
|
[ -n "${PN##*documentation*}" ] && [ -n "${TEXLIVE_MODULE_DOC_CONTENTS}" ] && SRC_URI="${SRC_URI} doc? (" |
69 |
|
|
for i in ${TEXLIVE_MODULE_DOC_CONTENTS}; do |
70 |
|
|
SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.tar.lzma" |
71 |
|
|
done |
72 |
|
|
[ -n "${PN##*documentation*}" ] && [ -n "${TEXLIVE_MODULE_DOC_CONTENTS}" ] && SRC_URI="${SRC_URI} )" |
73 |
|
|
|
74 |
|
|
# Forge source SRC_URI |
75 |
|
|
if [ -n "${TEXLIVE_MODULE_SRC_CONTENTS}" ] ; then |
76 |
|
|
SRC_URI="${SRC_URI} source? (" |
77 |
|
|
for i in ${TEXLIVE_MODULE_SRC_CONTENTS}; do |
78 |
|
|
SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.tar.lzma" |
79 |
|
|
done |
80 |
|
|
SRC_URI="${SRC_URI} )" |
81 |
|
|
fi |
82 |
aballier |
1.9 |
fi |
83 |
aballier |
1.1 |
|
84 |
|
|
RDEPEND="${COMMON_DEPEND}" |
85 |
|
|
|
86 |
aballier |
1.12 |
[ -z "${PN##*documentation*}" ] || IUSE="${IUSE} doc" |
87 |
aballier |
1.1 |
|
88 |
|
|
S="${WORKDIR}" |
89 |
|
|
|
90 |
aballier |
1.15 |
|
91 |
|
|
# @FUNCTION: texlive-module_make_language_def_lines |
92 |
|
|
# @DESCRIPTION: |
93 |
|
|
# Only valid for TeXLive 2008. |
94 |
aballier |
1.16 |
# Creates a language.${PN}.def entry to put in /etc/texmf/language.def.d |
95 |
aballier |
1.15 |
# It parses the AddHyphen directive of tlpobj files to create it. |
96 |
|
|
|
97 |
|
|
texlive-module_make_language_def_lines() { |
98 |
|
|
local lefthyphenmin righthyphenmin synonyms name file |
99 |
|
|
eval $@ |
100 |
|
|
einfo "Generating language.def entry for $@" |
101 |
|
|
[ -z "$lefthyphenmin" ] && lefthyphenmin="2" |
102 |
|
|
[ -z "$righthyphenmin" ] && righthyphenmin="3" |
103 |
|
|
echo "\\addlanguage{$name}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" |
104 |
|
|
if [ -n "$synonyms" ] ; then |
105 |
|
|
for i in $(echo $synonyms | tr ',' ' ') ; do |
106 |
|
|
einfo "Generating language.def synonym $i for $@" |
107 |
|
|
echo "\\addlanguage{$i}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" |
108 |
|
|
done |
109 |
|
|
fi |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
# @FUNCTION: texlive-module_make_language_dat_lines |
113 |
|
|
# @DESCRIPTION: |
114 |
|
|
# Only valid for TeXLive 2008. |
115 |
aballier |
1.16 |
# Creates a language.${PN}.dat entry to put in /etc/texmf/language.dat.d |
116 |
aballier |
1.15 |
# It parses the AddHyphen directive of tlpobj files to create it. |
117 |
|
|
|
118 |
|
|
texlive-module_make_language_dat_lines() { |
119 |
|
|
local lefthyphenmin righthyphenmin synonyms name file |
120 |
|
|
eval $@ |
121 |
|
|
einfo "Generating language.dat entry for $@" |
122 |
|
|
echo "$name $file" >> "${S}/language.${PN}.dat" |
123 |
|
|
if [ -n "$synonyms" ] ; then |
124 |
|
|
for i in $(echo $synonyms | tr ',' ' ') ; do |
125 |
|
|
einfo "Generating language.dat synonym $i for $@" |
126 |
|
|
echo "=$i" >> "${S}/language.${PN}.dat" |
127 |
|
|
done |
128 |
|
|
fi |
129 |
|
|
} |
130 |
|
|
|
131 |
aballier |
1.8 |
# @FUNCTION: texlive-module_src_compile |
132 |
|
|
# @DESCRIPTION: |
133 |
|
|
# exported function: |
134 |
aballier |
1.1 |
# Will look for format.foo.cnf and build foo format files using fmtutil |
135 |
|
|
# (provided by texlive-core). The compiled format files will be sent to |
136 |
|
|
# texmf-var/web2c, like fmtutil defaults to but with some trick to stay in the |
137 |
|
|
# sandbox |
138 |
|
|
# The next step is to generate config files that are to be installed in |
139 |
|
|
# /etc/texmf; texmf-update script will take care of merging the different config |
140 |
|
|
# files for different packages in a single one used by the whole tex installation. |
141 |
|
|
|
142 |
|
|
texlive-module_src_compile() { |
143 |
|
|
# Build format files |
144 |
|
|
for i in texmf/fmtutil/format*.cnf; do |
145 |
|
|
if [ -f "${i}" ]; then |
146 |
|
|
einfo "Building format ${i}" |
147 |
|
|
TEXMFHOME="${S}/texmf:${S}/texmf-dist"\ |
148 |
|
|
fmtutil --cnffile "${i}" --fmtdir "${S}/texmf-var/web2c" --all\ |
149 |
|
|
|| die "failed to build format ${i}" |
150 |
|
|
fi |
151 |
|
|
done |
152 |
|
|
|
153 |
|
|
# Generate config files |
154 |
aballier |
1.9 |
# TeX Live 2007 was providing lists. For 2008 they are now tlpobj. |
155 |
|
|
if [ -z "${PV##2007*}" ] ; then |
156 |
aballier |
1.1 |
for i in "${S}"/texmf/lists/*; |
157 |
|
|
do |
158 |
aballier |
1.9 |
grep '^!' "${i}" | sed -e 's/^!//' | tr ' ' '@' |sort|uniq >> "${T}/jobs" |
159 |
aballier |
1.1 |
done |
160 |
aballier |
1.9 |
else |
161 |
|
|
for i in "${S}"/tlpkg/tlpobj/*; |
162 |
|
|
do |
163 |
|
|
grep '^execute ' "${i}" | sed -e 's/^execute //' | tr ' ' '@' |sort|uniq >> "${T}/jobs" |
164 |
|
|
done |
165 |
|
|
fi |
166 |
aballier |
1.1 |
|
167 |
aballier |
1.9 |
for i in $(<"${T}/jobs"); |
168 |
aballier |
1.1 |
do |
169 |
aballier |
1.9 |
j="$(echo $i | tr '@' ' ')" |
170 |
|
|
command=${j%% *} |
171 |
|
|
parameter=${j#* } |
172 |
aballier |
1.1 |
case "${command}" in |
173 |
|
|
addMap) |
174 |
|
|
echo "Map ${parameter}" >> "${S}/${PN}.cfg";; |
175 |
|
|
addMixedMap) |
176 |
|
|
echo "MixedMap ${parameter}" >> "${S}/${PN}.cfg";; |
177 |
|
|
addDvipsMap) |
178 |
|
|
echo "p +${parameter}" >> "${S}/${PN}-config.ps";; |
179 |
|
|
addDvipdfmMap) |
180 |
|
|
echo "f ${parameter}" >> "${S}/${PN}-config";; |
181 |
aballier |
1.9 |
AddHyphen) |
182 |
aballier |
1.15 |
texlive-module_make_language_def_lines "$parameter" |
183 |
|
|
texlive-module_make_language_dat_lines "$parameter";; |
184 |
aballier |
1.9 |
BuildFormat) |
185 |
aballier |
1.14 |
einfo "Format $parameter already built.";; |
186 |
aballier |
1.9 |
BuildLanguageDat) |
187 |
aballier |
1.14 |
einfo "Language file $parameter already generated.";; |
188 |
aballier |
1.9 |
*) |
189 |
|
|
die "No rule to proccess ${command}. Please file a bug." |
190 |
aballier |
1.1 |
esac |
191 |
|
|
done |
192 |
|
|
} |
193 |
|
|
|
194 |
aballier |
1.8 |
# @FUNCTION: texlive-module_src_install |
195 |
|
|
# @DESCRIPTION: |
196 |
|
|
# exported function: |
197 |
aballier |
1.1 |
# Install texmf and config files to the system |
198 |
|
|
|
199 |
|
|
texlive-module_src_install() { |
200 |
aballier |
1.3 |
for i in texmf/fmtutil/format*.cnf; do |
201 |
|
|
[ -f "${i}" ] && etexlinks "${i}" |
202 |
|
|
done |
203 |
|
|
|
204 |
aballier |
1.1 |
insinto /usr/share |
205 |
aballier |
1.10 |
if [ -z "${PN##*documentation*}" ] || use doc; then |
206 |
aballier |
1.4 |
[ -d texmf-doc ] && doins -r texmf-doc |
207 |
|
|
else |
208 |
|
|
[ -d texmf/doc ] && rm -rf texmf/doc |
209 |
|
|
[ -d texmf-dist/doc ] && rm -rf texmf-dist/doc |
210 |
|
|
fi |
211 |
|
|
|
212 |
aballier |
1.1 |
[ -d texmf ] && doins -r texmf |
213 |
|
|
[ -d texmf-dist ] && doins -r texmf-dist |
214 |
aballier |
1.12 |
[ -n "${PV##2007*}" ] && [ -d tlpkg ] && use source && doins -r tlpkg |
215 |
aballier |
1.4 |
|
216 |
aballier |
1.5 |
insinto /var/lib/texmf |
217 |
aballier |
1.2 |
[ -d texmf-var ] && doins -r texmf-var/* |
218 |
aballier |
1.1 |
|
219 |
|
|
insinto /etc/texmf/updmap.d |
220 |
|
|
[ -f "${S}/${PN}.cfg" ] && doins "${S}/${PN}.cfg" |
221 |
aballier |
1.6 |
insinto /etc/texmf/dvips.d |
222 |
aballier |
1.1 |
[ -f "${S}/${PN}-config.ps" ] && doins "${S}/${PN}-config.ps" |
223 |
|
|
insinto /etc/texmf/dvipdfm/config |
224 |
|
|
[ -f "${S}/${PN}-config" ] && doins "${S}/${PN}-config" |
225 |
|
|
|
226 |
aballier |
1.15 |
if [ -f "${S}/language.${PN}.def" ] ; then |
227 |
|
|
insinto /etc/texmf/language.def.d |
228 |
|
|
doins "${S}/language.${PN}.def" |
229 |
|
|
fi |
230 |
|
|
|
231 |
|
|
if [ -f "${S}/language.${PN}.dat" ] ; then |
232 |
|
|
insinto /etc/texmf/language.dat.d |
233 |
|
|
doins "${S}/language.${PN}.dat" |
234 |
|
|
fi |
235 |
|
|
|
236 |
aballier |
1.1 |
texlive-common_handle_config_files |
237 |
|
|
} |
238 |
|
|
|
239 |
aballier |
1.8 |
# @FUNCTION: texlive-module_pkg_postinst |
240 |
|
|
# @DESCRIPTION: |
241 |
|
|
# exported function: |
242 |
aballier |
1.1 |
# run texmf-update to ensure the tex installation is consistent with the |
243 |
|
|
# installed texmf trees. |
244 |
|
|
|
245 |
|
|
texlive-module_pkg_postinst() { |
246 |
aballier |
1.7 |
if [ "$ROOT" = "/" ] && [ -x /usr/sbin/texmf-update ] ; then |
247 |
aballier |
1.1 |
/usr/sbin/texmf-update |
248 |
aballier |
1.7 |
else |
249 |
|
|
ewarn "Cannot run texmf-update for some reason." |
250 |
|
|
ewarn "Your texmf tree might be inconsistent with your configuration" |
251 |
|
|
ewarn "Please try to figure what has happened" |
252 |
aballier |
1.1 |
fi |
253 |
|
|
} |
254 |
|
|
|
255 |
aballier |
1.8 |
# @FUNCTION: texlive-module_pkg_postrm |
256 |
|
|
# @DESCRIPTION: |
257 |
|
|
# exported function: |
258 |
|
|
# run texmf-update to ensure the tex installation is consistent with the |
259 |
|
|
# installed texmf trees. |
260 |
|
|
|
261 |
aballier |
1.1 |
texlive-module_pkg_postrm() { |
262 |
aballier |
1.7 |
if [ "$ROOT" = "/" ] && [ -x /usr/sbin/texmf-update ] ; then |
263 |
aballier |
1.1 |
/usr/sbin/texmf-update |
264 |
aballier |
1.7 |
else |
265 |
|
|
ewarn "Cannot run texmf-update for some reason." |
266 |
|
|
ewarn "Your texmf tree might be inconsistent with your configuration" |
267 |
|
|
ewarn "Please try to figure what has happened" |
268 |
aballier |
1.1 |
fi |
269 |
|
|
} |
270 |
|
|
|
271 |
|
|
EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |