diff --git a/Formula/yubikey-agent.rb b/Formula/yubikey-agent.rb new file mode 100644 index 00000000000..a180c36f55a --- /dev/null +++ b/Formula/yubikey-agent.rb @@ -0,0 +1,68 @@ +class YubikeyAgent < Formula + desc "Seamless ssh-agent for YubiKeys and other PIV tokens" + homepage "https://filippo.io/yubikey-agent" + url "https://github.com/FiloSottile/yubikey-agent/archive/v0.1.3.tar.gz" + sha256 "58c597551daf0c429d7ea63f53e72b464f8017f5d7f88965d4dae397ce2cb70a" + license "BSD-3-Clause" + head "https://filippo.io/yubikey-agent", using: :git + + depends_on "go" => :build + depends_on "pinentry-mac" + + def install + system "go", "build", *std_go_args, "-ldflags", "-X main.Version=v#{version}" + end + + def post_install + (var/"run").mkpath + (var/"log").mkpath + end + + def caveats + <<~EOS + To use this SSH agent, set this variable in your ~/.zshrc and/or ~/.bashrc: + export SSH_AUTH_SOCK="#{var}/run/yubikey-agent.sock" + EOS + end + + plist_options manual: "yubikey-agent -l #{HOMEBREW_PREFIX}/var/run/yubikey-agent.sock" + + def plist + <<~EOS + + + + + Label + #{plist_name} + EnvironmentVariables + + PATH + /usr/bin:/bin:/usr/sbin:/sbin:#{Formula["pinentry-mac"].opt_bin} + + ProgramArguments + + #{opt_bin}/yubikey-agent + -l + #{var}/run/yubikey-agent.sock + + RunAtLoad + KeepAlive + ProcessType + Background + StandardErrorPath + #{var}/log/yubikey-agent.log + StandardOutPath + #{var}/log/yubikey-agent.log + + + EOS + end + + test do + socket = testpath/"yubikey-agent.sock" + fork { exec bin/"yubikey-agent", "-l", socket } + sleep 1 + assert_predicate socket, :exist? + end +end