diff --git a/Formula/ntfs-3g.rb b/Formula/ntfs-3g.rb new file mode 100644 index 0000000000..c417bd1720 --- /dev/null +++ b/Formula/ntfs-3g.rb @@ -0,0 +1,69 @@ +class Ntfs3g < Formula + desc "Read-write NTFS driver for FUSE" + homepage "https://www.tuxera.com/community/open-source-ntfs-3g/" + url "https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2016.2.22.tgz" + sha256 "d7b72c05e4b3493e6095be789a760c9f5f2b141812d5b885f3190c98802f1ea0" + + head do + url "git://git.code.sf.net/p/ntfs-3g/ntfs-3g", :branch => "edge" + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "libtool" => :build + depends_on "libgcrypt" => :build + end + + depends_on "pkg-config" => :build + depends_on "gettext" + depends_on :osxfuse + + def install + ENV.append "LDFLAGS", "-lintl" + args = ["--disable-debug", + "--disable-dependency-tracking", + "--prefix=#{prefix}", + "--exec-prefix=#{prefix}", + "--mandir=#{man}", + "--with-fuse=external"] + + system "./autogen.sh" if build.head? + inreplace "ntfsprogs/Makefile.in", "/sbin", sbin # Workaround for hardcoded /sbin in ntfsprogs + system "./configure", *args + system "make" + system "make", "install" + + # Install a script that can be used to enable automount + File.open("#{sbin}/mount_ntfs", File::CREAT|File::TRUNC|File::RDWR, 0755) do |f| + f.puts <<-EOS.undent + #!/bin/bash + + VOLUME_NAME="${@:$#}" + VOLUME_NAME=${VOLUME_NAME#/Volumes/} + USER_ID=#{Process.uid} + GROUP_ID=#{Process.gid} + + if [ `/usr/bin/stat -f %u /dev/console` -ne 0 ]; then + USER_ID=`/usr/bin/stat -f %u /dev/console` + GROUP_ID=`/usr/bin/stat -f %g /dev/console` + fi + + #{opt_bin}/ntfs-3g \\ + -o volname="${VOLUME_NAME}" \\ + -o local \\ + -o negative_vncache \\ + -o auto_xattr \\ + -o auto_cache \\ + -o noatime \\ + -o windows_names \\ + -o user_xattr \\ + -o inherit \\ + -o uid=$USER_ID \\ + -o gid=$GROUP_ID \\ + -o allow_other \\ + "$@" >> /var/log/mount-ntfs-3g.log 2>&1 + + exit $?; + EOS + end + end +end