# -*- 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 89956 2012-02-17 04:22:11Z ryandesign@macports.org $

PortSystem          1.0

name                ntfs-3g
version             2012.1.15
revision            2
categories          fuse
platforms           darwin
maintainers         kelotti.net:petri \
                    openmaintainer
license             GPL-2+ LGPL-2
description         Safe read/write NTFS driver for FUSE
long_description    The NTFS-3G driver is an open source, freely available \
                    NTFS driver for FUSE with read and write support. It \
                    provides safe and fast handling of the Windows XP, Windows \
                    Server 2003, Windows 2000 and Windows Vista file systems. \
                    Most POSIX file system operations are supported, with the \
                    exception of full file ownership and access right support. \
                    Also included are ntfsprogs, a set of utilities to create \
                    and manipulate NTFS file systems.

homepage            http://www.tuxera.com/community/ntfs-3g-download/
distname            ntfs-3g_ntfsprogs-${version}
extract.suffix      .tgz

master_sites        http://tuxera.com/opensource/

checksums           md5     341acae00a290cab9b00464db65015cc \
                    sha1    8d55cf49afde172fefa369a0a85289e09c4d7bbb \
                    rmd160  4db6ea1025eedeee160a1cd4238d069a307b9b35

livecheck.type      regex
livecheck.regex     {stable version</font></b> is <a href="http://tuxera.com/opensource/ntfs-3g-(.+?)\.tgz">}

depends_build       port:pkgconfig
depends_lib         path:lib/pkgconfig/fuse.pc:fuse4x

# Use default PKG_CONFIG_PATH to avoid picking up a FUSE installation
# in /usr/local (see #30537)
patchfiles          patch-configure.diff

configure.args      --exec-prefix=${prefix} --with-fuse=external

platform darwin {
    configure.ldflags-append    -framework CoreFoundation -lintl
}

pre-destroot {
    file mkdir ${destroot}/sbin
}

post-destroot {
    # ntfs-3g symlinks /sbin/mount.ntfs-3g to ${prefix}/bin/ntfs-3g
    # but on darwin mount wants mount_* instead of mount.*

    # /sbin/mount.ntfs-3g is no longer installed with recent versions of ntfs-3g
    # but check here to verify so updates don't miss it if it's turned back on
    if {[file exists ${destroot}/sbin/mount.ntfs-3g]} {
       # This violated the tree restrictions, hopefully fixed by now.
       file rename -- ${destroot}/sbin/mount.ntfs-3g \
                      ${destroot}${prefix}/sbin/mount_ntfs-3g
    }
    file rename -- ${destroot}${prefix}/share/man/man8/mount.ntfs-3g.8 \
                   ${destroot}${prefix}/share/man/man8/mount_ntfs-3g.8

    # This violated the tree restrictions, hopefully fixed by now.
    file rename -- ${destroot}/sbin/mkfs.ntfs \
                   ${destroot}${prefix}/sbin/mkfs.ntfs
}

