homebrew-fuse/Formula/rclone-mac.rb
Adrian Ho 2e2f25d0dc Preliminary support for M1 builds
NOTE: I don't have an M1 Mac, so the only testing I can do is with
a non-`/usr/local` Intel Homebrew installation. This should take
care of "`cc` shim forbids `/usr/local` if Homebrew not installed
under `/usr/local`", which is the default setup for M1 Homebrew.
2021-07-04 00:27:00 +08:00

54 lines
2 KiB
Ruby

require_relative "../require/macfuse"
class RcloneMac < Formula
desc "Rsync for cloud storage (with macOS FUSE mount support)"
homepage "https://rclone.org/"
url "https://github.com/rclone/rclone/archive/v1.55.1.tar.gz"
sha256 "b8cbf769c8ed41c6e1dd74de78bf14ee7935ee436ee5ba018f742a48ee326f62"
license "MIT"
head "https://github.com/rclone/rclone.git"
depends_on "go" => :build
depends_on MacfuseRequirement
depends_on :macos
def install
setup_fuse
system "go", "build",
"-ldflags", "-s -X github.com/rclone/rclone/fs.Version=v#{version}",
"-tags", "cmount", *std_go_args
(libexec/"rclone").install_symlink bin/name.to_s => "rclone"
man1.install "rclone.1" => "#{name}.1"
system bin/name.to_s, "genautocomplete", "bash", "rclone.bash"
system bin/name.to_s, "genautocomplete", "bash", "#{name}.bash"
system bin/name.to_s, "genautocomplete", "zsh", "_rclone"
system bin/name.to_s, "genautocomplete", "zsh", "_#{name}"
inreplace "#{name}.bash" do |s|
s.gsub! "commands=(\"rclone\")", "commands=(\"#{name}\")"
s.gsub!(/(-F __start_rclone) rclone$/, "\\1 #{name}")
end
inreplace "_#{name}", /(#compdef _rclone) rclone$/, "\\1 #{name}"
bash_completion.install "rclone.bash" => "rclone"
bash_completion.install "#{name}.bash" => name.to_s
zsh_completion.install "_rclone"
zsh_completion.install "_#{name}"
end
def caveats
<<~EOS
The rclone binary has been installed as `#{name}`,
to avoid conflict with the core `rclone` formula.
If you need to use it as `rclone`, add the "rclone" directory
to your PATH like:
PATH="#{opt_libexec}/rclone:$PATH"
EOS
end
test do
(testpath/"file1.txt").write "Test!"
system bin/name.to_s, "copy", testpath/"file1.txt", testpath/"dist"
assert_match File.read(testpath/"file1.txt"), File.read(testpath/"dist/file1.txt")
system opt_libexec/"rclone/rclone", "copy", testpath/"file1.txt", testpath/"dast"
assert_match File.read(testpath/"file1.txt"), File.read(testpath/"dast/file1.txt")
end
end