PortSystem 1.0
PortGroup github 1.0
PortGroup python 1.0

github.setup    decklin lastfmsubmitd 0.35
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision        1
description     LastFM Music Submitter
categories      audio
maintainers     nomaintainer
long_description \
     lastfmsubmitd is a replacement for the traditional Last.fm plugin model. \
     Instead of re-implementing networking and caching code in each plugin, \
     player plugins can simply send song information to the daemon, which will \
     take care of the rest.

master_sites    macports_distfiles
use_bzip2       yes
checksums       md5 0da502e0ecbbaef373c9849e33187367 \
                sha1 98fb020a54f8e49b16090fb1af07912a12351d8f \
                rmd160 c6a06aa3931b823ee8de2e863812b1a8542ffa47

python.default_version 27

set dirs { /var/spool/lastfm /var/run/lastfm /var/log/lastfm }
set conf lastfmsubmitd.conf.sample
set user "lastfm"

post-extract {
    file copy ${filespath}/${conf} ${worksrcpath}
}

patchfiles      patch-config.py.diff \
                patch-setup.py.diff \
                patch-lastfmsubmitd.1.diff
post-patch {
    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/doc/lastfmsubmitd.1
    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/lib/lastfm/config.py
    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/${conf}
}

post-destroot {
    addgroup ${user}
    set gid [existsgroup ${user}]
    adduser ${user} gid=${gid} realname=LastFM\ Submit\ Daemon

    foreach dir ${dirs} {
        xinstall -m 755 -o ${user} -g ${user} -d ${destroot}${prefix}${dir}
        destroot.keepdirs-append ${destroot}${prefix}${dir}
    }
    xinstall -m 600 -o ${user} -g ${user} ${worksrcpath}/${conf} ${destroot}${prefix}/etc/${conf}
}