source: trunk/dports/_resources/port1.0/group/texlive-1.0.tcl @ 72558

Last change on this file since 72558 was 72558, checked in by ryandesign@…, 9 years ago

Portgroups: Add svn:eol-style and svn:keywords

  • Property svn:eol-style set to native
  • Property svn:eolstyle set to native
  • Property svn:keywords set to Id
File size: 13.2 KB
Line 
1# $Id: texlive-1.0.tcl 72558 2010-10-20 21:12:08Z ryandesign@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
50set 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
56set texlive_texmfdist "${prefix}/share/texmf-texlive-dist"
57
58# "local" texmf files, e.g. installed by ports other than texlive
59set texlive_texmflocal "${prefix}/share/texmf"
60
61# variable runtime data, e.g. formats
62set texlive_texmfsysvar "${prefix}/var/db/texmf"
63
64# configuration data from texconfig
65set texlive_texmfsysconfig "${prefix}/etc/texmf"
66
67# Remove dependencies on any texlive-documentation-* ports, for use by
68# -doc variants
69proc texlive.removedocdepends {} {
70    global depends_lib
71    foreach dep $depends_lib {
72        if [regexp {^port:texlive-documentation-} $dep] {
73            depends_lib-delete $dep
74        }
75    }
76}
77
78#
79# For installing texmf ports
80#
81
82# Files to skip installation of, specified in terms of their path in
83# the texmf tree, e.g. texmf-dist/foo/bar/
84options texlive.exclude
85default texlive.exclude {}
86
87# Skip installing all manpages. A number of texmf ports include
88# manpages, but many of them are already installed by texmf-bin.
89options texlive.excludemanpages
90default texlive.excludemanpages no
91
92options texlive.formats texlive.languages texlive.maps
93default texlive.formats {}
94default texlive.languages {}
95default texlive.maps {}
96
97options texlive.forceupdatecnf
98default texlive.forceupdatecnf no
99
100proc texlive.texmfport {} {
101    homepage        http://www.tug.org/texlive/
102    platforms       darwin
103   
104    supported_archs noarch
105   
106    master_sites    http://flute.csail.mit.edu/texlive/
107    use_bzip2       yes
108
109    global name master_sites
110    livecheck.type  regex
111    livecheck.url   ${master_sites}
112    livecheck.regex ${name}-(\\d+)\\.tar\\.bz2
113
114    depends_lib-append port:texlive-common port:texlive-bin
115
116    variant doc description "Install documentation" { }
117    variant src description "Install TeX source" { }
118    default_variants +doc
119
120    if {![variant_isset "doc"]} {
121        # Skip any dependencies on texlive-documentation-* ports
122        texlive.removedocdepends
123    }
124   
125    use_configure   no
126
127    build           { }
128
129    destroot {
130        set indexlist {"runfiles"}
131        if {[variant_isset "doc"]} { lappend indexlist "docfiles" }
132        if {[variant_isset "src"]} { lappend indexlist "srcfiles" }
133
134        # copy files listed in tlpkginfo/$indexname into destroot
135        foreach indexname $indexlist {           
136            set filelist [open ${worksrcpath}/tlpkginfo/${indexname}]
137            while {[gets $filelist line] >= 0} {
138                # Check if file is excluded
139                set excluded false
140                foreach excludeline ${texlive.exclude} {
141                    if {[string equal -nocase $line $excludeline]} {
142                        # file is specifically excluded
143                        set excluded true
144                        break
145                    }
146                    if {[string equal -nocase -length [expr [string length $excludeline] + 1] $line "$excludeline/"]} {
147                        # this is a file in an excluded directory
148                        set excluded true
149                        break;
150                    }
151                }
152                if {$excluded} {
153                    continue
154                }
155                   
156                set srcfile ${worksrcpath}/${indexname}/$line
157
158                # check for manpages and treat specially
159                if [regexp {^texmf/doc/man/man(\d)/([^/]+)} $line -> section filename] {
160                    if {![tbool texlive.excludemanpages]} {
161                        if [string match "*.$section" $filename] {
162                            # actually a manpage; install it
163                            copy $srcfile ${destroot}${prefix}/share/man/man$section/
164                        } else {
165                            # not actually a manpage; do nothing
166                            # (e.g. don't install PDF manpages)
167                        }
168                    }
169                } else {
170                    # not a manpage; install into requested target dir
171                    # translate path in line to destination
172                    set splitline [split $line "/"]
173                    switch [lindex $splitline 0] {
174                        "texmf"      {lset splitline 0 ${texlive_texmfmain}}
175                        "texmf-dist" {lset splitline 0 ${texlive_texmfdist}}
176                        default { ui_msg "warning: unknown file destination" }
177                    }
178                    set dstfile [join $splitline "/"]
179                   
180                    # create directory if necessary, and install file
181                    xinstall -d ${destroot}[file dirname $dstfile]
182                    copy ${srcfile} ${destroot}${dstfile}
183                }
184            }
185        }
186
187        # install a documentation file containing the list of TeX
188        # packages installed. This also ensures that each port
189        # provides at least one file, even if there's nothing to
190        # install (e.g. documentation ports with -doc)
191        xinstall -d ${destroot}${prefix}/share/doc/texlive
192        set docfile [open ${destroot}${prefix}/share/doc/texlive/${name} "w"]
193        puts $docfile "${name} version ${version} (MacPorts revision ${version}_${revision})"
194        puts $docfile "\nTeX Live packages contained in this port:"
195        set pkgfile [open ${worksrcpath}/tlpkginfo/pkgs]
196        while {[gets $pkgfile line] >= 0} {
197            set splitline [split $line]
198            set pkg [lindex $splitline 0]
199            set pkgdesc [join [lrange $splitline 1 end]]
200            puts $docfile "    $pkg: $pkgdesc"
201        }
202        close $pkgfile
203        close $docfile
204
205        # install fmtutil.cnf file
206        if {${texlive.formats} != ""} {
207            xinstall -d ${destroot}${texlive_texmfsysconfig}/fmtutil.d
208            set fmtfilename \
209                ${destroot}${texlive_texmfsysconfig}/fmtutil.d/10${name}.cnf
210            set fmtfile [open $fmtfilename "w"]
211            foreach x ${texlive.formats} {
212                set fmtenabled [lindex $x 0]
213                set fmtname [lindex $x 1]
214                set fmtengine [lindex $x 2]
215                set fmtpatterns [lindex $x 3]
216                set fmtoptions [lindex $x 4]
217                if {!$fmtenabled} {
218                    set fmtprefix "#! "
219                } else {
220                    set fmtprefix ""
221                }
222
223                puts $fmtfile \
224                    "$fmtprefix$fmtname\t$fmtengine\t$fmtpatterns\t$fmtoptions"
225
226                # Simulate texlinks
227                if {($fmtengine != $fmtname) &&
228                    ![file exists ${destroot}${prefix}/bin/$fmtname]} {
229                    ln -s ${prefix}/bin/$fmtengine \
230                        ${destroot}${prefix}/bin/$fmtname
231                }
232            }
233           
234            close $fmtfile
235        }
236
237        # install updmap.cfg file
238        if {${texlive.maps} != ""} {
239            xinstall -d ${destroot}${texlive_texmfsysconfig}/updmap.d
240            set mapfilename \
241                ${destroot}${texlive_texmfsysconfig}/updmap.d/10${name}.cfg
242            set mapfile [open $mapfilename "w"]
243            foreach x ${texlive.maps} {
244                puts $mapfile $x
245            }
246            close $mapfile
247        }
248
249        # install languages.dat and languages.def files
250        if {${texlive.languages} != ""} {
251            xinstall -d ${destroot}${texlive_texmfsysconfig}/language.d
252            set langdatfilename \
253                ${destroot}${texlive_texmfsysconfig}/language.d/10${name}.dat
254            set langdeffilename \
255                ${destroot}${texlive_texmfsysconfig}/language.d/10${name}.def
256            set langdatfile [open $langdatfilename "w"]
257            set langdeffile [open $langdeffilename "w"]
258            foreach x ${texlive.languages} {
259                set langname [lindex $x 0]
260                set langfile [lindex $x 1]
261                set langlhmin [lindex $x 2]
262                set langrhmin [lindex $x 3]
263                set langsyns [lindex $x 4]
264
265                puts $langdatfile "$langname $langfile"
266                foreach syn $langsyns {
267                    puts $langdatfile "=$syn"
268                }
269
270                foreach syn [concat $langname $langsyns] {
271                    puts $langdeffile "\\addlanguage{$syn}{$langfile}{}{$langlhmin}{$langrhmin}"
272                }
273            }
274            close $langdatfile
275            close $langdeffile
276        }
277    }
278
279    post-activate {
280        system "${prefix}/bin/mktexlsr"
281        if {${texlive.forceupdatecnf}} {
282            # If force was specified, update all the config files, and
283            # regenerate all maps and formats.
284            system "${prefix}/libexec/texlive-update-cnf language.dat"
285            system "${prefix}/libexec/texlive-update-cnf language.def"
286            system "${prefix}/libexec/texlive-update-cnf updmap.cfg"
287            system "${prefix}/libexec/texlive-update-cnf fmtutil.cnf"
288            system "${prefix}/bin/updmap-sys"
289            system "${prefix}/bin/fmtutil-sys --all"
290        } else {
291            # Otherwise, only update the config files that are
292            # actually affected, and only generate the formats that
293            # are being installed.
294            if {${texlive.languages} != ""} {
295                system "${prefix}/libexec/texlive-update-cnf language.dat"
296                system "${prefix}/libexec/texlive-update-cnf language.def"
297            }
298            if {${texlive.maps} != ""} {
299                system "${prefix}/libexec/texlive-update-cnf updmap.cfg"
300                system "${prefix}/bin/updmap-sys"
301            }
302            if {${texlive.formats} != ""} {
303                system "${prefix}/libexec/texlive-update-cnf fmtutil.cnf"
304                foreach x ${texlive.formats} {
305                    set fmtname [lindex $x 1]
306                    system "${prefix}/bin/fmtutil-sys --byfmt $fmtname"
307                }
308            }
309        }
310    }
311
312    post-deactivate {
313        # Update ls-R and any config files to reflect that the package
314        # is now gone
315        system "${prefix}/bin/mktexlsr"
316        if {${texlive.forceupdatecnf} || ${texlive.languages} != ""} {
317            system "${prefix}/libexec/texlive-update-cnf language.dat"
318            system "${prefix}/libexec/texlive-update-cnf language.def"
319        }
320        if {${texlive.forceupdatecnf} || ${texlive.maps} != ""} {
321            system "${prefix}/libexec/texlive-update-cnf updmap.cfg"
322        }
323        if {${texlive.forceupdatecnf} || ${texlive.formats} != ""} {
324            system "${prefix}/libexec/texlive-update-cnf fmtutil.cnf"
325        }
326       
327        # Remove any generated format files
328        foreach x ${texlive.formats} {
329            set fmtname [lindex $x 1]
330            set fmtengine [lindex $x 2]
331            switch $fmtengine {
332                "mf"       -
333                "mf-nowin" {set fmtengine "metafont"}
334                "mpost"    {set fmtengine "metapost"}
335            }
336           
337            foreach filename [glob -nocomplain ${texlive_texmfsysvar}/web2c/$fmtengine/$fmtname.*] {
338                delete $filename
339            }
340        }
341    }
342}
Note: See TracBrowser for help on using the repository browser.