Ticket #61530: Portfile

File Portfile, 6.6 KB (added by ballapete (Peter "Pete" Dyballa), 3 years ago)

Possible Portfile to build dblatex @0.3.12pre1

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2
3PortSystem          1.0
4PortGroup           python 1.0
5PortGroup           texlive 1.0
6
7name                dblatex
8version             0.3.12pre1
9distname            ${name}3-${version}
10revision            0
11categories          textproc tex
12maintainers         {cal @neverpanic} openmaintainer
13license             GPL-2+
14platforms           darwin
15supported_archs     noarch
16
17description         DocBook to LaTeX Converter
18long_description    Dblatex transforms a DocBook XML/SGML document to LaTeX. \
19                    Once transformed into LaTeX, standard LaTeX tools are \
20                    used to produce DVI, Postcript or PDF files. \
21                    dblatex tries to hide as much as possible the latex \
22                    compiling stuff by providing a single clean script to \
23                    produce directly DVI, PostScript and PDF output. \
24                    The actual output rendering is done not only by the \
25                    XSL stylesheets transformation, but also by a dedicated \
26                    LaTeX package. The goal is to allow a deep LaTeX \
27                    customisation without changing the XSL stylesheets. \
28                    Post-processing is done by Python, to make publication \
29                    faster, convert the images if needed, and do the whole \
30                    compilation.
31
32homepage            http://dblatex.sourceforge.net
33master_sites        sourceforge:project/dblatex/dblatex/${name}3-${version}
34
35checksums           sha256  497aae48af99a6b7baadc1207d8575c5a8b3633e3f21cbf437ff8443414573f0 \
36                    rmd160  5abdec82b79a05aea6f25cf1ac04b1275a442f04 \
37                    size    1695197
38
39use_bzip2           yes
40
41depends_lib         port:texlive-latex-extra \
42                    port:texlive-latex-recommended \
43                    port:texlive-math-science \
44                    port:dejavu-fonts \
45                    port:ImageMagick \
46                    port:docbook-xml \
47                    port:docbook-xsl-nons
48
49python.link_binaries no
50python.default_version 38
51
52default destroot.cmd {${python.bin} setup.py}
53destroot.destdir    --root=${destroot} \
54                    --catalogs=${destroot}${prefix}/etc/xml/catalog
55
56# The mactex variant expects MacTeX to be installed
57# and installs dblatex's stylefiles to MacTeX's texmf (local)
58set dblatex.texmflocal ""
59set dblatex.mactex_bin ""
60set dblatex.temp       ""
61
62variant mactex description {Allow dblatex to use MacTeX or another\
63    external TeXLive installation instead of MacPorts TeXLive tools.\
64    To install the 'mactex' variant the path to the TeX distribution's\
65    binary directory (for example '/Library/TeX/texbin') must be added\
66    to 'binpath' in 'macports.conf' *before* installing this port.} {
67
68    # Find the binary directory of the external TeX distribution by
69    # searching the kpsewhich program in the path.  We assume that all
70    # other binaries of the distribution are in this directory, too.
71    if {[auto_execok kpsewhich] ne ""} {
72        set dblatex.temp {*}[auto_execok kpsewhich]
73    }
74    set dblatex.mactex_bin \
75        [file dirname [file normalize ${dblatex.temp}]]
76    if {${dblatex.mactex_bin} eq "."} {
77        pre-fetch {
78            return -code error "Cannot find MacTeX or external TeXLive\
79                installation; aborting.  Have you added the path to\
80                your TeX distribution's binary directory to 'binpath'\
81                in 'macports.conf'?"
82        }
83    } elseif {${dblatex.mactex_bin} eq \
84                  [file dirname [file normalize "${prefix}/bin/kpsewhich"]]} {
85        pre-fetch {
86            return -code error "Variant 'mactex' doesn't work with\
87                installed MacPorts TeXLive packages.  Either\
88                uninstall them or don't use the 'mactex' variant of\
89                dblatex."
90        }
91    } else {
92        set dblatex.texmflocal \
93            [exec ${dblatex.mactex_bin}/kpsewhich --expand-var='\$TEXMFLOCAL']
94        regsub -all {'} ${dblatex.texmflocal} "" dblatex.texmflocal
95    }
96
97    # Make 'port notes dblatex +mactex' work even if neither the package
98    # nor an external TeXLive is installed.
99    if {${dblatex.texmflocal} eq ""} {
100        notes "The 'mactex' variant will install styles into your\
101            TeXLive's texmf-local tree (which is outside MacPorts'\
102            common directory structure)."
103    } else {
104        notes "\
105The 'mactex' variant will install styles into your TeXLive's texmf-local\
106tree at
107
108    ${dblatex.texmflocal}
109
110(which is outside MacPorts' common directory structure)."
111    }
112
113    depends_lib-delete \
114                    port:texlive-latex-extra \
115                    port:texlive-latex-recommended \
116                    port:texlive-math-science
117
118    # AND, since we're installing files outside MacPorts' normal
119    # directories...
120    destroot.violate_mtree  yes
121}
122
123post-destroot {
124    reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${python.prefix}/bin/dblatex
125    reinplace "s|#!/usr/bin/env python|#!${python.bin}|" ${destroot}${python.prefix}/bin/dblatex
126
127    fs-traverse f ${destroot}${python.prefix}/share {
128        if {[file isfile $f]} {
129            set f [string range $f [string length ${destroot}${python.prefix}/share/] end]
130            file mkdir [file dirname ${destroot}${prefix}/share/$f]
131            ln -s ${python.prefix}/share/$f ${destroot}${prefix}/share/$f
132        }
133    }
134    if {![variant_isset mactex]} {
135        set dblatex.texmflocal ${texlive_texmflocal}
136        set dblatex.bin ${prefix}/bin
137    } else {
138        set dblatex.bin ${dblatex.mactex_bin}
139    }
140    file mkdir ${destroot}${dblatex.texmflocal}/tex/latex/dblatex
141    fs-traverse f ${destroot}${python.prefix}/share/dblatex/latex {
142        if {[file isfile $f]} {
143            if {[catch {exec ${dblatex.bin}/kpsewhich -a [file tail $f]} result]} {
144                set f [string range $f [string length ${destroot}${python.prefix}/share/dblatex/latex/] end]
145                file mkdir [file dirname ${destroot}${dblatex.texmflocal}/tex/latex/dblatex/$f]
146                ln -s ${python.prefix}/share/dblatex/latex/$f ${destroot}${dblatex.texmflocal}/tex/latex/dblatex/$f
147            }
148        }
149    }
150    ln -s ${python.prefix}/bin/dblatex ${destroot}${prefix}/bin/
151}
152
153proc dblatex.mktexlsr {} {
154    if {![variant_isset mactex]} {
155        texlive.mktexlsr
156    } else {
157        global dblatex.mactex_bin
158        system "${dblatex.mactex_bin}/mktexlsr"
159    }
160}
161
162post-activate {
163    dblatex.mktexlsr
164}
165
166post-deactivate {
167    dblatex.mktexlsr
168}
169
170livecheck.regex     /${name}-(\[0-9.\]+)/