2015-02-26 03:58:07 +00:00
|
|
|
class Pushpin < Formula
|
|
|
|
homepage "http://pushpin.org"
|
2015-05-10 01:31:18 +00:00
|
|
|
url "http://packages.fanout.io/source/pushpin-1.2.0.tar.bz2"
|
|
|
|
sha256 "10156a5c3a5e956569fe25d5e467e3e452fc2b6b0b63c7894fc7f6aee6c7c414"
|
2015-05-10 17:00:02 +00:00
|
|
|
revision 1
|
2015-05-05 20:49:48 +00:00
|
|
|
|
|
|
|
head "https://github.com/fanout/pushpin.git"
|
2015-02-26 08:58:09 +00:00
|
|
|
|
2015-03-09 11:24:50 +00:00
|
|
|
bottle do
|
2015-05-10 18:08:03 +00:00
|
|
|
sha256 "e3e375fb96a6e558e27c300e18d3cd6b1535530f6ea32345554e2d2def627c6f" => :yosemite
|
|
|
|
sha256 "31be58a8024be381ceaddc7a2c682b2f7ee5ca952d02964abdfc2cc222224d66" => :mavericks
|
|
|
|
sha256 "02f82c337c06c3373fbdfb69f4066d897413e2e35011a53725331b799e0378c3" => :mountain_lion
|
2015-03-09 11:24:50 +00:00
|
|
|
end
|
|
|
|
|
2015-02-26 03:58:07 +00:00
|
|
|
depends_on "pkg-config" => :build
|
|
|
|
depends_on "qt"
|
|
|
|
depends_on "zeromq"
|
|
|
|
depends_on "qca"
|
|
|
|
depends_on "qjson"
|
|
|
|
depends_on "mongrel2"
|
|
|
|
depends_on "zurl"
|
|
|
|
|
|
|
|
resource "MarkupSafe" do
|
|
|
|
url "https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.23.tar.gz"
|
2015-05-05 20:49:48 +00:00
|
|
|
sha256 "a4ec1aff59b95a14b45eb2e23761a0179e98319da5a7eb76b56ea8cdc7b871c3"
|
2015-02-26 03:58:07 +00:00
|
|
|
end
|
|
|
|
|
2015-05-05 20:49:48 +00:00
|
|
|
resource "Jinja2" do
|
2015-02-26 03:58:07 +00:00
|
|
|
url "https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz"
|
2015-05-05 20:49:48 +00:00
|
|
|
sha256 "2e24ac5d004db5714976a04ac0e80c6df6e47e98c354cb2c0d82f8879d4f8fdb"
|
2015-02-26 03:58:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
resource "pyzmq" do
|
2015-05-05 20:49:48 +00:00
|
|
|
url "https://pypi.python.org/packages/source/p/pyzmq/pyzmq-14.6.0.tar.gz"
|
|
|
|
sha256 "7746806ff94f1e8c1e843644c6bbd3b9aaeb1203c2eaf38879adc23dbd5c35bb"
|
2015-02-26 03:58:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
resource "setproctitle" do
|
|
|
|
url "https://pypi.python.org/packages/source/s/setproctitle/setproctitle-1.1.8.tar.gz"
|
2015-05-05 20:49:48 +00:00
|
|
|
sha256 "b564cf6488217c7a4632a9fe646fc3a3bea2f9712b4e667e9632b870d1a58211"
|
2015-02-26 03:58:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
resource "tnetstring" do
|
|
|
|
url "https://pypi.python.org/packages/source/t/tnetstring/tnetstring-0.2.1.tar.gz"
|
2015-05-05 20:49:48 +00:00
|
|
|
sha256 "55715a5d758214034db179005def47ed842da36c4c48e9e7ae59bcaffed7ca9b"
|
2015-02-26 03:58:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
|
|
|
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
|
|
|
|
|
2015-05-05 20:49:48 +00:00
|
|
|
%w[MarkupSafe Jinja2 pyzmq setproctitle tnetstring].each do |r|
|
2015-02-26 03:58:07 +00:00
|
|
|
resource(r).stage do
|
|
|
|
system "python", *Language::Python.setup_install_args(libexec/"vendor")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
system "make", "prefix=#{prefix}", "varprefix=#{var}"
|
|
|
|
system "make", "install", "prefix=#{prefix}", "varprefix=#{var}"
|
|
|
|
|
|
|
|
pyenv = { :PYTHONPATH => ENV["PYTHONPATH"] }
|
2015-05-10 17:00:02 +00:00
|
|
|
%w[pushpin pushpin-handler pushpin-publish].each do |f|
|
2015-02-26 03:58:07 +00:00
|
|
|
(libexec/"bin").install bin/f
|
|
|
|
(bin/f).write_env_script libexec/"bin/#{f}", pyenv
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
conffile = testpath/"pushpin.conf"
|
|
|
|
routesfile = testpath/"routes"
|
|
|
|
runfile = testpath/"test.py"
|
|
|
|
|
|
|
|
cp prefix/"etc/pushpin/pushpin.conf", conffile
|
|
|
|
cp prefix/"etc/pushpin/internal.conf", testpath/"internal.conf"
|
|
|
|
cp prefix/"etc/pushpin/routes", routesfile
|
|
|
|
|
|
|
|
inreplace routesfile, "localhost:80", "localhost:10080"
|
|
|
|
|
2015-05-05 20:49:48 +00:00
|
|
|
runfile.write <<-EOS.undent
|
2015-02-26 03:58:07 +00:00
|
|
|
import urllib2
|
|
|
|
import threading
|
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
|
|
|
class TestHandler(BaseHTTPRequestHandler):
|
|
|
|
def do_GET(self):
|
|
|
|
self.send_response(200)
|
|
|
|
self.end_headers()
|
|
|
|
self.wfile.write('test response\\n')
|
|
|
|
def server_worker(c):
|
|
|
|
global port
|
|
|
|
server = HTTPServer(('', 10080), TestHandler)
|
|
|
|
port = server.server_address[1]
|
|
|
|
c.acquire()
|
|
|
|
c.notify()
|
|
|
|
c.release()
|
|
|
|
try:
|
|
|
|
server.serve_forever()
|
|
|
|
except:
|
|
|
|
server.server_close()
|
|
|
|
c = threading.Condition()
|
|
|
|
c.acquire()
|
|
|
|
server_thread = threading.Thread(target=server_worker, args=(c,))
|
|
|
|
server_thread.daemon = True
|
|
|
|
server_thread.start()
|
|
|
|
c.wait()
|
|
|
|
c.release()
|
|
|
|
f = urllib2.urlopen('http://localhost:7999/test')
|
|
|
|
body = f.read()
|
|
|
|
assert(body == 'test response\\n')
|
2015-05-05 20:49:48 +00:00
|
|
|
EOS
|
2015-02-26 03:58:07 +00:00
|
|
|
|
|
|
|
pid = fork do
|
|
|
|
exec "#{bin}/pushpin", "--config=#{conffile}"
|
|
|
|
end
|
|
|
|
|
|
|
|
begin
|
|
|
|
sleep 3 # make sure pushpin processes have started
|
|
|
|
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
|
|
|
|
system "python", runfile
|
|
|
|
ensure
|
|
|
|
Process.kill("TERM", pid)
|
|
|
|
Process.wait(pid)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|