- Setup Golang.
- Install gox for cross platform compilation:
go get -u github.com/mitchellh/gox
Get packer source and download dependencies
git clone https://github.com/mitchellh/packer.git $GOPATH/src/github.com/mitchellh/packer
cd $GOPATH/src/github.com/mitchellh/packer
make updatedeps
To cross compile packer in its entirety for Windows from linux or a mac:
cd $GOPATH/src/github.com/mitchellh/packer
gox -osarch="windows/amd64" -output="pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"
gox -osarch="windows/amd64" -output="pkg/{{.OS}}_{{.Arch}}/packer-{{.Dir}}" ./...
rm pkg/windows_amd64/packer-packer.exe
Binaries are now in the pkg folder
cd $GOPATH/src/github.com/mitchellh/packer/pkg/windows_amd64/
ls -l *.exe
Build just a specific submodule of packer (e.g. only builder-vmware-iso). This is much faster than re-crosscompiling all the things.
cd $GOPATH/src/github.com/mitchellh/packer
gox -osarch="windows/amd64" -output="pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"
gox -osarch="windows/amd64" -output="pkg/{{.OS}}_{{.Arch}}/packer-{{.Dir}}" github.com/mitchellh/packer/plugin/builder-vmware-iso
Get Azure Packer plugin source
git clone https://github.com/Azure/packer-azure.git $GOPATH/src/github.com/Azure/packer-azure
cd $GOPATH/src/github.com/Azure/packer-azure
gox -osarch="windows/amd64" -output="pkg/{{.OS}}_{{.Arch}}/packer-{{.Dir}}" github.com/Azure/packer-azure/packer/plugin/...
Binaries are now in the pkg folder
cd $GOPATH/src/github.com/Azure/packer-azure/pkg/windows_amd64/
ls -l *.exe
Thanks @mefellows for the submodule only tip!