dev-python/structlog: add 22.1.0, drop 21.5.0
[gentoo-zh.git] / eclass / xetex-package.eclass
blobb4b2b251285ec364da92fa342850041bcb73ba29
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/xetex-package.eclass,v 1.37 2008/08/30 13:49:28 aballier Exp $
5 # @ECLASS: xetex-package.eclass
6 # @MAINTAINER:
7 # TeX team <tex@gentoo.org>
9 # Author Matthew Turk <satai@gentoo.org>
10 # Martin Ehmsen <ehmsen@gentoo.org>
11 # @BLURB: An eclass for easy installation of LaTeX packages
12 # @DESCRIPTION:
13 # This eClass is designed to be easy to use and implement. The vast majority of
14 # LaTeX packages will only need to define SRC_URI (and sometimes S) for a
15 # successful installation. If fonts need to be installed, then the variable
16 # SUPPLIER must also be defined.
18 # However, those packages that contain subdirectories must process each
19 # subdirectory individually. For example, a package that contains directories
20 # DIR1 and DIR2 must call xetex-package_src_compile() and
21 # xetex-package_src_install() in each directory, as shown here:
23 # src_compile() {
24 # cd ${S}
25 # cd DIR1
26 # xetex-package_src_compile
27 # cd ..
28 # cd DIR2
29 # xetex-package_src_compile
30 # }
32 # src_install() {
33 # cd ${S}
34 # cd DIR1
35 # xetex-package_src_install
36 # cd ..
37 # cd DIR2
38 # xetex-package_src_install
39 # }
41 # The eClass automatically takes care of rehashing TeX's cache (ls-lR) after
42 # installation and after removal, as well as creating final documentation from
43 # TeX files that come with the source. Note that we break TeX layout standards
44 # by placing documentation in /usr/share/doc/${PN}
46 # For examples of basic installations, check out dev-tex/aastex and
47 # dev-tex/leaflet .
49 # NOTE: The CTAN "directory grab" function creates files with different MD5
50 # signatures EVERY TIME. For this reason, if you are grabbing from the CTAN,
51 # you must either grab each file individually, or find a place to mirror an
52 # archive of them. (iBiblio)
54 # Use EAPI2 to make USE dependency easy to specify
55 EAPI="4"
57 # It inherits base.
59 inherit base
61 # here we check three different case for installing xetex,
62 # first is the standard texlive-2008 installation,
63 # second is suppose to be the minimal installation of texlive-xetex-2008
64 # this case is not very certain, but may work.
65 # last is the solo xetex
66 RDEPEND="|| (
67 >=app-text/texlive-2008[xetex]
69 >=dev-texlive/texlive-xetex-2008
70 >=dev-texlive/texlive-fontsrecommended-2008
71 virtual/latex-base
73 >=app-text/xetex-0.997
75 DEPEND="${RDEPEND}
76 >=sys-apps/texinfo-4.2-r5"
77 HOMEPAGE="http://www.tug.org/"
78 SRC_URI="ftp://tug.ctan.org/macros/xetex/"
79 TEXMF="/usr/share/texmf"
81 # @ECLASS-VARIABLE: SUPPLIER
82 # @DESCRIPTION:
83 # This refers to the font supplier; it should be overridden (see eclass
84 # DESCRIPTION above)
85 SUPPLIER="misc"
87 # @FUNCTION: xetex-package_has_tetex3
88 # @RETURN: true if at least one of (>=tetex-3 or >=ptex-3.1.8 or >=texlive-core-2007) is installed, else false
89 # @DESCRIPTION:
90 # It is often used to know if the current TeX installation supports gentoo's
91 # texmf-update or if the package has to do it the old way
92 xetex-package_has_tetex_3() {
93 if has_version '>=app-text/tetex-3' || has_version '>=app-text/ptex-3.1.8' || has_version '>=app-text/texlive-core-2007' ; then
94 true
95 else
96 false
100 # @FUNCTION: xetex-package_src_doinstall
101 # @USAGE: [ module ]
102 # @DESCRIPTION:
103 # [module] can be one or more of: sh, sty, cls, fd, clo, def, cfg, dvi, ps, pdf,
104 # tex, dtx, tfm, vf, afm, pfb, ttf, bst, styles, doc, fonts, bin, or all.
105 # If [module] is not given, all is assumed.
106 # It installs the files found in the current directory to the standard locations
107 # for a TeX installation
108 xetex-package_src_doinstall() {
109 debug-print function $FUNCNAME $*
110 # This actually follows the directions for a "single-user" system
111 # at http://www.ctan.org/installationadvice/ modified for gentoo.
112 [ -z "$1" ] && xetex-package_src_install all
114 while [ "$1" ]; do
115 case $1 in
116 "sh")
117 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
119 dobin $i || die "dobin $i failed"
120 done
122 "sty" | "cls" | "fd" | "clo" | "def" | "cfg")
123 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
125 insinto ${TEXMF}/tex/xetex/${PN}
126 doins $i || die "doins $i failed"
127 done
129 "dvi" | "ps" | "pdf")
130 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
132 insinto /usr/share/doc/${PF}
133 doins $i || die "doins $i failed"
134 dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/xetex/${PN}/${i}
135 #dodoc -u $i
136 done
138 "tex" | "dtx")
139 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
141 einfo "Making documentation: $i"
142 texi2dvi -q -c --language=latex $i &> /dev/null
143 done
145 "tfm" | "vf" | "afm")
146 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
148 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN}
149 doins $i || die "doins $i failed"
150 done
152 "pfb")
153 for i in `find . -maxdepth 1 -type f -name "*.pfb"`
155 insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN}
156 doins $i || die "doins $i failed"
157 done
159 "ttf")
160 for i in `find . -maxdepth 1 -type f -name "*.ttf"`
162 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN}
163 doins $i || die "doins $i failed"
164 done
166 "bst")
167 for i in `find . -maxdepth 1 -type f -name "*.bst"`
169 insinto ${TEXMF}/bibtex/bst/${PN}
170 doins $i || die "doins $i failed"
171 done
173 "styles")
174 xetex-package_src_doinstall sty cls fd clo def cfg bst
176 "doc")
177 xetex-package_src_doinstall tex dtx dvi ps pdf
179 "fonts")
180 xetex-package_src_doinstall tfm vf afm pfb ttf
182 "bin")
183 xetex-package_src_doinstall sh
185 "all")
186 xetex-package_src_doinstall styles fonts bin doc
188 esac
189 shift
190 done
193 # @FUNCTION: xetex_src_configure
194 # @DESCRIPTION:
195 # Overide base_src_configure phrase which is inherited from base.eclass
196 # ( http://rafb.net/p/HgzEoq71.html )
197 xetex-package_src_configure() {
198 einfo "Nothing to configure."
201 # @FUNCTION: xetex-package_src_compile
202 # @DESCRIPTION:
203 # Calls xetex for each *.ins in the current directory in order to generate the
204 # relevant files that will be installed
205 xetex-package_src_compile() {
206 debug-print function $FUNCNAME $*
207 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"`
209 einfo "Extracting from $i"
210 xetex --interaction=batchmode $i &> /dev/null
211 done
214 # @FUNCTION: xetex-package_src_install
215 # @DESCRIPTION:
216 # Installs the package
217 xetex-package_src_install() {
218 debug-print function $FUNCNAME $*
219 xetex-package_src_doinstall all
220 if [ -n "${DOCS}" ] ; then
221 dodoc ${DOCS}
225 # @FUNCTION: xetex-pacakge_pkg_postinst
226 # @DESCRIPTION:
227 # Calls xetex-package_rehash to ensure the TeX installation is consistent with
228 # the kpathsea database
229 xetex-package_pkg_postinst() {
230 debug-print function $FUNCNAME $*
231 xetex-package_rehash
234 # @FUNCTION: xetex-package_pkg_postrm
235 # @DESCRIPTION:
236 # Calls xetex-package_rehash to ensure the TeX installation is consistent with
237 # the kpathsea database
238 xetex-package_pkg_postrm() {
239 debug-print function $FUNCNAME $*
240 xetex-package_rehash
243 # @FUNCTION: xetex-package_rehash
244 # @DESCRIPTION:
245 # Rehashes the kpathsea database, according to the current TeX installation
246 xetex-package_rehash() {
247 debug-print function $FUNCNAME $*
248 if xetex-package_has_tetex_3 ; then
249 texmf-update
250 else
251 texconfig rehash
255 EXPORT_FUNCTIONS src_configure src_compile src_install pkg_postinst pkg_postrm