The easiest way to build a windows version of Packer for testing

172 views
Skip to first unread message

Patrick van der Velde

unread,
Mar 18, 2017, 10:52:41 PM3/18/17
to Packer
Hi

I'm trying to build a version of Packer from source code on windows 10 for windows x64. I've followed the instructions on the github page but I'm having issues getting the build to work. So far I have:

* Installed Go and set the GOPATH to the directory in which I want all my go code to appear

        echo %GOPATH% returns E:\documents\Petrik\documents\software\go)

* Got the source code via

        go get github.com/mitchellh/packer

* Executing make returns

        go get github.com/mitchellh/gox
        go get golang.org/x/tools/cmd/stringer
        go get github.com/kardianos/govendor
        govendor sync
        process_begin: CreateProcess(NULL, govendor sync, ...) failed.
        make (e=2): The system cannot find the file specified.
        make: *** [deps] Error 2

I have tried to use the Linux subsystem but that has a known bug which makes it not possible to execute go (see https://github.com/Microsoft/BashOnWindows/issues/349).

All I'm trying to do is to build an x64 version of Packer so that I can test a single line change I think I need to make to the Hyper-V provider.

Can anybody give me a hand shaving this compilation yak?

Thanks

Petrik

Rickard von Essen

unread,
Mar 19, 2017, 4:48:48 AM3/19/17
to packe...@googlegroups.com
If you have Docker for Windows the simplest way might be cross compile in a container. 

Go to the directory where you have packer checked out and run something like:

docker run -v %PWD%:/usr/src/packer -w /usr/src/packer golang:1.8 bash -c XC_ARCH=amd64 XC_OS=windows make dev

This should give you a Windows binary somewhere under pkg. 

I don't have access to a computer so I haven't tested the above but it should be close to correct. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/8295aec7-c778-4e81-8b9c-bcfb016e2175%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Patrick van der Velde

unread,
Mar 19, 2017, 9:05:08 PM3/19/17
to packe...@googlegroups.com
I was really hoping to avoid having to create a Linux machine to build Packer on, but if that's the only way then I guess I'll have to make one.

You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/oHAFgPP0QrM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt_Vt-HMG9A0fifCJCoUPQdPyOXJnQFw-nAOwVQEYZ923A%40mail.gmail.com.

Rickard von Essen

unread,
Mar 20, 2017, 4:36:21 AM3/20/17
to packe...@googlegroups.com
It should work to build on Windows, unfortunately I can't really help with that. We build each commit in appveyor and that is green so I expect there is something with you setup. 

Patrick van der Velde

unread,
Mar 20, 2017, 4:42:51 AM3/20/17
to Packer
Yeah I guess my environment is not correctly configured. I got docker for windows to work by the way but while it doesn't fail, it doesn't seem to produce a package either.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/oHAFgPP0QrM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Rickard von Essen

unread,
Mar 20, 2017, 5:03:03 AM3/20/17
to packe...@googlegroups.com
I tested my docker command and it's not completely accurate. This works on my Mac:

docker run -v $PWD:/go/src/github.com/mitchellh/packer -w /go/src/github.com/mitchellh/packer golang:1.8 bash -c "XC_ARCH=amd64 XC_OS=windows make dev"

It produces a windows binary in pkg/windows_amd64

I guess you need to adjust the variable ref ($PWD).

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/cc636ebf-0e98-47e1-9cff-5f69ead10926%40googlegroups.com.

Patrick van der Velde

unread,
Mar 20, 2017, 5:13:52 AM3/20/17
to Packer
So based on your command line I tried the following:

Go to the GOPATH directory
    cd e:\documents\Petrik\documents\src\go

Then run
     docker run -v %cd%:/usr/src/go -w /usr/src/go/src/github.com/mitchellh/packer golang:1.8 bash -c "GOPATH=/usr/src/go XC_ARCH=amd64 XC_OS=windows make dev"

That gets me
make: govendor: Command not found
Makefile:31: recipe for target 'deps' failed
make: *** [deps] Error 127

Which is progress! So now I need to figure out why govendor isn't a command.

Rickard von Essen

unread,
Mar 20, 2017, 5:19:14 AM3/20/17
to packe...@googlegroups.com
We vendor our deps so you don't need your full go path tree, $GOPATH/src/github.com/mitchellh/packer is enough. (Unless you want to modify deps)

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/7b97949a-d7f7-4e88-af17-ea9d7b73d089%40googlegroups.com.

Patrick van der Velde

unread,
Mar 20, 2017, 5:34:14 AM3/20/17
to Packer
Ok that got me nearly there.

If I cd to my packer directory

    cd e:\documents\Petrik\documents\software\go\src\github.com\mitchellh\packer

and then call the following command line

    docker run -v %cd%:/go/src/github.com/mitchellh/packer -w /go/src/github.com/mitchellh/packer golang:1.8 bash -c "GOPATH=/go XC_ARCH=amd64 XC_OS=windows make dev"

Then it compiles and I get
==> Removing old directory...
==> Building...
Number of parallel builds: 1

-->   windows/amd64: github.com/mitchellh/packer
==> Copying binaries for this platform...
find: `./pkg/linux_amd64': No such file or directory

==> Results:
total 0

Which I think means it failed to copy the binary in the end? There's nothing in the $GOPATH/bin folder and nothing in the packer/bin folder either

Rickard von Essen

unread,
Mar 20, 2017, 5:46:41 AM3/20/17
to packe...@googlegroups.com
Sorry that's expected behaviour, it actually work but our dev target tries to copy the binary from pkg/linux_amd64 to $GOPATH/bin/ to put it on the path, but it doesn't adheres to XC_ARCH and XC_OS. So you can just ignore that error. You should have the windows binary, pkg/windows_amd64/packer.exe

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/f1aa8ede-c4b0-447a-8df1-cd75a330a90d%40googlegroups.com.

Patrick van der Velde

unread,
Mar 20, 2017, 5:52:34 AM3/20/17
to Packer
Woot! You're right. I have a build.

Thanks heaps!!!!
Reply all
Reply to author
Forward
0 new messages