# -*- 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
# $Id: Portfile 117339 2014-02-22 21:47:41Z macsforever2000@macports.org $

PortSystem          1.0
PortGroup           app 1.0

name                hdhomerun_gui
version             20140121
categories          multimedia
platforms           darwin
license             GPL-3
maintainers         nomaintainer
description         HDHomeRun configuration utility, GTK GUI
long_description    Provides a utility program to access, configure and test \
                    HDHomeRun network tuner devices from SiliconDust including viewing \
                    live television.  May also be used to upgrade firmware.  Uses GTK \
                    graphical environment.
homepage            http://www.silicondust.com/

master_sites        http://download.silicondust.com/hdhomerun
distname            hdhomerun_config_gui_${version}
patchfiles          patch-libhdhomerun.diff \
                    patch-firmware_path.diff \
                    patch-missing_frameworks.diff
patch.args          -p1
extract.suffix      .tgz
worksrcdir          hdhomerun_config_gui
checksums           rmd160  1647563fee263f150cc52018c26c33199818946c \
                    sha256  56575484578ce5a116a20e342969e41d60ad7db1212eb8c21ed134f14b6efd99

livecheck.type      regex
livecheck.url       http://www.silicondust.com/support/hdhomerun/downloads/
livecheck.regex     Current release: (\[0-9\]+)

depends_build       port:pkgconfig
depends_lib         port:hdhomerun port:gtk2
depends_run         port:VLC \
                    path:bin/Xquartz:xorg-server

post-patch {
    reinplace "s|@FIRMWARE_DIR@|${prefix}/share/hdhomerun/|g" \
        ${worksrcpath}/src/HDHRConfig.cpp
    reinplace "s|\${EXECUTABLE_NAME}|hdhomerun_config_gui|g" \
        ${worksrcpath}/OSX/Info.plist
    reinplace "s|\${PRODUCT_NAME}|HDHomeRun Config|g" \
        ${worksrcpath}/OSX/Info.plist
}

post-build {
# no execute permission, will refuse to run with "Error 126", Permission denied
    file attributes ${worksrcpath}/install-sh -permissions +x
}

app.name            HDHomerun
app.executable      hdhomerun_config_gui
app.icon            ${worksrcpath}/OSX/hdhr.icns

post-destroot {
# Stop icon from bouncing on dock
# see https://trac.macports.org/ticket/40110
    reinplace -E {s|(<string>APPL</string>)|\1 <key>LSUIElement</key><string>1</string>|} \
        "${destroot}${applications_dir}/HDHomerun.app/Contents/Info.plist"
}
