homebrew-fuse/Formula/ntfs-3g-mac.rb

107 lines
3.4 KiB
Ruby
Raw Normal View History

2021-04-27 02:01:59 +08:00
require_relative "../require/macfuse"
2021-04-27 14:33:48 +08:00
class Ntfs3gMac < Formula
2021-04-27 02:01:59 +08:00
desc "Read-write NTFS driver for FUSE"
homepage "https://www.tuxera.com/community/open-source-ntfs-3g/"
2022-06-16 13:32:09 +08:00
url "https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2022.5.17.tgz"
sha256 "0489fbb6972581e1b417ab578d543f6ae522e7fa648c3c9b49c789510fd5eb93"
license all_of: ["GPL-2.0-or-later", "LGPL-2.0-or-later"]
2021-04-27 02:01:59 +08:00
livecheck do
url :head
strategy :github_latest
2021-04-27 02:01:59 +08:00
end
bottle do
2022-06-16 13:32:09 +08:00
root_url "https://github.com/gromgit/homebrew-fuse/releases/download/ntfs-3g-mac-2022.5.17"
sha256 cellar: :any, arm64_monterey: "9b56b3d030aace12240cfcca5c505a16d7403c5d08ae22880eb2edf888e59175"
2022-06-16 20:29:40 +08:00
sha256 cellar: :any, monterey: "ee6068cc63819c203b24ab4749bc69894beda8f8a204aaa63668f626ec7d4471"
2022-06-16 14:06:04 +08:00
sha256 cellar: :any, big_sur: "c279548d3d07fdb950cb98cf27d195789021c046b49ddbd3cf0c0306382f62b7"
2022-06-17 11:48:26 +08:00
sha256 cellar: :any, catalina: "f20a4b41c9e0e16625b40c1210898300f4e12aa87709f07c94e2c70dc5821b25"
2022-06-16 14:38:12 +08:00
sha256 cellar: :any, mojave: "f0691c942eae549d753e1b1dd3efe6a177e919c8975f5b0022f0cc27c7f3c870"
2021-04-27 02:01:59 +08:00
end
head do
url "https://github.com/tuxera/ntfs-3g.git", branch: "edge"
2021-04-27 02:01:59 +08:00
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libgcrypt" => :build
depends_on "libtool" => :build
end
depends_on "pkg-config" => :build
depends_on "coreutils" => :test
depends_on "gettext"
depends_on MacfuseRequirement
depends_on :macos
def install
setup_fuse
2021-04-27 02:01:59 +08:00
ENV.append "LDFLAGS", "-lintl"
args = %W[
--disable-debug
--disable-dependency-tracking
--prefix=#{prefix}
--exec-prefix=#{prefix}
--mandir=#{man}
--with-fuse=external
--enable-extras
]
system "./autogen.sh" if build.head?
# Workaround for hardcoded /sbin in ntfsprogs
inreplace "ntfsprogs/Makefile.in", "/sbin", sbin
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
#!/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 streams_interface=openxattr \\
-o inherit \\
-o uid="$USER_ID" \\
-o gid="$GROUP_ID" \\
-o allow_other \\
-o big_writes \\
"$@" >> /var/log/mount-ntfs-3g.log 2>&1
exit $?;
EOS
end
end
test do
# create a small raw image, format and check it
ntfs_raw = testpath/"ntfs.raw"
system Formula["coreutils"].libexec/"gnubin/truncate", "--size=10M", ntfs_raw
ntfs_label_input = "Homebrew"
system sbin/"mkntfs", "--force", "--fast", "--label", ntfs_label_input, ntfs_raw
system bin/"ntfsfix", "--no-action", ntfs_raw
ntfs_label_output = shell_output("#{sbin}/ntfslabel #{ntfs_raw}")
assert_match ntfs_label_input, ntfs_label_output
end
end