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

github.setup        libfuse sshfs 3.7.3 sshfs-
github.tarball_from archive
revision            0
categories          fuse

maintainers         {dports @drkp} {i0ntempest @i0ntempest} openmaintainer
description         SSH filesystem for FUSE
long_description    This is a filesystem client based on the \
                    SSH File Transfer Protocol. Since most SSH \
                    servers already support this protocol it is \
                    very easy to set up: i.e. on the server side \
                    there is nothing to do.  On the client side \
                    mounting the filesystem is as easy as logging \
                    into the server with ssh.

license             GPL-2

checksums           rmd160  6b773ded50ff56865ffcfa444e7664baa05cf8a6 \
                    sha256  52a1a1e017859dfe72a550e6fef8ad4f8703ce312ae165f74b579fd7344e3a26 \
                    size    63968

set python_branch   3.13
set python_version  [string map {. ""} ${python_branch}]

depends_build-append \
                    port:coreutils \
                    port:py${python_version}-docutils

depends_lib-append  path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    bin:ssh:openssh

post-extract {
    delete {*}[glob ${worksrcpath}/compat/fuse_opt*]
}

# Patches below are merged - remove when updating past 3.7.3
patch.args         -p1
patchfiles-append  patch-70c8fd9031e7610bf182956a785f7fc8f104e0f7.diff \
                   patch-5f767dec5b3fc07f665fdd4fbd9eb728a790f35f.diff \
                   patch-1a52814a4e4ccbc0774bb19bc655123398e407d5.diff \
                   patch-a9eb71cb1cfd1ae2bb9bd58e2405fde9bb9f5e75.diff \
                   patch-ed0825440c48895b7e20cc1440bbafd8d9c88eb8.diff \
                   patch-ccb6821019c19600110af6750e0d2395a9401617.diff

post-patch {
    reinplace "s|ln|${prefix}/bin/gln|g" ${worksrcpath}/utils/install_helper.sh
    reinplace "s| *'compat/fuse_opt.c',||" ${worksrcpath}/meson.build
    reinplace "s|'rst2man'|'rst2man-${python_branch}'|" ${worksrcpath}/meson.build
}

if {${os.platform} eq "darwin" && ${os.major} > 22} {
    configure.cflags-append \
                    -Wno-error=incompatible-function-pointer-types
}

# These versions hang indefinitely when compiling.
compiler.blacklist  {clang >= 1403 < 1600}

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.
    "
}
