From e212b64823219b74839c32e9bec90bf8d6d74ef3 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 28 Sep 2014 21:54:07 +0100 Subject: [PATCH] Fix build on Solaris --- internal/upgrade/upgrade_common.go | 9 +-------- internal/upgrade/upgrade_supported.go | 8 +++++++- internal/upgrade/upgrade_unsupp.go | 2 +- internal/upgrade/upgrade_windows.go | 8 +++++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/internal/upgrade/upgrade_common.go b/internal/upgrade/upgrade_common.go index 958935529..8c6e0fedf 100644 --- a/internal/upgrade/upgrade_common.go +++ b/internal/upgrade/upgrade_common.go @@ -9,8 +9,6 @@ import ( "errors" "strconv" "strings" - - "bitbucket.org/kardianos/osext" ) type Release struct { @@ -40,12 +38,7 @@ func init() { func UpgradeTo(rel Release, archExtra string) error { select { case <-upgradeUnlocked: - path, err := osext.Executable() - if err != nil { - upgradeUnlocked <- true - return err - } - err = upgradeTo(path, rel, archExtra) + err := upgradeTo(rel, archExtra) // If we've failed to upgrade, unlock so that another attempt could be made if err != nil { upgradeUnlocked <- true diff --git a/internal/upgrade/upgrade_supported.go b/internal/upgrade/upgrade_supported.go index e67f56080..58e9cdd99 100644 --- a/internal/upgrade/upgrade_supported.go +++ b/internal/upgrade/upgrade_supported.go @@ -19,10 +19,16 @@ import ( "path/filepath" "runtime" "strings" + + "bitbucket.org/kardianos/osext" ) // Upgrade to the given release, saving the previous binary with a ".old" extension. -func upgradeTo(path string, rel Release, archExtra string) error { +func upgradeTo(rel Release, archExtra string) error { + path, err := osext.Executable() + if err != nil { + return err + } osName := runtime.GOOS if osName == "darwin" { // We call the darwin release bundles macosx because that makes more diff --git a/internal/upgrade/upgrade_unsupp.go b/internal/upgrade/upgrade_unsupp.go index a9daca075..fb981d5f9 100644 --- a/internal/upgrade/upgrade_unsupp.go +++ b/internal/upgrade/upgrade_unsupp.go @@ -6,7 +6,7 @@ package upgrade -func upgradeTo(path string, rel Release, extra string) error { +func upgradeTo(rel Release, extra string) error { return ErrUpgradeUnsupported } diff --git a/internal/upgrade/upgrade_windows.go b/internal/upgrade/upgrade_windows.go index c09d76516..fcceca2eb 100755 --- a/internal/upgrade/upgrade_windows.go +++ b/internal/upgrade/upgrade_windows.go @@ -19,10 +19,16 @@ import ( "path/filepath" "runtime" "strings" + + "bitbucket.org/kardianos/osext" ) // Upgrade to the given release, saving the previous binary with a ".old" extension. -func upgradeTo(path string, rel Release, archExtra string) error { +func upgradeTo(rel Release, archExtra string) error { + path, err := osext.Executable() + if err != nil { + return err + } expectedRelease := fmt.Sprintf("syncthing-%s-%s%s-%s.", runtime.GOOS, runtime.GOARCH, archExtra, rel.Tag) if debug { l.Debugf("expected release asset %q", expectedRelease)