diff --git a/Makefile b/Makefile index b1a740a95..87386533c 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ OK_COLOR=\x1b[32;01m ERROR_COLOR=\x1b[31;01m WARN_COLOR=\x1b[33;01m +export ROOTDIR=$(CURDIR) + all: @mkdir -p bin/ go get -d -v ./... diff --git a/packer.go b/packer.go index bb2b6da8a..878d3f115 100644 --- a/packer.go +++ b/packer.go @@ -3,12 +3,18 @@ package main import ( "github.com/mitchellh/packer/packer" + "github.com/mitchellh/packer/packer/plugin" "fmt" "os" + "os/exec" ) func main() { envConfig := packer.DefaultEnvironmentConfig() + envConfig.Commands = []string{"build"} + envConfig.CommandFunc = func(n string) packer.Command { + return plugin.Command(exec.Command("bin/packer-build")) + } env, err := packer.NewEnvironment(envConfig) if err != nil { diff --git a/packer/plugin/command.go b/packer/plugin/command.go index de65fa9da..6ffbbf655 100644 --- a/packer/plugin/command.go +++ b/packer/plugin/command.go @@ -11,7 +11,13 @@ import ( ) func Command(cmd *exec.Cmd) packer.Command { + env := []string{ + "PACKER_PLUGIN_MIN_PORT=10000", + "PACKER_PLUGIN_MAX_PORT=25000", + } + out := new(bytes.Buffer) + cmd.Env = append(cmd.Env, env...) cmd.Stdout = out cmd.Start() diff --git a/plugin/command-build/Makefile b/plugin/command-build/Makefile index e1ee4fe9f..8e93cf031 100644 --- a/plugin/command-build/Makefile +++ b/plugin/command-build/Makefile @@ -1,6 +1,6 @@ plugin: go get -d -v ./... - go build -v -o $(CURDIR)/bin/packer-build + go build -v -o $(ROOTDIR)/bin/packer-build format: go fmt ./... diff --git a/plugin/command-build/bin/packer-build b/plugin/command-build/bin/packer-build deleted file mode 100755 index 10d913598..000000000 Binary files a/plugin/command-build/bin/packer-build and /dev/null differ