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.57.0.tar.gz" sha256 "294f7a6b0874509997d3a9ffae7c74f0c45b687df0ac7d7742f284ad3814fe55" license "MIT" head "https://github.com/rclone/rclone.git" bottle do root_url "https://github.com/gromgit/homebrew-fuse/releases/download/rclone-mac-1.57.0" sha256 cellar: :any_skip_relocation, monterey: "6781de4b7a88e170fc653110160b2eb633bd780b7dff68bcb8ee8db5508ee259" sha256 cellar: :any_skip_relocation, big_sur: "a5f85ac8d5c2dc818e092e5f7f75284ece39f3386717df0842ffda1be6d47df3" sha256 cellar: :any_skip_relocation, catalina: "f37cf21d56b5118406a3625a5f32f9c26d3b43eb23a63a7847ca195d2cc88d33" sha256 cellar: :any_skip_relocation, mojave: "3b0be477d781dded239b2913fd6c012b6051b11984ecee6fbb8c37f5b22c1418" end 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