diff --git a/Library/Formula/docker-machine-driver-xhyve.rb b/Library/Formula/docker-machine-driver-xhyve.rb new file mode 100644 index 000000000000..2fc88c8a59fa --- /dev/null +++ b/Library/Formula/docker-machine-driver-xhyve.rb @@ -0,0 +1,43 @@ +require "language/go" + +class DockerMachineDriverXhyve < Formula + desc "Docker Machine driver for xhyve" + homepage "https://github.com/zchee/docker-machine-driver-xhyve" + url "https://github.com/zchee/docker-machine-driver-xhyve/releases/download/v0.2.1/docker-machine-driver-xhyve" + sha256 "d56db4635ad2f711d73b44508405277bddd5af439af2c82dbdd0da116e8d1380" + + head do + url "https://github.com/zchee/docker-machine-driver-xhyve.git" + + depends_on "go" => :build + end + + depends_on "docker-machine" + + def install + if build.head? + contents = Dir["{*,.git,.gitignore}"] + gopath = buildpath/"gopath" + (gopath/"src/github.com/zchee/docker-machine-driver-xhyve").install contents + + ENV["GOPATH"] = gopath + ENV["GO15VENDOREXPERIMENT"] = "1" + + cd gopath/"src/github.com/zchee/docker-machine-driver-xhyve" do + ENV["GIT_COMMIT"] = `git rev-parse --short HEAD 2>/dev/null`.gsub(/\n/,"") + system "go", "build", "-o", "docker-machine-driver-xhyve", "-ldflags", "'-w -s'", "-ldflags", "-X 'github.com/zchee/docker-machine-driver-xhyve/xhyve.GitCommit=#{ENV['GIT_COMMIT']}'", "./main.go" + bin.install "docker-machine-driver-xhyve" + end + else + bin.install "docker-machine-driver-xhyve" + end + end + + def caveats; <<-EOS.undent + docker-machine-driver-xhyve requires root privileges to correctly setup vmnet networking. + Please change the driver's owner and set the setuid bit: + sudo chown root:wheel #{bin}/docker-machine-driver-xhyve + sudo chmod u+s #{bin}/docker-machine-driver-xhyve + EOS + end +end