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

Diff of /eclass/texlive-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20