Shadow the flock pkg & add a noop filelock so that at least the solaris binary can be built
Without this the following error occurs: $ GOOS=solaris go build . # github.com/hashicorp/packer/vendor/github.com/gofrs/flock vendor/github.com/gofrs/flock/flock_unix.go:28:22: undefined: syscall.LOCK_EX vendor/github.com/gofrs/flock/flock_unix.go:39:22: undefined: syscall.LOCK_SH vendor/github.com/gofrs/flock/flock_unix.go:56:12: undefined: syscall.Flock vendor/github.com/gofrs/flock/flock_unix.go:66:12: undefined: syscall.Flock vendor/github.com/gofrs/flock/flock_unix.go:96:12: undefined: syscall.Flock vendor/github.com/gofrs/flock/flock_unix.go:96:42: undefined: syscall.LOCK_UN vendor/github.com/gofrs/flock/flock_unix.go:118:21: undefined: syscall.LOCK_EX vendor/github.com/gofrs/flock/flock_unix.go:130:21: undefined: syscall.LOCK_SH vendor/github.com/gofrs/flock/flock_unix.go:149:9: undefined: syscall.Flock vendor/github.com/gofrs/flock/flock_unix.go:149:44: undefined: syscall.LOCK_NB vendor/github.com/gofrs/flock/flock_unix.go:149:44: too many errors
This commit is contained in:
parent
5d9d43c01d
commit
d9e5145de9
|
@ -0,0 +1,11 @@
|
||||||
|
// +build !solaris
|
||||||
|
|
||||||
|
package filelock
|
||||||
|
|
||||||
|
import "github.com/gofrs/flock"
|
||||||
|
|
||||||
|
type Flock = flock.Flock
|
||||||
|
|
||||||
|
func New(path string) *Flock {
|
||||||
|
return flock.New(path)
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
// build solaris
|
||||||
|
|
||||||
|
package filelock
|
||||||
|
|
||||||
|
// Flock is a noop on solaris for now.
|
||||||
|
// TODO(azr): PR github.com/gofrs/flock for this.
|
||||||
|
type Flock = Noop
|
||||||
|
|
||||||
|
func New(string) *Flock {
|
||||||
|
return &Flock{}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package filelock
|
||||||
|
|
||||||
|
// this lock does nothing
|
||||||
|
type Noop struct{}
|
||||||
|
|
||||||
|
func (_ *Noop) Lock() (bool, error) { return true, nil }
|
||||||
|
func (_ *Noop) TryLock() (bool, error) { return true, nil }
|
||||||
|
func (_ *Noop) Unlock() error { return nil }
|
|
@ -8,8 +8,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gofrs/flock"
|
"github.com/hashicorp/packer/common/filelock"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ type Listener struct {
|
||||||
net.Listener
|
net.Listener
|
||||||
Port int
|
Port int
|
||||||
Address string
|
Address string
|
||||||
lock *flock.Flock
|
lock *filelock.Flock
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Listener) Close() error {
|
func (l *Listener) Close() error {
|
||||||
|
@ -70,7 +69,7 @@ func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
lock := flock.New(lockFilePath)
|
lock := filelock.New(lockFilePath)
|
||||||
locked, err := lock.TryLock()
|
locked, err := lock.TryLock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gofrs/flock"
|
|
||||||
getter "github.com/hashicorp/go-getter"
|
getter "github.com/hashicorp/go-getter"
|
||||||
urlhelper "github.com/hashicorp/go-getter/helper/url"
|
urlhelper "github.com/hashicorp/go-getter/helper/url"
|
||||||
|
"github.com/hashicorp/packer/common/filelock"
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
)
|
)
|
||||||
|
@ -146,7 +146,7 @@ func (s *StepDownload) download(ctx context.Context, ui packer.Ui, source string
|
||||||
lockFile := targetPath + ".lock"
|
lockFile := targetPath + ".lock"
|
||||||
|
|
||||||
log.Printf("Acquiring lock for: %s (%s)", u.String(), lockFile)
|
log.Printf("Acquiring lock for: %s (%s)", u.String(), lockFile)
|
||||||
lock := flock.New(lockFile)
|
lock := filelock.New(lockFile)
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue