# typed: false # frozen_string_literal: true # Homebrew formula for Tailscale class Tailscale < Formula desc "Easiest, secure, crossplatform WireGuard Go-based VPN w/oauth2, 2FA/SSO" homepage "https://www.tailscale.com" url "http://localhost:8901/tailscale/tailscale/archive/v1.5.0.tar.gz" sha256 "a62caf2eb5c84d2d1775cd8a17eeb0e8ad3b8dbc9453399862d908227e0af721" license "BSD-3-Clause" head "https://github.com/tailscale/tailscale.git", branch: "main" depends_on "go" => :build def install ENV["GOPATH"] = buildpath tailscale_path = buildpath/"src/github.com/tailscale/tailscale" tailscale_path.install buildpath.children cd tailscale_path do # TODO(mkramlich): refactor down the 'version.sh to ENV sets': output = Utils.safe_popen_read("./version/version.sh") lines = output.split("\n") lines.each do |line| parts = line.split("=") key = parts.at(0) val = parts.at(1) system "echo adding to ENV for go builds: key #{key}, val #{val}" ENV[key] = val end # TODO(mkramlich): make brew audit happy again # TODO(mkramlich): lose the breaking quotes around the vals in the #{ENV["FOO"]} renders in the go builds # go builds equiv to how done by tailscale repo's build_dist.sh: system "go", "build", "-o", ".", "-tags", "xversion", "-ldflags", "\"-X tailscale.com/version.Long=#{ENV["VERSION_LONG"]} -X tailscale.com/version.Short=#{ENV["VERSION_SHORT"]} -X tailscale.com/version.GitCommit=#{ENV["VERSION_GIT_HASH"]}\"", "tailscale.com/cmd/tailscale" system "go", "build", "-o", ".", "-tags", "xversion", "-ldflags", "\"-X tailscale.com/version.Long=#{ENV["VERSION_LONG"]} -X tailscale.com/version.Short=#{ENV["VERSION_SHORT"]} -X tailscale.com/version.GitCommit=#{ENV["VERSION_GIT_HASH"]}\"", "tailscale.com/cmd/tailscaled" bin.install "tailscale" bin.install "tailscaled" end end def post_install (var/"run/tailscale").mkpath (var/"lib/tailscale").mkpath end plist_options manual: "sudo tailscaled --socket=#{HOMEBREW_PREFIX}/run/tailscale/tailscaled.sock --state=#{HOMEBREW_PREFIX}/lib/tailscale/tailscaled.state" def plist <<~EOS KeepAlive SuccessfulExit NetworkState Label #{plist_name} ProgramArguments #{opt_bin}/tailscaled --socket=#{var}/run/tailscale/tailscaled.sock --state=#{var}/lib/tailscale/tailscaled.state RunAtLoad WorkingDirectory #{var}/lib/tailscale StandardErrorPath #{var}/log/tailscale/tailscaled-stderr.log StandardOutPath #{var}/log/tailscale/tailscaled-stdout.log EOS end test do system bin/"tailscale", "--version" system bin/"tailscale", "netcheck" end end