Ticket #55106: dblatex-0.3.10-mactex.diff

File dblatex-0.3.10-mactex.diff, 3.8 KB (added by nortcele, 7 years ago)

Patch to add a +mactex variant

  • Portfile

    old new  
    66
    77name                dblatex
    88version             0.3.10
     9revision            1
    910categories          textproc tex
    1011maintainers         cal openmaintainer
    1112license             GPL-2+
     
    5152destroot.destdir    --root=${destroot} \
    5253                    --catalogs=${destroot}${prefix}/etc/xml/catalog
    5354
     55# The mactex variant expects MacTeX to be installed
     56# and installs dblatex's stylefiles to MacTeX's texmf (local)
     57set dblatex.texmflocal ""
     58set dblatex.mactex_bin ""
     59
     60variant mactex description {Allow dblatex to use a MacTeX installation instead of Macports texlive tools.
     61To install the mactex variant /Library/TeX/texbin must be added to binpath
     62in 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
    5497post-destroot {
    5598    reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${python.prefix}/bin/dblatex
    5699    reinplace "s|#!/usr/bin/env python|#!${python.bin}|" ${destroot}${python.prefix}/bin/dblatex
     
    62105            ln -s ${python.prefix}/share/$f ${destroot}${prefix}/share/$f
    63106        }
    64107    }
    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
    66112    fs-traverse f ${destroot}${python.prefix}/share/dblatex/latex {
    67113        if {[file isfile $f]} {
    68114            if {[catch {exec ${prefix}/bin/kpsewhich -a [file tail $f]} result]} {
    69115                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
    72118            }
    73119        }
    74120    }
    75121    ln -s ${python.prefix}/bin/dblatex ${destroot}${prefix}/bin/
    76122}
    77123
     124proc 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
    78136post-activate {
    79     texlive.mktexlsr
     137    dblatex.mktexlsr
    80138}
    81139
    82140post-deactivate {
    83     texlive.mktexlsr
     141    dblatex.mktexlsr
    84142}
    85143
    86144livecheck.regex     /${name}-(\[0-9.\]+)/