allow building packer on solaris by removing progress bar and tty imports

fix #7586
This commit is contained in:
Adrien Delorme 2019-05-07 15:58:49 +02:00
parent a6bb06c04e
commit 5f076d4328
8 changed files with 40 additions and 13 deletions

View File

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

View File

@ -22,7 +22,6 @@ import (
"github.com/hashicorp/packer/packer/plugin"
"github.com/hashicorp/packer/packer/tmp"
"github.com/hashicorp/packer/version"
"github.com/mattn/go-tty"
"github.com/mitchellh/cli"
"github.com/mitchellh/panicwrap"
"github.com/mitchellh/prefixedio"
@ -193,7 +192,7 @@ func wrappedMain() int {
}
ui = basicUi
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)
} else {
basicUi.TTY = TTY

View File

@ -1,3 +1,5 @@
// +build !solaris
package packer
import (
@ -78,12 +80,3 @@ type readCloser struct {
}
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.
# Determine the arch/os combos we're building for
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
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")
}