Merge pull request #7618 from hashicorp/build_on_solaris

allow building packer on solaris by removing progress bar and tty imports on solaris
This commit is contained in:
Megan Marsh 2019-05-07 10:10:02 -07:00 committed by GitHub
commit c28ab292a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 13 deletions

View File

@ -57,4 +57,4 @@ workflows:
- build_windows - build_windows
- build_freebsd - build_freebsd
- build_openbsd - build_openbsd
- build_solaris

View File

@ -22,7 +22,6 @@ import (
"github.com/hashicorp/packer/packer/plugin" "github.com/hashicorp/packer/packer/plugin"
"github.com/hashicorp/packer/packer/tmp" "github.com/hashicorp/packer/packer/tmp"
"github.com/hashicorp/packer/version" "github.com/hashicorp/packer/version"
"github.com/mattn/go-tty"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"github.com/mitchellh/panicwrap" "github.com/mitchellh/panicwrap"
"github.com/mitchellh/prefixedio" "github.com/mitchellh/prefixedio"
@ -193,7 +192,7 @@ func wrappedMain() int {
} }
ui = basicUi ui = basicUi
if !inPlugin { if !inPlugin {
if TTY, err := tty.Open(); err != nil { if TTY, err := openTTY(); err != nil {
fmt.Fprintf(os.Stderr, "No tty available: %s\n", err) fmt.Fprintf(os.Stderr, "No tty available: %s\n", err)
} else { } else {
basicUi.TTY = TTY basicUi.TTY = TTY

View File

@ -1,3 +1,5 @@
// +build !solaris
package packer package packer
import ( import (
@ -78,12 +80,3 @@ type readCloser struct {
} }
func (c *readCloser) Close() error { return c.close() } func (c *readCloser) Close() error { return c.close() }
// NoopProgressTracker is a progress tracker
// that displays nothing.
type NoopProgressTracker struct{}
// TrackProgress returns stream
func (*NoopProgressTracker) TrackProgress(_ string, _, _ int64, stream io.ReadCloser) io.ReadCloser {
return stream
}

View File

@ -0,0 +1,12 @@
package packer
import "io"
// NoopProgressTracker is a progress tracker
// that displays nothing.
type NoopProgressTracker struct{}
// TrackProgress returns stream
func (*NoopProgressTracker) TrackProgress(_ string, _, _ int64, stream io.ReadCloser) io.ReadCloser {
return stream
}

View File

@ -0,0 +1,3 @@
package packer
type uiProgressBar = NoopProgressTracker

View File

@ -3,7 +3,7 @@
# This script builds the application from source for multiple platforms. # This script builds the application from source for multiple platforms.
# Determine the arch/os combos we're building for # Determine the arch/os combos we're building for
ALL_XC_ARCH="386 amd64 arm arm64 ppc64le mips mips64 mipsle mipsle64 s390x" ALL_XC_ARCH="386 amd64 arm arm64 ppc64le mips mips64 mipsle mipsle64 s390x"
ALL_XC_OS="linux darwin windows freebsd openbsd" ALL_XC_OS="linux darwin windows freebsd openbsd solaris"
# Exit immediately if a command fails # Exit immediately if a command fails
set -e set -e

9
tty.go Normal file
View File

@ -0,0 +1,9 @@
// +build !solaris
package main
import (
"github.com/mattn/go-tty"
)
var openTTY = tty.Open

11
tty_solaris.go Normal file
View File

@ -0,0 +1,11 @@
package main
import (
"fmt"
"github.com/hashicorp/packer/packer"
)
func openTTY() (packer.TTY, error) {
return nil, fmt.Errorf("no TTY available on solaris")
}