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

# should match gimp2 version
version             2.10.38
revision            0

categories          aqua graphics
platforms           {darwin any}
license             GPL-3+

maintainers         {mcalhoun @MarcusCalhoun-Lopez} {mascguy @mascguy} openmaintainer

description         GIMP.app application bundle
long_description    {*}${description}
homepage            https://www.gimp.org/

set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        gimp:gimp/v${branch}/osx

# name has an architecture in it, but we delete architecture dependent components
distfiles           gimp-${version}-x86_64.dmg

checksums           rmd160  6aa4a24fe3c18ee4707c7eb9f92b7dce30e7c3fe \
                    sha256  cf0c79201f54b0c8978ba43806199f0d85bb0ac8db3e77f9dc4f6f4393a9d836 \
                    size    316665100

use_configure       no
supported_archs     noarch

use_dmg             yes

depends_run-append  path:bin/gimp:gimp2

patchfiles-append   patch-Info.plist.diff

post-extract {
    delete ${worksrcpath}/GIMP.app/Contents/Resources/etc
    delete ${worksrcpath}/GIMP.app/Contents/Resources/share
    delete ${worksrcpath}/GIMP.app/Contents/Resources/include
    delete ${worksrcpath}/GIMP.app/Contents/Resources/lib
    delete ${worksrcpath}/GIMP.app/Contents/Resources/libexec
    delete ${worksrcpath}/GIMP.app/Contents/Resources/Library
    delete ${worksrcpath}/GIMP.app/Contents/_CodeSignature
    delete {*}[glob ${worksrcpath}/GIMP.app/Contents/MacOS/*]
}

build {
    set script [open "${worksrcpath}/GIMP.app/Contents/MacOS/GIMP" w 0755]
    puts ${script} "#!/bin/sh"
    puts ${script} ""
    puts ${script} "exec ${prefix}/bin/gimp \"$@\""
    close ${script}
}

destroot {
    copy ${worksrcpath}/GIMP.app ${destroot}${applications_dir}
}

livecheck.url       https://download.gimp.org/pub/gimp/v2.10/osx/
livecheck.regex     {gimp-(\d+(?:\.\d+)*)-.*\.dmg}
