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

# set fullhash      7b40699e95539ebbff71ccf1772b866353952ad7
set shorthash       7b40699e
github.setup        MythTV mythweb ${shorthash}
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
set majorversion    .27
set minorversion    .4
name                mythweb${majorversion}
version             0${majorversion}${minorversion}-Fixes-20160720
revision            1

categories          multimedia www
platforms           any
license             GPL-2 LGPL-2.1
maintainers         nomaintainer
supported_archs     noarch
conflicts           mythweb.25 mythweb.26

description         control your Myth system via a web browser
long_description    MythWeb provides a frontend to MythTV using a web browser. \
                    Review program listings, schedule recordings, browse previous recordings, \
                    check on the status of your system and much more.  Note that this is an \
                    INSECURE installation intended for local network access only.  Take steps to \
                    secure if access from the internet is to be allowed.

homepage            https://www.mythtv.org/
checksums           rmd160  ff811f99295931d37a6f45ab673b0b16e11d7161 \
                    sha256  18847fb0a84a76ad99937dad476a5ffea239178aee23139f3f796b779668dd61

set perlver         perl5.28
set perlbin         ${prefix}/bin/${perlver}
set perlmodver      p5.28
set webroot         ${prefix}/www/apache2/html

depends_run         port:mythtv-core${majorversion} \
                    port:${perlmodver}-http-request-ascgi \
                    port:${perlmodver}-dbd-mysql \
                    port:php54-mysql \
                    port:php54-apache2handler

patchfiles          patch-mythweb.conf.diff

use_configure       no
build               {}

pre-patch {
    copy ${worksrcpath}/mythweb.conf.apache ${worksrcpath}/mythweb.conf
}

post-patch {
    reinplace -locale C "s|@PREFIX@|${prefix}|g" ${worksrcpath}/mythweb.conf
    reinplace -locale C "s|/usr/local|${prefix}|" ${worksrcpath}/mythweb.php

    reinplace -locale C "s|#!/usr/bin/perl|#!${perlbin}|" \
         ${worksrcpath}/mythweb.pl \
         ${worksrcpath}/modules/_shared/lang/build_translation.pl \
         ${worksrcpath}/modules/coverart/handler.pl \
         ${worksrcpath}/modules/stream/handler.pl \
         ${worksrcpath}/modules/stream/stream_asx.pl \
         ${worksrcpath}/modules/stream/stream_flv.pl \
         ${worksrcpath}/modules/stream/stream_flvp.pl \
         ${worksrcpath}/modules/stream/stream_mp4.pl \
         ${worksrcpath}/modules/stream/stream_raw.pl \
         ${worksrcpath}/modules/stream/tv.pl
}

destroot {
    xinstall -d ${destroot}${webroot}
    copy ${worksrcpath} ${destroot}${webroot}
    file rename ${destroot}${webroot}/mythweb-${shorthash} \
        ${destroot}${webroot}/MythWeb
    system "chown -R _www:_www ${destroot}${webroot}/MythWeb/data"
}

notes "\
############################################################################
#
# If this is the first time installing MythWeb, please see
# http://www.mythtv.org/wiki/MythWeb_via_MacPorts for information
# essential to finishing the installation of MythWeb!
#
# Upgrading for the first time after October 20, 2017?  Check your
# configuration with the above wiki page.
#
############################################################################"

livecheck.type              none
