/[gentoo-x86]/eclass/texlive-module.eclass
Gentoo

Contents of /eclass/texlive-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (show annotations) (download)
Tue Sep 2 10:00:06 2008 UTC (5 years, 11 months ago) by aballier
Branch: MAIN
Changes since 1.17: +7 -1 lines
document TEXLIVE_MODULE_BINSCRIPTS

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

  ViewVC Help
Powered by ViewVC 1.1.20