From ebd04694bf357571fcf9907feac2693e7ce77d08 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 13 Nov 2016 20:24:46 +0900 Subject: [PATCH] docker-machine-driver-xhyve: fix libev issue Close #6678 --- Formula/docker-machine-driver-xhyve.rb | 39 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Formula/docker-machine-driver-xhyve.rb b/Formula/docker-machine-driver-xhyve.rb index 677e997ad6cb6..17983c487185e 100644 --- a/Formula/docker-machine-driver-xhyve.rb +++ b/Formula/docker-machine-driver-xhyve.rb @@ -20,9 +20,12 @@ class DockerMachineDriverXhyve < Formula depends_on "docker-machine" => :recommended if build.with? "qcow2" depends_on "opam" - depends_on "libev" + depends_on "libev" => :build end + # Allow specifying version and libev location. + patch :DATA + def install (buildpath/"gopath/src/github.com/zchee/docker-machine-driver-xhyve").install Dir["{*,.git,.gitignore,.gitmodules}"] @@ -38,8 +41,12 @@ def install if build.with? "qcow2" build_tags << " qcow2" + ENV["LIBEV_FILE"] = "#{Formula["libev"].lib}/libev.a" + system "opam", "init", "--no-setup" opam_dir = "#{buildpath}/.brew_home/.opam" + + # To imitate 'eval `opam init`' ENV["CAML_LD_LIBRARY_PATH"] = "#{opam_dir}/system/lib/stublibs:/usr/local/lib/ocaml/stublibs" ENV["OPAMUTF8MSGS"] = "1" ENV["PERL5LIB"] = "#{opam_dir}/system/lib/perl5" @@ -48,11 +55,11 @@ def install system "opam", "install", "-y", "uri", "qcow-format", "conf-libev" end - go_ldflags = "-w -s -X 'github.com/zchee/docker-machine-driver-xhyve/xhyve.GitCommit=Homebrew#{git_hash}'" + go_ldflags = "-w -s -X=github.com/zchee/docker-machine-driver-xhyve/xhyve.GitCommit=Homebrew-#{git_hash}" ENV["GO_LDFLAGS"] = go_ldflags ENV["GO_BUILD_TAGS"] = build_tags system "make", "lib9p" - system "make", "build" + system "make", "build", "V=1" bin.install "bin/docker-machine-driver-xhyve" end end @@ -70,3 +77,29 @@ def caveats; <<-EOS.undent shell_output("#{Formula["docker-machine"].bin}/docker-machine create --driver xhyve -h") end end + +__END__ +diff --git a/Makefile b/Makefile +index d6448d0..8c26cf7 100644 +--- a/Makefile ++++ b/Makefile +@@ -78,7 +78,7 @@ CGO_CFLAGS := + CGO_LDFLAGS := + + # Parse git current branch commit-hash +-GO_LDFLAGS += -X `go list ./xhyve`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` ++GO_LDFLAGS ?= -X `go list ./xhyve`.GitCommit=`git rev-parse --short HEAD 2>/dev/null` + + + # Set debug gcflag, or optimize ldflags +@@ -126,8 +126,8 @@ endif + # Use mirage-block for pwritev|preadv + HAVE_OCAML_QCOW := $(shell if ocamlfind query qcow uri >/dev/null 2>/dev/null ; then echo YES ; else echo NO; fi) + ifeq ($(HAVE_OCAML_QCOW),YES) +-LIBEV_FILE=/usr/local/lib/libev.a +-LIBEV=$(shell if test -e $(LIBEV_FILE) ; then echo $(LIBEV_FILE) ; fi ) ++LIBEV_FILE ?= /usr/local/lib/libev.a ++LIBEV = $(shell if test -e $(LIBEV_FILE) ; then echo $(LIBEV_FILE) ; fi ) + OCAML_WHERE := $(shell ocamlc -where) + OCAML_LDLIBS := -L $(OCAML_WHERE) \ + $(shell ocamlfind query cstruct)/cstruct.a \