Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions arduino/cores/cores.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ func (dep *ToolDependency) String() string {

// GetOrCreateRelease returns the specified release corresponding the provided version,
// or creates a new one if not found.
func (platform *Platform) GetOrCreateRelease(version *semver.Version) (*PlatformRelease, error) {
func (platform *Platform) GetOrCreateRelease(version *semver.Version) *PlatformRelease {
tag := ""
if version != nil {
tag = version.String()
}
if release, ok := platform.Releases[tag]; ok {
return release, nil
return release
}
release := &PlatformRelease{
Version: version,
Expand All @@ -128,7 +128,7 @@ func (platform *Platform) GetOrCreateRelease(version *semver.Version) (*Platform
Platform: platform,
}
platform.Releases[tag] = release
return release, nil
return release
}

// FindReleaseWithVersion returns the specified release corresponding the provided version,
Expand Down
5 changes: 1 addition & 4 deletions arduino/cores/packageindex/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ func (inPlatformRelease indexPlatformRelease) extractPlatformIn(outPackage *core
if err != nil {
return fmt.Errorf("invalid platform archive size: %s", err)
}
outPlatformRelease, err := outPlatform.GetOrCreateRelease(inPlatformRelease.Version)
if err != nil {
return fmt.Errorf("creating release: %s", err)
}
outPlatformRelease := outPlatform.GetOrCreateRelease(inPlatformRelease.Version)
outPlatformRelease.IsTrusted = trusted
outPlatformRelease.Resource = &resources.DownloadResource{
ArchiveFileName: inPlatformRelease.ArchiveFileName,
Expand Down
10 changes: 2 additions & 8 deletions arduino/cores/packagemanager/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
}

platform := targetPackage.GetOrCreatePlatform(architecture)
release, err := platform.GetOrCreateRelease(version)
if err != nil {
return fmt.Errorf("loading platform release: %s", err)
}
release := platform.GetOrCreateRelease(version)
release.IsIDEBundled = isIDEBundled
if isIDEBundled {
pm.Log.Infof("Package is built-in")
Expand Down Expand Up @@ -246,10 +243,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
if err != nil {
return fmt.Errorf("invalid version dir %s: %s", versionDir, err)
}
release, err := platform.GetOrCreateRelease(version)
if err != nil {
return fmt.Errorf("loading platform release %s: %s", versionDir, err)
}
release := platform.GetOrCreateRelease(version)
if err := pm.loadPlatformRelease(release, versionDir); err != nil {
return fmt.Errorf("loading platform release %s: %s", versionDir, err)
}
Expand Down
42 changes: 20 additions & 22 deletions commands/bundled_tools_serial_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package commands
import (
"encoding/json"
"fmt"
"sync"
"time"

"github.com/arduino/arduino-cli/arduino/cores"
Expand All @@ -32,14 +31,13 @@ import (
)

var (
mutex = sync.Mutex{}
sdVersion = semver.ParseRelaxed("1.1.0")
flavors = []*cores.Flavor{
serialDiscoveryVersion = semver.ParseRelaxed("1.1.0")
serialDiscoveryFlavors = []*cores.Flavor{
{
OS: "i686-pc-linux-gnu",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_32bit.tar.bz2", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_32bit.tar.bz2", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_32bit.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_32bit.tar.bz2", serialDiscoveryVersion),
Size: 1589443,
Checksum: "SHA-256:e60fa16da2735f80410c636234a405bd1cc9306090cab4e312c4189e38f93f72",
CachePath: "tools",
Expand All @@ -48,8 +46,8 @@ var (
{
OS: "x86_64-pc-linux-gnu",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_64bit.tar.bz2", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_64bit.tar.bz2", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_64bit.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_64bit.tar.bz2", serialDiscoveryVersion),
Size: 1611875,
Checksum: "SHA-256:6232f852543094e9f73e1994e6888646fdcd24eca15fd4e5bde716a8e23046dc",
CachePath: "tools",
Expand All @@ -58,8 +56,8 @@ var (
{
OS: "i686-mingw32",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_32bit.zip", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_32bit.zip", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_32bit.zip", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_32bit.zip", serialDiscoveryVersion),
Size: 1719070,
Checksum: "SHA-256:3efdc744a0ca11c5f9088525eb4363e90e2b6a43a0db23c5c6975a10d739c7cb",
CachePath: "tools",
Expand All @@ -68,8 +66,8 @@ var (
{
OS: "x86_64-mingw32",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_64bit.zip", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_64bit.zip", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_64bit.zip", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_64bit.zip", serialDiscoveryVersion),
Size: 1683799,
Checksum: "SHA-256:c6296b92459160f4c0bf7d2e1234cd53fd64f44cb3fa8c3a4b10dd6670466c69",
CachePath: "tools",
Expand All @@ -78,8 +76,8 @@ var (
{
OS: "x86_64-apple-darwin",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_macOS_64bit.tar.bz2", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_macOS_64bit.tar.bz2", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_macOS_64bit.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_macOS_64bit.tar.bz2", serialDiscoveryVersion),
Size: 1620346,
Checksum: "SHA-256:4052a64dd68090726247dea7f03656eae951549df9878362dcedfcef116a9e9f",
CachePath: "tools",
Expand All @@ -88,8 +86,8 @@ var (
{
OS: "arm-linux-gnueabihf",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM.tar.bz2", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM.tar.bz2", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM.tar.bz2", serialDiscoveryVersion),
Size: 1511104,
Checksum: "SHA-256:fe68fd5abdfebe0f01c48c3eac16d27af46ec2391da87de44571e6ea2dab31e7",
CachePath: "tools",
Expand All @@ -98,8 +96,8 @@ var (
{
OS: "arm64-linux-gnueabihf",
Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM64.tar.bz2", sdVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM64.tar.bz2", sdVersion),
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM64.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM64.tar.bz2", serialDiscoveryVersion),
Size: 1500998,
Checksum: "SHA-256:1e6bcb6b7790d38863df15395c96baba239cb56233d7ef2d78bcb2b3efb1bc5d",
CachePath: "tools",
Expand Down Expand Up @@ -233,8 +231,8 @@ func WatchListBoards(pm *packagemanager.PackageManager) (<-chan *discovery.Event

func getBuiltinSerialDiscoveryTool(pm *packagemanager.PackageManager) (*cores.ToolRelease, error) {
builtinPackage := pm.Packages.GetOrCreatePackage("builtin")
ctagsTool := builtinPackage.GetOrCreateTool("serial-discovery")
ctagsRel := ctagsTool.GetOrCreateRelease(sdVersion)
ctagsRel.Flavors = flavors
return pm.Package("builtin").Tool("serial-discovery").Release(sdVersion).Get()
serialDiscoveryTool := builtinPackage.GetOrCreateTool("serial-discovery")
serialDiscoveryToolRel := serialDiscoveryTool.GetOrCreateRelease(serialDiscoveryVersion)
serialDiscoveryToolRel.Flavors = serialDiscoveryFlavors
return pm.Package("builtin").Tool("serial-discovery").Release(serialDiscoveryVersion).Get()
}
2 changes: 1 addition & 1 deletion commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (instance *CoreInstance) checkForBuiltinTools(downloadCB DownloadProgressCB
return err
}

// Check for bultin serial-discovery tool
// Check for builtin serial-discovery tool
serialDiscoveryTool, _ := getBuiltinSerialDiscoveryTool(instance.PackageManager)
serialDiscoveryInstalled, err := instance.installToolIfMissing(serialDiscoveryTool, downloadCB, taskCB)
if err != nil {
Expand Down