aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/pssh.rb
blob: a60c2e2d8331dfdc331b9c386b9c6078940fbc38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'formula'

class Pssh < Formula
  homepage 'https://code.google.com/p/parallel-ssh/'
  url 'https://parallel-ssh.googlecode.com/files/pssh-2.3.1.tar.gz'
  sha1 '65736354baaa289cffdf374eb2ffd9aa1eda7d85'

  depends_on :python

  # TODO: Move this into Library/Homebrew somewhere (see also mitmproxy.rb and ansible.rb).
  def wrap bin_file, pythonpath
    bin_file = Pathname.new bin_file
    libexec_bin = Pathname.new libexec/'bin'
    libexec_bin.mkpath
    mv bin_file, libexec_bin
    bin_file.write <<-EOS.undent
    #!/bin/sh
    PYTHONPATH="#{pythonpath}:$PYTHONPATH" exec "#{libexec_bin}/#{bin_file.basename}" "$@"
    EOS
  end

  def install
    python do
      system python, "setup.py", "install",
        "--prefix=#{prefix}", "--install-data=#{share}"
    end

    Dir["#{bin}/*"].each do |bin_file|
      wrap bin_file, python.global_site_packages
    end
  end

  test do
    system "#{bin}/pssh", "--version"
  end
end