1 | # $Id: texlive-1.0.tcl 73314 2010-11-10 04:19:13Z dports@macports.org $ |
---|
2 | # |
---|
3 | # Copyright (c) 2010 Dan R. K. Ports <dports@macports.org> |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use in source and binary forms, with or without |
---|
7 | # modification, are permitted provided that the following conditions are |
---|
8 | # met: |
---|
9 | # |
---|
10 | # 1. Redistributions of source code must retain the above copyright |
---|
11 | # notice, this list of conditions and the following disclaimer. |
---|
12 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | # notice, this list of conditions and the following disclaimer in the |
---|
14 | # documentation and/or other materials provided with the distribution. |
---|
15 | # 3. Neither the name of The MacPorts Project nor the names of its |
---|
16 | # contributors may be used to endorse or promote products derived from |
---|
17 | # this software without specific prior written permission. |
---|
18 | # |
---|
19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
30 | # |
---|
31 | |
---|
32 | # |
---|
33 | # This portgroup contains common definitions for a MacPorts |
---|
34 | # installation of TeX Live. It can be used in one of two ways: |
---|
35 | # |
---|
36 | # 1. for installing "texmf ports". These contain tex files and are |
---|
37 | # installed from preprocessed distfiles made from TeXLive |
---|
38 | # packages. These ports should invoke texlive.texmfport to set up |
---|
39 | # the installation process. |
---|
40 | # |
---|
41 | # 2. other ports, like texlive-common or texlive-bin can include this |
---|
42 | # portgroup (but not call texlive.texmfport) to get texlive path |
---|
43 | # definitions and the like. |
---|
44 | |
---|
45 | # |
---|
46 | # texmf tree paths |
---|
47 | # |
---|
48 | |
---|
49 | # texmf files installed by texlive |
---|
50 | set texlive_texmfmain "${prefix}/share/texmf-texlive" |
---|
51 | |
---|
52 | # texmf files installed by texlive, but nominally distribution-independent |
---|
53 | # not clear it's really necessary to separate these from texmfmain, |
---|
54 | # but texlive goes to great effort to keep them separate, so we might as |
---|
55 | # well too |
---|
56 | set texlive_texmfdist "${prefix}/share/texmf-texlive-dist" |
---|
57 | |
---|
58 | # texmf files installed by ports other than texlive |
---|
59 | set texlive_texmfports "${prefix}/share/texmf" |
---|
60 | |
---|
61 | # optional tree for user-installed texmf files |
---|
62 | set texlive_texmflocal "${prefix}/share/texmf-local" |
---|
63 | |
---|
64 | # variable runtime data, e.g. formats |
---|
65 | set texlive_texmfsysvar "${prefix}/var/db/texmf" |
---|
66 | |
---|
67 | # configuration data from texconfig |
---|
68 | set texlive_texmfsysconfig "${prefix}/etc/texmf" |
---|
69 | |
---|
70 | # location of binaries installed by texlive-bin |
---|
71 | # |
---|
72 | # All TeXLive binaries are built by texlive-bin, but most of them |
---|
73 | # aren't usable without the support files installed by other ports: |
---|
74 | # for example, xetex needs texlive-xetex, tex4ht needs |
---|
75 | # texlive-htmlxml, and just about everything needs texlive-basic. We |
---|
76 | # don't want to install useless files into $prefix/bin, so instead |
---|
77 | # texlive-bin installs its binaries into this "hidden" directory, and |
---|
78 | # other ports "activate" them when they are ready to be used by creating |
---|
79 | # symlinks into $prefix/bin. |
---|
80 | set texlive_bindir "${prefix}/libexec/texlive/binaries" |
---|
81 | |
---|
82 | # another directory containing symlinks to activated texlive binaries |
---|
83 | # |
---|
84 | # This is provided to support MacTeX's TeX Distribution preference |
---|
85 | # pane: it can select the active TeX distribution by pointing the |
---|
86 | # /usr/texbin symlink here |
---|
87 | set texlive_mactex_texbindir "${prefix}/libexec/texlive/texbin" |
---|
88 | |
---|
89 | # Remove dependencies on any texlive-documentation-* ports, for use by |
---|
90 | # -doc variants |
---|
91 | proc texlive.removedocdepends {} { |
---|
92 | global depends_lib |
---|
93 | foreach dep $depends_lib { |
---|
94 | if [regexp {^port:texlive-documentation-} $dep] { |
---|
95 | depends_lib-delete $dep |
---|
96 | } |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|
100 | # |
---|
101 | # For installing texmf ports |
---|
102 | # |
---|
103 | |
---|
104 | # Files to skip installation of, specified in terms of their path in |
---|
105 | # the texmf tree, e.g. texmf-dist/foo/bar/ |
---|
106 | options texlive.exclude |
---|
107 | default texlive.exclude {} |
---|
108 | |
---|
109 | options texlive.binaries texlive.formats texlive.languages texlive.maps |
---|
110 | default texlive.binaries {} |
---|
111 | default texlive.formats {} |
---|
112 | default texlive.languages {} |
---|
113 | default texlive.maps {} |
---|
114 | |
---|
115 | options texlive.forceupdatecnf |
---|
116 | default texlive.forceupdatecnf no |
---|
117 | |
---|
118 | proc texlive.texmfport {} { |
---|
119 | homepage http://www.tug.org/texlive/ |
---|
120 | platforms darwin |
---|
121 | |
---|
122 | supported_archs noarch |
---|
123 | |
---|
124 | master_sites http://flute.csail.mit.edu/texlive/ |
---|
125 | use_xz yes |
---|
126 | |
---|
127 | global name master_sites |
---|
128 | livecheck.type regex |
---|
129 | livecheck.url ${master_sites} |
---|
130 | livecheck.regex ${name}-(\\d+)\\.tar |
---|
131 | |
---|
132 | depends_lib-append port:texlive-common port:texlive-bin |
---|
133 | |
---|
134 | variant doc description "Install documentation" { } |
---|
135 | variant src description "Install TeX source" { } |
---|
136 | default_variants +doc |
---|
137 | |
---|
138 | if {![variant_isset "doc"]} { |
---|
139 | # Skip any dependencies on texlive-documentation-* ports |
---|
140 | texlive.removedocdepends |
---|
141 | } |
---|
142 | |
---|
143 | use_configure no |
---|
144 | |
---|
145 | build { } |
---|
146 | |
---|
147 | destroot { |
---|
148 | xinstall -d ${destroot}${texlive_mactex_texbindir} |
---|
149 | |
---|
150 | set indexlist {"runfiles"} |
---|
151 | if {[variant_isset "doc"]} { lappend indexlist "docfiles" } |
---|
152 | if {[variant_isset "src"]} { lappend indexlist "srcfiles" } |
---|
153 | |
---|
154 | # copy files listed in tlpkginfo/$indexname into destroot |
---|
155 | foreach indexname $indexlist { |
---|
156 | set filelist [open ${worksrcpath}/tlpkginfo/${indexname}] |
---|
157 | while {[gets $filelist line] >= 0} { |
---|
158 | # Check if file is excluded |
---|
159 | set excluded false |
---|
160 | foreach excludeline ${texlive.exclude} { |
---|
161 | if {[string equal -nocase $line $excludeline]} { |
---|
162 | # file is specifically excluded |
---|
163 | set excluded true |
---|
164 | break |
---|
165 | } |
---|
166 | if {[string equal -nocase -length [expr [string length $excludeline] + 1] $line "$excludeline/"]} { |
---|
167 | # this is a file in an excluded directory |
---|
168 | set excluded true |
---|
169 | break; |
---|
170 | } |
---|
171 | } |
---|
172 | if {$excluded} { |
---|
173 | continue |
---|
174 | } |
---|
175 | |
---|
176 | set srcfile ${worksrcpath}/${indexname}/$line |
---|
177 | |
---|
178 | # check for manpages and treat specially |
---|
179 | if [regexp {^texmf/doc/man/man(\d)/([^/]+)} $line -> section filename] { |
---|
180 | if [string match "*.$section" $filename] { |
---|
181 | # actually a manpage; install it. If |
---|
182 | # texlive-bin installed a manpage with the |
---|
183 | # same name, use it instead to make sure the |
---|
184 | # documentation matches the binary. |
---|
185 | if [file exists ${texlive_bindir}/man${section}/$filename.gz] { |
---|
186 | ln -s ${texlive_bindir}/man${section}/$filename.gz \ |
---|
187 | ${destroot}${prefix}/share/man/man$section/ |
---|
188 | } else { |
---|
189 | copy $srcfile ${destroot}${prefix}/share/man/man$section/ |
---|
190 | } |
---|
191 | } else { |
---|
192 | # not actually a manpage; do nothing |
---|
193 | # (e.g. don't install PDF manpages) |
---|
194 | } |
---|
195 | } else { |
---|
196 | # not a manpage; install into requested target dir |
---|
197 | # translate path in line to destination |
---|
198 | set splitline [split $line "/"] |
---|
199 | switch [lindex $splitline 0] { |
---|
200 | "texmf" {lset splitline 0 ${texlive_texmfmain}} |
---|
201 | "texmf-dist" {lset splitline 0 ${texlive_texmfdist}} |
---|
202 | default { ui_msg "warning: unknown file destination" } |
---|
203 | } |
---|
204 | set dstfile [join $splitline "/"] |
---|
205 | |
---|
206 | # create directory if necessary, and install file |
---|
207 | xinstall -d ${destroot}[file dirname $dstfile] |
---|
208 | copy ${srcfile} ${destroot}${dstfile} |
---|
209 | } |
---|
210 | } |
---|
211 | } |
---|
212 | |
---|
213 | # create symlinks for any binaries activated by the port |
---|
214 | foreach bin ${texlive.binaries} { |
---|
215 | ui_msg "activating binary $bin" |
---|
216 | ln -s ${texlive_bindir}/$bin ${destroot}${prefix}/bin |
---|
217 | ln -s ${texlive_bindir}/$bin ${destroot}${texlive_mactex_texbindir} |
---|
218 | } |
---|
219 | |
---|
220 | # install a documentation file containing the list of TeX |
---|
221 | # packages installed. This also ensures that each port |
---|
222 | # provides at least one file, even if there's nothing to |
---|
223 | # install (e.g. documentation ports with -doc) |
---|
224 | xinstall -d ${destroot}${prefix}/share/doc/texlive |
---|
225 | set docfile [open ${destroot}${prefix}/share/doc/texlive/${name} "w"] |
---|
226 | puts $docfile "${name} version ${version} (MacPorts revision ${version}_${revision})" |
---|
227 | puts $docfile "\nTeX Live packages contained in this port:" |
---|
228 | set pkgfile [open ${worksrcpath}/tlpkginfo/pkgs] |
---|
229 | while {[gets $pkgfile line] >= 0} { |
---|
230 | set splitline [split $line] |
---|
231 | set pkg [lindex $splitline 0] |
---|
232 | set pkgdesc [join [lrange $splitline 1 end]] |
---|
233 | puts $docfile " $pkg: $pkgdesc" |
---|
234 | } |
---|
235 | close $pkgfile |
---|
236 | close $docfile |
---|
237 | |
---|
238 | # install fmtutil.cnf file |
---|
239 | if {${texlive.formats} != ""} { |
---|
240 | xinstall -d ${destroot}${texlive_texmfsysconfig}/fmtutil.d |
---|
241 | set fmtfilename \ |
---|
242 | ${destroot}${texlive_texmfsysconfig}/fmtutil.d/10${name}.cnf |
---|
243 | set fmtfile [open $fmtfilename "w"] |
---|
244 | foreach x ${texlive.formats} { |
---|
245 | set fmtenabled [lindex $x 0] |
---|
246 | set fmtname [lindex $x 1] |
---|
247 | set fmtengine [lindex $x 2] |
---|
248 | set fmtpatterns [lindex $x 3] |
---|
249 | set fmtoptions [lindex $x 4] |
---|
250 | if {!$fmtenabled} { |
---|
251 | set fmtprefix "#! " |
---|
252 | } else { |
---|
253 | set fmtprefix "" |
---|
254 | } |
---|
255 | |
---|
256 | puts $fmtfile \ |
---|
257 | "$fmtprefix$fmtname\t$fmtengine\t$fmtpatterns\t$fmtoptions" |
---|
258 | |
---|
259 | # Simulate texlinks |
---|
260 | if {($fmtengine != $fmtname) && |
---|
261 | ![file exists ${destroot}${prefix}/bin/$fmtname]} { |
---|
262 | ln -s ${prefix}/bin/$fmtengine \ |
---|
263 | ${destroot}${prefix}/bin/$fmtname |
---|
264 | ln -s ${prefix}/bin/$fmtengine \ |
---|
265 | ${destroot}${texlive_mactex_texbindir}/$fmtname |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | close $fmtfile |
---|
270 | } |
---|
271 | |
---|
272 | # install updmap.cfg file |
---|
273 | if {${texlive.maps} != ""} { |
---|
274 | xinstall -d ${destroot}${texlive_texmfsysconfig}/updmap.d |
---|
275 | set mapfilename \ |
---|
276 | ${destroot}${texlive_texmfsysconfig}/updmap.d/10${name}.cfg |
---|
277 | set mapfile [open $mapfilename "w"] |
---|
278 | foreach x ${texlive.maps} { |
---|
279 | puts $mapfile $x |
---|
280 | } |
---|
281 | close $mapfile |
---|
282 | } |
---|
283 | |
---|
284 | # install languages.dat and languages.def files |
---|
285 | if {${texlive.languages} != ""} { |
---|
286 | xinstall -d ${destroot}${texlive_texmfsysconfig}/language.d |
---|
287 | set langdatfilename \ |
---|
288 | ${destroot}${texlive_texmfsysconfig}/language.d/10${name}.dat |
---|
289 | set langdeffilename \ |
---|
290 | ${destroot}${texlive_texmfsysconfig}/language.d/10${name}.def |
---|
291 | set langdatfile [open $langdatfilename "w"] |
---|
292 | set langdeffile [open $langdeffilename "w"] |
---|
293 | foreach x ${texlive.languages} { |
---|
294 | set langname [lindex $x 0] |
---|
295 | set langfile [lindex $x 1] |
---|
296 | set langlhmin [lindex $x 2] |
---|
297 | set langrhmin [lindex $x 3] |
---|
298 | set langsyns [lindex $x 4] |
---|
299 | |
---|
300 | puts $langdatfile "$langname $langfile" |
---|
301 | foreach syn $langsyns { |
---|
302 | puts $langdatfile "=$syn" |
---|
303 | } |
---|
304 | |
---|
305 | foreach syn [concat $langname $langsyns] { |
---|
306 | puts $langdeffile "\\addlanguage{$syn}{$langfile}{}{$langlhmin}{$langrhmin}" |
---|
307 | } |
---|
308 | } |
---|
309 | close $langdatfile |
---|
310 | close $langdeffile |
---|
311 | } |
---|
312 | } |
---|
313 | |
---|
314 | post-activate { |
---|
315 | system "${texlive_bindir}/mktexlsr" |
---|
316 | if {${texlive.forceupdatecnf}} { |
---|
317 | # If force was specified, update all the config files, and |
---|
318 | # regenerate all maps and formats. |
---|
319 | system "${prefix}/libexec/texlive-update-cnf language.dat" |
---|
320 | system "${prefix}/libexec/texlive-update-cnf language.def" |
---|
321 | system "${prefix}/libexec/texlive-update-cnf updmap.cfg" |
---|
322 | system "${prefix}/libexec/texlive-update-cnf fmtutil.cnf" |
---|
323 | system "${prefix}/bin/updmap-sys" |
---|
324 | system "${prefix}/bin/fmtutil-sys --all" |
---|
325 | } else { |
---|
326 | # Otherwise, only update the config files that are |
---|
327 | # actually affected, and only generate the formats that |
---|
328 | # are being installed. |
---|
329 | if {${texlive.languages} != ""} { |
---|
330 | system "${prefix}/libexec/texlive-update-cnf language.dat" |
---|
331 | system "${prefix}/libexec/texlive-update-cnf language.def" |
---|
332 | } |
---|
333 | if {${texlive.maps} != ""} { |
---|
334 | system "${prefix}/libexec/texlive-update-cnf updmap.cfg" |
---|
335 | system "${prefix}/bin/updmap-sys" |
---|
336 | } |
---|
337 | if {${texlive.formats} != ""} { |
---|
338 | system "${prefix}/libexec/texlive-update-cnf fmtutil.cnf" |
---|
339 | foreach x ${texlive.formats} { |
---|
340 | set fmtname [lindex $x 1] |
---|
341 | system "${prefix}/bin/fmtutil-sys --byfmt $fmtname" |
---|
342 | } |
---|
343 | } |
---|
344 | } |
---|
345 | } |
---|
346 | |
---|
347 | post-deactivate { |
---|
348 | # Update ls-R and any config files to reflect that the package |
---|
349 | # is now gone |
---|
350 | system "${texlive_bindir}/mktexlsr" |
---|
351 | if {${texlive.forceupdatecnf} || ${texlive.languages} != ""} { |
---|
352 | system "${prefix}/libexec/texlive-update-cnf language.dat" |
---|
353 | system "${prefix}/libexec/texlive-update-cnf language.def" |
---|
354 | } |
---|
355 | if {${texlive.forceupdatecnf} || ${texlive.maps} != ""} { |
---|
356 | system "${prefix}/libexec/texlive-update-cnf updmap.cfg" |
---|
357 | } |
---|
358 | if {${texlive.forceupdatecnf} || ${texlive.formats} != ""} { |
---|
359 | system "${prefix}/libexec/texlive-update-cnf fmtutil.cnf" |
---|
360 | } |
---|
361 | |
---|
362 | # Remove any generated format files |
---|
363 | foreach x ${texlive.formats} { |
---|
364 | set fmtname [lindex $x 1] |
---|
365 | set fmtengine [lindex $x 2] |
---|
366 | switch $fmtengine { |
---|
367 | "mf" - |
---|
368 | "mf-nowin" {set fmtengine "metafont"} |
---|
369 | "mpost" {set fmtengine "metapost"} |
---|
370 | } |
---|
371 | |
---|
372 | foreach filename [glob -nocomplain ${texlive_texmfsysvar}/web2c/$fmtengine/$fmtname.*] { |
---|
373 | delete $filename |
---|
374 | } |
---|
375 | } |
---|
376 | } |
---|
377 | } |
---|