# -*- 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
PortGroup               xcode 1.0

# The future home of CronniX is expected to be
# https://github.com/finestructure/cronnix

name                    CronniX
version                 3.0.2
revision                1
checksums               rmd160  a5627dff5b6cb854b373889a2beaf3da49d19aa6 \
                        sha256  5a2c43aede9afc52c9628863f852009e28dc10c2c2526a5ca1f3a3eb89620dc7 \
                        size    724168

categories              aqua
maintainers             {ryandesign @ryandesign}
license                 GPL-3
homepage                https://code.google.com/p/cronnix/
xcode.target            ${name}

svn.revision            83
master_sites            http://www.ryandesign.com/macports/distfiles/${name}
distname                cronnix-r${svn.revision}
use_bzip2               yes

description \
    graphical frontend for scheduling cronjobs

long_description \
    ${name} is a macOS frontend to the Unix scheduler cron. Cron is a \
    system service that allows scheduled execution of scripts and programs.

patchfiles              InfoPlist.strings.utf8.patch \
                        Localizable.strings.utf8.patch \
                        French.patch \
                        html.utf8.patch \
                        super-dealloc.patch

post-configure {
    # Convert from utf-16 to utf-8.
    foreach lang [list Catalan Danish Dutch French Italian Japanese Spanish Welsh] {
        set strings ${worksrcpath}/${lang}.lproj/Localizable.strings
        move ${strings} ${strings}.orig
        system "< [shellescape ${strings}.orig] iconv -f utf-16 -t utf-8 > [shellescape ${strings}]"
    }
    # Convert from corrupted utf-16/8-bit mix to utf-8.
    foreach {lang charset} [list English ascii German iso-8859-1 Swedish macroman] {
        set strings ${worksrcpath}/${lang}.lproj/Localizable.strings
        move ${strings} ${strings}.orig
        system "< [shellescape ${strings}.orig] LC_CTYPE=C tr -d '\\000' | LC_CTYPE=C awk 'NR==1{sub(/^\\xfe\\xff/,\"\")}1' | iconv -f [shellescape ${charset}] -t utf-8 > [shellescape ${strings}]"
    }
    # Convert Mac to Unix line endings.
    foreach lang [list Danish] {
        set strings ${worksrcpath}/${lang}.lproj/Localizable.strings
        move ${strings} ${strings}.temp
        system "< [shellescape ${strings}.temp] tr '\\r' '\\n' > [shellescape ${strings}]"
    }
    # Fix syntax errors.
    system -W ${worksrcpath} "patch -p0 < [shellescape ${filespath}/Localizable.strings.syntax.patch]"
}

if {[vercmp ${xcodeversion} >= 10.0] && [vercmp ${xcodeversion} < 11.0]} {
    build.pre_args      -UseNewBuildSystem=NO
    destroot.pre_args   -UseNewBuildSystem=NO
}

post-destroot {
    fs-traverse dir ${destroot} {
        if {[file isdirectory ${dir}]} {
            file attributes ${dir} -permissions u+w
        }
    }
}

livecheck.type          none
