# -*- 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

PortSystem                  1.0

name                        bbcolors
version                     1.0.1
platforms                   any
categories                  sysutils
maintainers                 {ryandesign @ryandesign}
license                     {Artistic-1 GPL}

description                 a tool for saving and loading text color \
                            preference schemes for BBEdit and TextWrangler

long_description            ${name} is {*}${description}.

homepage                    https://daringfireball.net/projects/bbcolors/
master_sites                https://daringfireball.net/projects/downloads/:main \
                            ${homepage}schemes/:schemes
use_zip                     yes

distname                    ${name}_${version}
set bell_dark_distname      {Bell Dark.bbcolors}
set gruber_dark_distname    {Gruber Dark.bbcolors}
set gruber_light_distname   {Gruber Light.bbcolors}

set bbcolors_distfile       ${distname}${extract.suffix}
set bell_dark_distfile      ${bell_dark_distname}${extract.suffix}
set gruber_dark_distfile    ${gruber_dark_distname}${extract.suffix}
set gruber_light_distfile   ${gruber_light_distname}${extract.suffix}

distfiles                   ${bbcolors_distfile}:main \
                            ${bell_dark_distfile}:schemes \
                            ${gruber_dark_distfile}:schemes \
                            ${gruber_light_distfile}:schemes

checksums                   ${bbcolors_distfile} \
                            md5     43ae9c44f0a423fcf3e6a21ed3afaec4 \
                            sha1    ce47e5ffbcafb01c21acdf242372f351215a80bf \
                            rmd160  07f7c2e2aa3fd3ba2178b749bf7ac40a2c88d6f3 \
                            ${bell_dark_distfile} \
                            md5     2fe37f9966992bc856a45318888b0889 \
                            sha1    71191b45393916d17c235505cbbf58a3fa52cdf0 \
                            rmd160  e6170b8a71b0d30340587ed12dec88fdb1e4b901 \
                            ${gruber_dark_distfile} \
                            md5     56a4942ab04fdd045f7d9093cf3a796d \
                            sha1    ffe45f7033705e26faa647fce6137e3b9f859070 \
                            rmd160  761d8217a42aaace169aa4bc70db5a50c0c3141d \
                            ${gruber_light_distfile} \
                            md5     7620dd83ab446b6282f21b8d34a99722 \
                            sha1    b98a08a6a3458e7efd110f17432def07346e6dfa \
                            rmd160  cab408c89df901f73ba345ff4c82da72efc013bf

depends_lib                 path:bin/perl:perl5

supported_archs             noarch

extract.mkdir               yes

post-extract {
    xinstall -W ${filespath} launcher ${worksrcpath}
}

patchfiles                  patch-bbcolors

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/bbcolors ${worksrcpath}/launcher
}

use_configure               no

build {
    system -W ${worksrcpath} "${prefix}/bin/pod2man bbcolors > bbcolors.1"
}

destroot {
    xinstall -d ${destroot}${prefix}/libexec/${name}
    xinstall -W ${worksrcpath} bbcolors ${destroot}${prefix}/libexec/${name}
    xinstall -W ${worksrcpath} launcher ${destroot}${prefix}/bin/bbcolors
    ln -s bbcolors ${destroot}${prefix}/bin/twcolors
    
    xinstall -W ${worksrcpath} bbcolors.1 ${destroot}${prefix}/share/man/man1
    ln -s bbcolors.1 ${destroot}${prefix}/share/man/man1/twcolors.1
    
    xinstall -d ${destroot}${prefix}/share/${name}/schemes
    xinstall -W ${worksrcpath} -m 644 \
        ${bell_dark_distname} \
        ${gruber_dark_distname} \
        ${gruber_light_distname} \
        ${destroot}${prefix}/share/${name}/schemes
}

livecheck.type              regex
livecheck.regex             ${name}_(\[0-9.\]+)${extract.suffix}