mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-19 19:45:12 +00:00
all: Mac OS X is now called macOS
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4694 LGTM: imsodin
This commit is contained in:
parent
e0931e201e
commit
050f9f8091
@ -87,8 +87,8 @@ D26E6ED000654A3E, available from https://syncthing.net/security.html and
|
||||
most key servers.
|
||||
|
||||
There is also a built in automatic upgrade mechanism (disabled in some
|
||||
distribution channels) which uses a compiled in ECDSA signature. Mac OS
|
||||
X binaries are also properly code signed.
|
||||
distribution channels) which uses a compiled in ECDSA signature. macOS
|
||||
binaries are also properly code signed.
|
||||
|
||||
## Documentation
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
This directory contains an example for running Syncthing in the
|
||||
background under Mac OS X.
|
||||
background under macOS.
|
||||
|
||||
1. Install the `syncthing` binary in a directory called `bin` in your
|
||||
home directory.
|
@ -2151,7 +2151,7 @@ angular.module('syncthing.core')
|
||||
}
|
||||
|
||||
var os = {
|
||||
'darwin': 'Mac OS X',
|
||||
'darwin': 'macOS',
|
||||
'dragonfly': 'DragonFly BSD',
|
||||
'freebsd': 'FreeBSD',
|
||||
'openbsd': 'OpenBSD',
|
||||
|
@ -225,15 +225,20 @@ func versionParts(v string) ([]int, []interface{}) {
|
||||
return release, prerelease
|
||||
}
|
||||
|
||||
func releaseName(tag string) string {
|
||||
func releaseNames(tag string) []string {
|
||||
// We must ensure that the release asset matches the expected naming
|
||||
// standard, containing both the architecture/OS and the tag name we
|
||||
// expect. This protects against malformed release data potentially
|
||||
// tricking us into doing a downgrade.
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
return fmt.Sprintf("syncthing-macosx-%s-%s.", runtime.GOARCH, tag)
|
||||
return []string{
|
||||
fmt.Sprintf("syncthing-macos-%s-%s.", runtime.GOARCH, tag),
|
||||
fmt.Sprintf("syncthing-macosx-%s-%s.", runtime.GOARCH, tag),
|
||||
}
|
||||
default:
|
||||
return fmt.Sprintf("syncthing-%s-%s-%s.", runtime.GOOS, runtime.GOARCH, tag)
|
||||
return []string{
|
||||
fmt.Sprintf("syncthing-%s-%s-%s.", runtime.GOOS, runtime.GOARCH, tag),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,13 +147,18 @@ func SelectLatestRelease(rels []Release, current string, upgradeToPreReleases bo
|
||||
l.Debugln("skipping pre-release", rel.Tag)
|
||||
continue
|
||||
}
|
||||
|
||||
expectedReleases := releaseNames(rel.Tag)
|
||||
nextAsset:
|
||||
for _, asset := range rel.Assets {
|
||||
assetName := path.Base(asset.Name)
|
||||
// Check for the architecture
|
||||
expectedRelease := releaseName(rel.Tag)
|
||||
if strings.HasPrefix(assetName, expectedRelease) {
|
||||
l.Debugln("selected", rel.Tag)
|
||||
selected = rel
|
||||
for _, expRel := range expectedReleases {
|
||||
if strings.HasPrefix(assetName, expRel) {
|
||||
l.Debugln("selected", rel.Tag)
|
||||
selected = rel
|
||||
break nextAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,14 +172,15 @@ func SelectLatestRelease(rels []Release, current string, upgradeToPreReleases bo
|
||||
|
||||
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
||||
func upgradeTo(binary string, rel Release) error {
|
||||
expectedRelease := releaseName(rel.Tag)
|
||||
l.Debugf("expected release asset %q", expectedRelease)
|
||||
expectedReleases := releaseNames(rel.Tag)
|
||||
for _, asset := range rel.Assets {
|
||||
assetName := path.Base(asset.Name)
|
||||
l.Debugln("considering release", assetName)
|
||||
|
||||
if strings.HasPrefix(assetName, expectedRelease) {
|
||||
return upgradeToURL(assetName, binary, asset.URL)
|
||||
for _, expRel := range expectedReleases {
|
||||
if strings.HasPrefix(assetName, expRel) {
|
||||
return upgradeToURL(assetName, binary, asset.URL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
package upgrade
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@ -100,7 +101,7 @@ func TestSelectedRelease(t *testing.T) {
|
||||
Prerelease: strings.Contains(c, "-"),
|
||||
Assets: []Asset{
|
||||
// There must be a matching asset or it will not get selected
|
||||
{Name: releaseName(c)},
|
||||
{Name: releaseNames(c)[0]},
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -115,3 +116,40 @@ func TestSelectedRelease(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectedReleaseMacOS(t *testing.T) {
|
||||
if runtime.GOOS != "darwin" {
|
||||
t.Skip("macOS only")
|
||||
}
|
||||
|
||||
// The alterantives that we expect should work
|
||||
assetNames := []string{
|
||||
"syncthing-macos-amd64-v0.14.47.tar.gz",
|
||||
"syncthing-macosx-amd64-v0.14.47.tar.gz",
|
||||
}
|
||||
|
||||
for _, assetName := range assetNames {
|
||||
// Provide one release with the given asset name
|
||||
rels := []Release{
|
||||
{
|
||||
Tag: "v0.14.47",
|
||||
Prerelease: false,
|
||||
Assets: []Asset{
|
||||
{Name: assetName},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Check that it is selected and the asset is as epected
|
||||
sel, err := SelectLatestRelease(rels, "v0.14.46", false)
|
||||
if err != nil {
|
||||
t.Fatal("Unexpected error:", err)
|
||||
}
|
||||
if sel.Tag != "v0.14.47" {
|
||||
t.Error("wrong tag selected:", sel.Tag)
|
||||
}
|
||||
if sel.Assets[0].Name != assetName {
|
||||
t.Error("wrong asset selected:", sel.Assets[0].Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user