# -*- 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 105489 2013-04-22 18:19:35Z elelay@macports.org $

PortSystem          1.0

name                gpodder
version             3.5.1
categories          gnome audio
license             GPL-3
maintainers         elelay
platforms           darwin
description         A media aggregator and podcast client

long_description    gPodder is a standalone podcast manager. \
                    It provides anything to manage feeds and podcasts \
                    but requires an external player to actually listen/view \
                    the content, e.g. Apple QuickTime Player.

homepage            http://gpodder.org
master_sites        http://gpodder.org/src/

checksums           md5     60bcc814adc654c00ab197abfe920d80 \
                    sha1    e9f26bd5bb7742d9c0fa78323e81060495f7417a \
                    rmd160  d8f06fe88f20a462d445589cdcbed9423a8bb20e


depends_build       port:help2man\
                    port:intltool

depends_lib         port:vorbis-tools\
                    port:lame

variant python25 conflicts python26 description {Use Python 2.5} {
    depends_lib-append  port:py25-feedparser\
                        port:py25-pil\
                        port:dbus-python25\
                        port:py25-mygpoclient \
                        port:py25-pygtk

    post-patch {
        reinplace s|python|${prefix}/bin/python2.5|g ${worksrcpath}/Makefile
    }

    destroot.args PREFIX=${prefix}
}


set my_python "DUMMY_VALUE_WILL_BE_OVERWRITTEN"

variant python26 conflicts python25 description {Use Python 2.6} {
    depends_lib-append  port:py26-feedparser\
                        port:py26-pil\
                        port:dbus-python26\
                        port:py26-mygpoclient \
                        port:py26-pygtk
    
    set my_python "${frameworks_dir}/Python.framework/Versions/2.6"

    post-patch {
        reinplace s|python|${my_python}/bin/python|g ${worksrcpath}/Makefile
    }
    
    # install in python 2.6 prefix, see bug #22522
    destroot.args PREFIX=${frameworks_dir}/Python.framework/Versions/2.6
    
    # Install the 2.6 apps in the standard path :
    # the 2 variants can't be active simultaneously.
    post-destroot {
    	foreach {app} {gpodder gpo gpodder-backup} {
    		ln -s ${my_python}/bin/${app} ${destroot}${prefix}/bin/${app}
        }
    }
}

variant python27 conflicts python26 conflicts python25 description {Use Python 2.7} {
    depends_lib-append  port:py27-feedparser\
                        port:py27-pil\
                        port:dbus-python27\
                        port:py27-mygpoclient \
                        port:py27-pygtk

    set my_python "${frameworks_dir}/Python.framework/Versions/2.7"
    
    post-patch {
        reinplace s|python|${my_python}/bin/python|g ${worksrcpath}/Makefile
    }

    # install in python 2.7 prefix, see bug #22522
    destroot.args PREFIX=${frameworks_dir}/Python.framework/Versions/2.7

    # Install the 2.7 apps in the standard path :
    # the 2 variants can't be active simultaneously.
    post-destroot {
        foreach {app} {gpodder gpo gpodder-backup gpodder-migrate2tres} {
            ln -s ${my_python}/bin/${app} ${destroot}${prefix}/bin/${app}
        }
    }
}

if {![variant_isset python25] && ![variant_isset python26] && ![variant_isset python27]} {
    default_variants +python27
}

variant quartz {
    depends_lib-append  port:gtk-osx-application
    
    post-destroot {
    	# Command-XX shortcuts in gPodder menus
    	system "/usr/bin/xsltproc -o ${destroot}${my_python}/share/gpodder/ui/gtk/gpodder.ui \
    		${filespath}/adjust-modifiers.xsl ${worksrcpath}/share/gpodder/ui/gtk/gpodder.ui"
    }
    
    patchfiles-append patch-src-gpodder-gtkui-main-py.diff
}

variant html_notes description {Use WebkitGtk+ to show episode notes in HTML format} {
	if {[variant_isset python25]} {
		depends_lib-append  port:py25-webkitgtk
	} elseif {[variant_isset python26]} {
		depends_lib-append  port:py26-webkitgtk
	} else {
		depends_lib-append  port:py27-webkitgtk
	}
}

use_configure       no

build {}

post-destroot {

    # build a MacOS X application
	if {[variant_isset python26] || [variant_isset python27]} {
		set install_path "${my_python}"
	} else {
		set install_path "${prefix}"
	}

	system "cd ${worksrcpath}/tools/mac-osx && make \
		GPODDERSCRIPT=\"${install_path}/bin/gpodder\"\
		APPLICATIONSDIR=\"${destroot}${applications_dir}\"\
		VERSION=\"${version}\"\
		OSXVERSION=\"${os.platform}${os.major}\" all"
}

notes "

****
****    With release 3.0, gPodder file structure has changed: instead of storing
**** the database in \$HOME/.config/gpodder and the downloads in \$HOME/gpodder-downloads
**** everything is now stored in the \$HOME/gPodder directory.
****    The database structure has also changed, so you'll have to run this
**** command to convert to the new format.
****
**** ${prefix}/bin/gpodder-migrate2tres
**** 
"


livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "gpodder-(\\d+(?:\\.\\d+)*)${extract.suffix}"
