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

github.setup        khenriks mp3fs 1.1.1 v
revision            0
github.tarball_from releases
categories          fuse audio
license             GPL-3+

maintainers         {i0ntempest @i0ntempest} openmaintainer

description         A flac to mp3 (read-only) filesystem for FUSE
long_description    This is a file system for converting flac files \
                    to mp3 files on the fly. This is useful, if you \
                    archive your music in flac format, but some \
                    program (i.e. iTunes) are not capable reading \
                    flac, but mp3.

homepage            https://khenriks.github.io/${name}/

checksums           rmd160  89d103e2ed82d46417325222dd5ce090e72390ae \
                    sha256  942b588fb623ea58ce8cac8844e6ff2829ad4bc9b4c163bba58e3fa9ebc15608 \
                    size    804399

depends_lib-append  port:flac \
                    port:lame \
                    port:libid3tag \
                    port:libvorbis \
                    port:zlib

post-patch {
    reinplace "s|#include <fuse_darwin\\.h>|//#include <fuse_darwin.h>|" ${worksrcpath}/src/mp3fs.cc
    reinplace "s|OS X FUSE|macFUSE|" ${worksrcpath}/src/mp3fs.cc
    reinplace "s|osxfuse_version|fuse_version|" ${worksrcpath}/src/mp3fs.cc
}

variant fs_link description "Link ${name} to a .fs bundle in /Library/Filesystems" {
    post-destroot {
        set dir /Library/Filesystems/${name}.fs/Contents/Resources
        xinstall -d ${destroot}${dir}
        ln -s ${prefix}/bin/${name} ${destroot}${dir}/mount_${name}
    }

    destroot.violate_mtree \
                        yes

    notes-append "
        With +fs_link, you may use \'mount -t ${name}\' and use ${name} in /etc/fstab.
    "
}
