Commit Graph

56 Commits

Author SHA1 Message Date
GennadySpb 25fddf3199
Add release build for darwin/arm64 (#10804)
* Add release build for darwin/arm64

Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
2021-03-25 13:34:21 +01:00
Wilken Rivera 1d53080625
Update script to exit on immediate failure (#10815) 2021-03-23 16:44:21 -04:00
Marco Molteni 1a248e4868
Fix: build.sh: give validateToolPresence a chance to inform the user (#9776)
Since the build.sh script runs with `set -e` (exit _immediately_ in case
of error), we cannot first call the `which` command and, on a susequent
line, check its exit status with $?, it would be too late. Instead, we
idiomatically check on the same line of the invocation of `which`.

From the confusing:

    $ make bin
    ==> Checking for necessary tools...
    make: *** [bin] Error 1

To the informative:

    $ make bin
    ==> Checking for necessary tools...
    realpath is not on the path. Exiting...
    make: *** [bin] Error 1
2020-08-16 21:37:12 -04:00
Wilken Rivera 951cd0f55e scripts/build: Remove unsupported Freebsd/arm builds from build chain
Builds before change
```
⇶  make bin
WARN: 'make bin' is for debug / test builds only. Use 'make release' for
release builds.
==> Checking for necessary tools...
==> Entering Packer source dir...
==> Ensuring output directories are present...
==> Removing old builds...
==> Building...
Number of parallel builds: 3

-->     linux/s390x: github.com/hashicorp/packer
-->     linux/amd64: github.com/hashicorp/packer
-->       linux/arm: github.com/hashicorp/packer
-->   solaris/amd64: github.com/hashicorp/packer
-->      linux/mips: github.com/hashicorp/packer
-->     freebsd/386: github.com/hashicorp/packer
-->     linux/arm64: github.com/hashicorp/packer
-->    linux/mips64: github.com/hashicorp/packer
-->    linux/mipsle: github.com/hashicorp/packer
-->    darwin/amd64: github.com/hashicorp/packer
-->       linux/386: github.com/hashicorp/packer
-->      darwin/386: github.com/hashicorp/packer
-->     windows/386: github.com/hashicorp/packer
-->   windows/amd64: github.com/hashicorp/packer
-->   linux/ppc64le: github.com/hashicorp/packer
-->     openbsd/386: github.com/hashicorp/packer
-->     freebsd/arm: github.com/hashicorp/packer
-->   openbsd/amd64: github.com/hashicorp/packer
-->   freebsd/amd64: github.com/hashicorp/packer

1 errors occurred:
--> freebsd/arm error: exit status 2
Stderr: # github.com/shirou/gopsutil/cpu
../go/pkg/mod/github.com/shirou/gopsutil@v2.18.12+incompatible/cpu/cpu_freebsd.go:25:16:
undefined: cpuTimes
../go/pkg/mod/github.com/shirou/gopsutil@v2.18.12+incompatible/cpu/cpu_freebsd.go:42:31:
undefined: cpuTimes
../go/pkg/mod/github.com/shirou/gopsutil@v2.18.12+incompatible/cpu/cpu_freebsd.go:66:38:
undefined: cpuTimes
../go/pkg/mod/github.com/shirou/gopsutil@v2.18.12+incompatible/cpu/cpu_freebsd.go:72:15:
undefined: cpuTimes
../go/pkg/mod/github.com/shirou/gopsutil@v2.18.12+incompatible/cpu/cpu_freebsd.go:87:13:
undefined: cpuTimes

==> Copying binaries for this platform...
'./pkg/linux_amd64/packer' -> 'bin/packer'
'./pkg/linux_amd64/packer' -> '/home/wilken/Development/go/bin/packer'

==> Results:
total 111M
-rwxr-xr-x 1 wilken wilken 111M Apr 14 22:02 packer
```

Builds after change
```
⇶  make bin
WARN: 'make bin' is for debug / test builds only. Use 'make release' for
release builds.
==> Checking for necessary tools...
==> Entering Packer source dir...
==> Ensuring output directories are present...
==> Removing old builds...
==> Building...
Number of parallel builds: 3

-->   solaris/amd64: github.com/hashicorp/packer
-->   windows/amd64: github.com/hashicorp/packer
-->     linux/s390x: github.com/hashicorp/packer
-->    darwin/amd64: github.com/hashicorp/packer
-->      darwin/386: github.com/hashicorp/packer
-->     windows/386: github.com/hashicorp/packer
-->   freebsd/amd64: github.com/hashicorp/packer
-->     freebsd/386: github.com/hashicorp/packer
-->     openbsd/386: github.com/hashicorp/packer
-->   openbsd/amd64: github.com/hashicorp/packer
-->     linux/arm64: github.com/hashicorp/packer
-->       linux/386: github.com/hashicorp/packer
-->     linux/amd64: github.com/hashicorp/packer
-->       linux/arm: github.com/hashicorp/packer
-->      linux/mips: github.com/hashicorp/packer
-->   linux/ppc64le: github.com/hashicorp/packer
-->    linux/mips64: github.com/hashicorp/packer
-->    linux/mipsle: github.com/hashicorp/packer
==> Copying binaries for this platform...
'./pkg/linux_amd64/packer' -> 'bin/packer'
'./pkg/linux_amd64/packer' ->
'/home/wilken/Development/golang/bin/packer'

==> Results:
total 111M
-rwxr-xr-x 1 wilken wilken 111M Apr 15 20:52 packer
```
2020-04-16 06:05:34 -04:00
Megan Marsh f12269f124
fix builds on linux (#9031)
* fix builds on linux

* Build: Move to CGO_ENABLED=0 (#9057)

After further investigation on cross-compiling Go bins on Linux. I found
that statically linking against GCC (for libc) failed to build for ARM
and introduced a possible licensing issue as our bins would essentially
be bundling libc into the bin. Diving further into cross compiling on Linux
I found that the defacto solution is to compile with CGO disabled - this
was also found to be the case for other HashiCorp products.

Disabling CGO has the limitation of not allowing the use of any pkg that
calls out to C (net, os), but in looking into the Packer code base and
the relevant Go code base it appears that the latest versions of Go have
pure Go implementations of the said packages so I believe we are good to
go. I should also point out that CGO is disabled by default when cross
compiling via `go build`. However, the GOX tool will enable it if it is
not explicitly disabled.

Below are three test cases executed to validate the compile bins work as
expected.

Build results after change
```
⇶  make bin
WARN: 'make bin' is for debug / test builds only. Use 'make release' for
release builds.
==> Checking for necessary tools...
==> Entering Packer source dir...
==> Ensuring output directories are present...
==> Removing old builds...
==> Building...
Number of parallel builds: 7

-->   windows/amd64: github.com/hashicorp/packer
-->     linux/arm64: github.com/hashicorp/packer
-->       linux/386: github.com/hashicorp/packer
-->       linux/arm: github.com/hashicorp/packer
-->    darwin/amd64: github.com/hashicorp/packer
-->     windows/386: github.com/hashicorp/packer
-->     linux/amd64: github.com/hashicorp/packer
-->      darwin/386: github.com/hashicorp/packer
==> Copying binaries for this platform...
'./pkg/linux_amd64/packer' -> 'bin/packer'
'./pkg/linux_amd64/packer' -> '/home/wilken/Development/go/bin/packer'

==> Results:
total 111M
-rwxr-xr-x 1 wilken wilken 111M Apr 13 12:29 packer
```

Packer executed on ARM based machine
```
ubuntu@ip-172-31-10-18:~$ ./packer version
Packer v1.5.6-dev (314ac5b65+CHANGES

ubuntu@ip-172-31-10-18:~$ uname -a
Linux ip-172-31-10-18 4.15.0-1054-aws #56-Ubuntu SMP Thu Nov 7 16:18:50 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

ubuntu@ip-172-31-10-18:~$ ./packer build build.json
null: output will be in this color.

==> null: Running local shell script: /tmp/packer-shell170248556
    null: UUID from Packer: 79cc8532-6114-925d-2a79-33ef6ce281cd
Build 'null' finished.

==> Builds finished. The artifacts of successful builds are:
--> null: Did not export anything. This is the null builder
```

Custom Docker image with updated bin
```
⇶  docker run packertest:latest version
Packer v1.5.6-dev (314ac5b65+CHANGES)

⇶  docker run packertest:latest build build.json
null: output will be in this color.

==> null: Running local shell script: /tmp/packer-shell065599452
    null: UUID from Packer: 852f0604-2be4-9e16-99af-6d7df972ac2e
Build 'null' finished.

==> Builds finished. The artifacts of successful builds are:
--> null: Did not export anything. This is the null builder
```

Windows AMI
```
[...]
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
    amazon-ebs: Adding tag: "Name": "Packer Builder"
    amazon-ebs: Instance ID: i-04387545cf3e2acd3
==> amazon-ebs: Waiting for instance (i-04387545cf3e2acd3) to become ready...
==> amazon-ebs: Skipping waiting for password since WinRM password set...
==> amazon-ebs: Using winrm communicator to connect: 18.206.100.104
==> amazon-ebs: Waiting for WinRM to become available...
    amazon-ebs: WinRM connected.
==> amazon-ebs: Connected to WinRM!
==> amazon-ebs: Uploading packertest => c:/Windows/Temp
==> amazon-ebs: Provisioning with Powershell...
==> amazon-ebs: Provisioning with powershell script: /tmp/powershell-provisioner173180945
    amazon-ebs: Packer v1.5.6-dev (314ac5b65+CHANGES)
    amazon-ebs: null: output will be in this color.
    amazon-ebs:
```

Co-authored-by: Wilken Rivera <dev@wilkenrivera.com>
2020-04-14 14:48:50 -04:00
bzhaoopenstack f7793649ec
Fix failed to copy binary when using make bin
If we use make bin, XC_OS and XC_ARCH will be None, the binary will failed to be copied.
2019-06-15 00:34:33 +08:00
Megan Marsh 5e23083df1
Merge pull request #7605 from hashicorp/verbose-packer-binary-copy
scripts/build.sh: don't discard stderr when copying packer
2019-05-07 10:23:20 -07:00
Adrien Delorme 5f076d4328 allow building packer on solaris by removing progress bar and tty imports
fix #7586
2019-05-07 15:58:49 +02:00
Adrien Delorme e8ac0e6c75
scripts/build.sh: don't discard stderr when copying packer
fix #7604
2019-05-06 11:06:38 +02:00
Guillaume J. Charmes 36641e66a7 Update build.sh. Remove solaris, add mipsXX and s390x
Signed-off-by: Guillaume J. Charmes <gcharmes@magicleap.com>
2019-04-25 16:29:25 -04:00
Adrien Delorme 413e242a14 Revert "scripts/build.sh: allow to set build settings when building"
This reverts commit f6be550f1a.
2019-04-15 16:35:32 +02:00
Adrien Delorme f6be550f1a scripts/build.sh: allow to set build settings when building
this will for example allow me to have the following alias:
alias buildmain='export T=$(mktemp -d) && ALL_XC_OS="linux darwin windows" ALL_XC_ARCH="amd64" GOLDFLAGS="-s -w" ./scripts/build.sh && cd pkg/ && for dir in *; do zip -r "$dir.zip" $dir & ; done ;  wait && mv *.zip $T/. && open $T'

that build only on 'main' platforms, so that I can share binaries easily.
2019-02-19 15:10:30 +01:00
Daniel Poggenpohl 6857e937e2 - FIX: That's what I get for wanting to use fancy or/and piping, back to basics (Now using explicit rc test to decide whether to quit) 2019-02-01 23:11:22 +01:00
Daniel Poggenpohl b0abd1fbf3 - FIX: I should call my defined functions, else they are useless 2019-02-01 20:48:42 +01:00
Daniel Poggenpohl ce760eec09 - More comments
- encapsulated code in functions to make it more readable
- validate presence of used tools/binaries (check if they're in PATH)
- more output
- FIX: make all uname/OSTYPE output to lowercase and check only for that
- refactored method name convert_path -> convertPathOnCygwin
- gave convert_path two arguments to make it more readable (Readability over tight code? I don't know what is required)
- some variable expansion now uses braces
2019-01-31 15:50:10 +01:00
Matthew Patton 554b2b4a5d ignore errors during Find 2018-04-09 19:47:41 -04:00
Matthew Patton d5bf9277ce remove rebase duplicate 2018-04-07 05:33:46 -04:00
Matthew Patton 6a85f5aed7 handle missing GOPATH and cygwin considerations 2018-04-07 05:29:43 -04:00
Matthew Patton 1d0cf3d909 handle missing GOPATH and cygwin considerations 2018-04-07 05:24:31 -04:00
Matthew Hooker 339d768420
add ppc64le as a build target 2017-09-25 15:38:32 -07:00
Matthew Hooker b7ddf80155
build solaris binary 2017-08-21 12:32:16 -07:00
Matthew Hooker 4ce0d91ae2
add support for building arm64 binaries 2017-05-15 13:31:38 -07:00
Matthew Hooker d805f5c8a5
put back the goose 2017-05-04 20:45:17 -07:00
Matthew Hooker 97892349dd
vastly speed up dev builds.
Copies work from hashicorp/consul#2924
2017-05-04 20:30:09 -07:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Sean Chittenden d430b7b763 Go's -X linker flag now requires only one argument (#3540)
This fixes building `packer` with Go >1.6.  From https://golang.org/cmd/link/:

```
-X importpath.name=value
	Set the value of the string variable in importpath named name to value.
	Note that before Go 1.5 this option took two separate arguments.
	Now it takes one argument split on the first = sign.
```
2016-05-17 13:24:04 -07:00
Christopher Boumenot 728c496370 Move version to its own package. (#3460) 2016-04-21 13:19:43 -07:00
Chris Bednarski c10e0eb398 Removed go get from build scripts since we have these in vendor already 2016-02-05 13:42:27 -08:00
Rickard von Essen 38612d45a9 Make all scripts portable regardless of where bash is installed. 2015-11-04 15:29:26 +01:00
Chris Bednarski a143f1e085 Updated build.sh so it doesn't build all the plugins separately anymore 2015-10-21 16:57:38 -07:00
Chris Bednarski 938f2178d7 Overhaul the Makefile
- Fix updatedeps reverting to master, which causes Travis CI to produce invalid results for pull-request builds. The makefile attempts to detect this change and checkout the correct branch if it happens.
- Clean up the code style and failure messaging.
- Add / update proxy targets for common workflows: default, deps, ci, release
2015-08-21 18:25:58 -07:00
Gonzalo Peci 0006cce41b When using MinGW gopath uses ; as separators, if we use : it strips everything after the driver letter. EG: C:\GO_Working\ gets stripped to C and makes ```make dev``` and ```make``` fail 2015-08-21 13:58:33 +12:00
Mitchell Hashimoto ddeefdcedd scripts: ignore errors on gox for now 2014-09-11 11:51:44 -07:00
Mitchell Hashimoto fd54017233 scripts: reintroduce dist 2014-09-11 11:51:20 -07:00
Mitchell Hashimoto f4b73c7ebf scripts: build should do everything now 2014-09-11 11:16:59 -07:00
Mitchell Hashimoto c5dc0f9e7d scripts: add openbsd/freebsd to builds 2014-09-10 16:10:33 -07:00
Ross Smith II f36b20ca28 make sure executable is named packer.exe in Windows build [GH-1483] 2014-09-10 09:47:49 -07:00
Mitchell Hashimoto 7078c2f922 Fix some scripts 2014-09-08 17:03:38 -07:00
Mitchell Hashimoto a23eb7512f scripts: copy packer- prefixed bins properly [GH-1467] 2014-09-07 15:58:36 -07:00
Mitchell Hashimoto 49ac4acdd2 scripts: able to set XC_ARCH/OS manually 2014-09-04 15:13:29 -07:00
Mitchell Hashimoto 2788ccc653 Update scripts to latest HashiCorp style 2014-09-02 15:13:55 -07:00
Mitchell Hashimoto 8516e03eed scripts: update to use gox 2013-11-18 15:37:14 -08:00
Mitchell Hashimoto 5d3b40dcbf Build script now installs binaries to $GOPATH/bin 2013-10-20 16:16:05 -07:00
Kirill Kazakov 678eb38e18 scripts: build.sh exits without being killed by SIGTERM 2013-09-27 14:27:47 +04:00
Mitchell Hashimoto 1e309b6609 scripts: PACKER_NO_BUILD_PARALLEL to build in sequence 2013-09-22 10:03:04 -07:00
Mitchell Hashimoto 6511b1892c scripts: build.sh compiles all Packer components in parallel 2013-09-22 09:58:34 -07:00
Mitchell Hashimoto 5b7865f085 scripts: build.sh appends .exe on Windows [GH-397] 2013-09-06 11:34:01 -07:00
Mitchell Hashimoto fd64600414 scripts: build go get ./... early to speed up builds 2013-08-21 11:20:55 -07:00
Mitchell Hashimoto 185f176937 scripts: set PACKER_RACE to build with race detector 2013-08-21 11:15:09 -07:00
Mitchell Hashimoto 923521e5df scripts: full SHA1 in build, not short 2013-08-12 09:17:03 -07:00