Commits

Clemens Lang authored 9d1d297ed31
dblatex: Add variant to support MacTeX

Closes: https://trac.macports.org/ticket/55106
No tags

textproc/dblatex/Portfile

Modified
1 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 2
3 3 PortSystem 1.0
4 4 PortGroup python 1.0
5 5 PortGroup texlive 1.0
6 6
7 7 name dblatex
8 8 version 0.3.10
9 +revision 1
9 10 categories textproc tex
10 -maintainers cal openmaintainer
11 +maintainers {cal @neverpanic} openmaintainer
11 12 license GPL-2+
12 13 platforms darwin
13 14 supported_archs noarch
14 15
15 16 description DocBook to LaTeX Converter
16 17 long_description Dblatex transforms a DocBook XML/SGML document to LaTeX. \
17 18 Once transformed into LaTeX, standard LaTeX tools are \
18 19 used to produce DVI, Postcript or PDF files. \
19 20 dblatex tries to hide as much as possible the latex \
20 21 compiling stuff by providing a single clean script to \
44 45 port:docbook-xsl
45 46
46 47 python.link_binaries no
47 48 python.default_version 27
48 49
49 50 # this gets assigned before python.bin is set to the version selected by the variant
50 51 #destroot.cmd ${python.bin} setup.py
51 52 destroot.destdir --root=${destroot} \
52 53 --catalogs=${destroot}${prefix}/etc/xml/catalog
53 54
55 +# The mactex variant expects MacTeX to be installed
56 +# and installs dblatex's stylefiles to MacTeX's texmf (local)
57 +set dblatex.texmflocal ""
58 +set dblatex.mactex_bin ""
59 +
60 +variant mactex description {Allow dblatex to use a MacTeX installation instead of Macports texlive tools.
61 +To install the mactex variant /Library/TeX/texbin must be added to binpath
62 +in macports.conf} {
63 + # First, check if MacTeX actually seems to be there…
64 + set dblatex.mactex_candidates { \
65 + "/Library/TeX/texbin" \
66 + "/usr/texbin" \
67 + }
68 + foreach dir ${dblatex.mactex_candidates} {
69 + if [file executable "${dir}/kpsewhich"] {
70 + set dblatex.mactex_bin ${dir}
71 + break
72 + }
73 + }
74 + if { ${dblatex.mactex_bin} != "" } {
75 + set dblatex.texmflocal \
76 + [exec ${dblatex.mactex_bin}/kpsewhich --expand-var='\$TEXMFLOCAL']
77 + regsub -all {'} ${dblatex.texmflocal} "" dblatex.texmflocal
78 + } else {
79 + return -code error "Cannot find MacTeX installation; aborting"
80 + }
81 +
82 + depends_lib-delete \
83 + port:texlive-latex-extra \
84 + port:texlive-latex-recommended \
85 + port:texlive-math-science
86 +
87 + notes "The mactex variant will install styles to MacTeX's texmf-local
88 + ${dblatex.texmflocal}
89 + (which is outside macport's common directory structure).
90 + For the mactex variant to work,
91 + ${dblatex.mactex_bin} must also be added to binpath in macports.conf"
92 +
93 + # AND, since we're installing files outside macports' normal directories
94 + destroot.violate_mtree yes
95 +}
96 +
54 97 post-destroot {
55 98 reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${python.prefix}/bin/dblatex
56 99 reinplace "s|#!/usr/bin/env python|#!${python.bin}|" ${destroot}${python.prefix}/bin/dblatex
57 100
58 101 fs-traverse f ${destroot}${python.prefix}/share {
59 102 if {[file isfile $f]} {
60 103 set f [string range $f [string length ${destroot}${python.prefix}/share/] end]
61 104 file mkdir [file dirname ${destroot}${prefix}/share/$f]
62 105 ln -s ${python.prefix}/share/$f ${destroot}${prefix}/share/$f
63 106 }
64 107 }
65 - file mkdir ${destroot}${texlive_texmflocal}/tex/latex/dblatex
108 + if {![variant_isset mactex]} {
109 + set dblatex.texmflocal ${texlive_texmflocal}
110 + }
111 + file mkdir ${destroot}${dblatex.texmflocal}/tex/latex/dblatex
66 112 fs-traverse f ${destroot}${python.prefix}/share/dblatex/latex {
67 113 if {[file isfile $f]} {
68 114 if {[catch {exec ${prefix}/bin/kpsewhich -a [file tail $f]} result]} {
69 115 set f [string range $f [string length ${destroot}${python.prefix}/share/dblatex/latex/] end]
70 - file mkdir [file dirname ${destroot}${texlive_texmflocal}/tex/latex/dblatex/$f]
71 - ln -s ${python.prefix}/share/dblatex/latex/$f ${destroot}${texlive_texmflocal}/tex/latex/dblatex/$f
116 + file mkdir [file dirname ${destroot}${dblatex.texmflocal}/tex/latex/dblatex/$f]
117 + ln -s ${python.prefix}/share/dblatex/latex/$f ${destroot}${dblatex.texmflocal}/tex/latex/dblatex/$f
72 118 }
73 119 }
74 120 }
75 121 ln -s ${python.prefix}/bin/dblatex ${destroot}${prefix}/bin/
76 122 }
77 123
124 +proc dblatex.mktexlsr {} {
125 + if {![variant_isset mactex]} {
126 + texlive.mktexlsr
127 + } else {
128 + global dblatex.mactex_bin
129 + system "${dblatex.mactex_bin}/mktexlsr"
130 + if [file exists "${dblatex.mactex_bin}/mtxrun"] {
131 + system "${dblatex.mactex_bin}/mtxrun --generate"
132 + }
133 + }
134 +}
135 +
78 136 post-activate {
79 - texlive.mktexlsr
137 + dblatex.mktexlsr
80 138 }
81 139
82 140 post-deactivate {
83 - texlive.mktexlsr
141 + dblatex.mktexlsr
84 142 }
85 143
86 144 livecheck.regex /${name}-(\[0-9.\]+)/

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut