diff --git a/commands/bundle_tools_test.go b/commands/bundle_tools_test.go deleted file mode 100644 index a18666513ff..00000000000 --- a/commands/bundle_tools_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2021 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package commands - -import ( - "fmt" - "testing" - - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/resources" - "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" - "go.bug.st/downloader/v2" -) - -func TestBundledToolsDownloadAvailability(t *testing.T) { - tmp, err := paths.MkTempDir("", "") - require.NoError(t, err) - defer tmp.RemoveAll() - - downloadAndTestChecksum := func(r *resources.DownloadResource) { - fmt.Println("Testing:", r.URL) - d, err := r.Download(tmp, &downloader.Config{}) - require.NoError(t, err) - err = d.Run() - require.NoError(t, err) - - checksum, err := r.TestLocalArchiveIntegrity(tmp) - require.True(t, checksum) - require.NoError(t, err) - } - - toTest := [][]*cores.Flavor{ - serialMonitorFlavors, - ctagsFlavors, - serialDiscoveryFlavors, - mdnsDiscoveryFlavors, - } - for _, flavors := range toTest { - for _, resource := range flavors { - downloadAndTestChecksum(resource.Resource) - resource.Resource.ArchivePath(tmp) - } - } -} diff --git a/commands/bundled_tools_ctags.go b/commands/bundled_tools_ctags.go deleted file mode 100644 index 5caf410849d..00000000000 --- a/commands/bundled_tools_ctags.go +++ /dev/null @@ -1,100 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package commands - -import ( - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - "github.com/arduino/arduino-cli/arduino/resources" - "github.com/arduino/arduino-cli/i18n" - semver "go.bug.st/relaxed-semver" -) - -var tr = i18n.Tr - -var ( - ctagsVersion = semver.ParseRelaxed("5.8-arduino11") - ctagsFlavors = []*cores.Flavor{ - { - OS: "i686-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: "ctags-5.8-arduino11-pm-i686-pc-linux-gnu.tar.bz2", - URL: "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-i686-pc-linux-gnu.tar.bz2", - Size: 106930, - Checksum: "SHA-256:3e219116f54d9035f6c49c600d0bb358710dcce139798ad237de0eef7998d0e2", - CachePath: "tools", - }, - }, - { - OS: "x86_64-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: "ctags-5.8-arduino11-pm-x86_64-pc-linux-gnu.tar.bz2", - URL: "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-x86_64-pc-linux-gnu.tar.bz2", - Size: 111604, - Checksum: "SHA-256:62b514f3aaf37b5429ef703853bb46365fb91b4754c1916d085bf134004886e3", - CachePath: "tools", - }, - }, - { - OS: "i686-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: "ctags-5.8-arduino11-pm-i686-mingw32.zip", - URL: "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-i686-mingw32.zip", - Size: 116455, - Checksum: "SHA-256:106c9f074a3e2ec55bd8a461c1522bb4c90488275f061c3d51942862c99b8ba7", - CachePath: "tools", - }, - }, - { - OS: "x86_64-apple-darwin", - Resource: &resources.DownloadResource{ - ArchiveFileName: "ctags-5.8-arduino11-pm-x86_64-apple-darwin.zip", - URL: "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-x86_64-apple-darwin.zip", - Size: 118296, - Checksum: "SHA-256:bf74807260ddf0e1fc94d67e9cd8a41b7c0a2f0bee03e254e6975139b37ef250", - CachePath: "tools", - }, - }, - { - OS: "arm-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: "ctags-5.8-arduino11-pm-armv6-linux-gnueabihf.tar.bz2", - URL: "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-armv6-linux-gnueabihf.tar.bz2", - Size: 95271, - Checksum: "SHA-256:098e8dc6a7dc0ddf09ef28e6e2e81d2ae181d12f41fb182dd78ff1387d4eb285", - CachePath: "tools", - }, - }, - { - OS: "aarch64-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: "ctags-5.8-arduino11-pm-aarch64-linux-gnu.tar.bz2", - URL: "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-aarch64-linux-gnu.tar.bz2", - Size: 100819, - Checksum: "SHA-256:89b6f8adb7b7124ebe2eb30970ea77c754cd2239e0d8a6b0102ae2a36416c6ef", - CachePath: "tools", - }, - }, - } -) - -func getBuiltinCtagsTool(pm *packagemanager.PackageManager) *cores.ToolRelease { - builtinPackage := pm.Packages.GetOrCreatePackage("builtin") - ctagsTool := builtinPackage.GetOrCreateTool("ctags") - ctagsRel := ctagsTool.GetOrCreateRelease(ctagsVersion) - ctagsRel.Flavors = ctagsFlavors - return ctagsRel -} diff --git a/commands/bundled_tools_mdns_discovery.go b/commands/bundled_tools_mdns_discovery.go deleted file mode 100644 index 897ec8abe0e..00000000000 --- a/commands/bundled_tools_mdns_discovery.go +++ /dev/null @@ -1,109 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2021 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package commands - -import ( - "fmt" - - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - "github.com/arduino/arduino-cli/arduino/resources" - semver "go.bug.st/relaxed-semver" -) - -var ( - mdnsDiscoveryVersion = semver.ParseRelaxed("0.9.2") - mdnsDiscoveryFlavors = []*cores.Flavor{ - { - OS: "i686-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_Linux_32bit.tar.bz2", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_Linux_32bit.tar.gz", mdnsDiscoveryVersion), - Size: 2417970, - Checksum: "SHA-256:34afe67745c7d7e8d435fb668aa3e85a93d313b7a8a4bc13f7e3c5fe48db0fa8", - CachePath: "tools", - }, - }, - { - OS: "x86_64-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_Linux_64bit.tar.bz2", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_Linux_64bit.tar.gz", mdnsDiscoveryVersion), - Size: 2499458, - Checksum: "SHA-256:e97d9553590559e4b15239c4f8c86c9bd310aca3f0cdfd26098c5878b463f2ec", - CachePath: "tools", - }, - }, - { - OS: "i686-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_Windows_32bit.zip", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_Windows_32bit.zip", mdnsDiscoveryVersion), - Size: 2548123, - Checksum: "SHA-256:2493290856294f8bed3eed50c9ed4cda6a4a98b4c01cae6db7c1621f4db33afd", - CachePath: "tools", - }, - }, - { - OS: "x86_64-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_Windows_64bit.zip", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_Windows_64bit.zip", mdnsDiscoveryVersion), - Size: 2603561, - Checksum: "SHA-256:26ef37b3f331cd6cfbfd234431fe95a0c4aec8d8889286084e0c9012cb72ff1e", - CachePath: "tools", - }, - }, - { - OS: "x86_64-apple-darwin", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_macOS_64bit.tar.bz2", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_macOS_64bit.tar.gz", mdnsDiscoveryVersion), - Size: 2458693, - Checksum: "SHA-256:51c7c1c7a7a81e1224cfd55f84497cfae278c28124d10619a0f7adae29c0f45b", - CachePath: "tools", - }, - }, - { - OS: "arm-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_Linux_ARMv6.tar.bz2", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_Linux_ARMv6.tar.gz", mdnsDiscoveryVersion), - Size: 2321304, - Checksum: "SHA-256:cc1096936abddb21af23fa10c435e8e9e37ec9df2c3d2c41d265d466b03de0af", - CachePath: "tools", - }, - }, - { - OS: "arm64-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("mdns-discovery_%s_Linux_ARM64.tar.bz2", mdnsDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_%s_Linux_ARM64.tar.gz", mdnsDiscoveryVersion), - Size: 2328169, - Checksum: "SHA-256:820266009f7decf421c005d702e1b4da43ba2af03d2ddd73f5a3a91737774571", - CachePath: "tools", - }, - }, - } -) - -func getBuiltinMDNSDiscoveryTool(pm *packagemanager.PackageManager) *cores.ToolRelease { - builtinPackage := pm.Packages.GetOrCreatePackage("builtin") - mdnsDiscoveryTool := builtinPackage.GetOrCreateTool("mdns-discovery") - mdnsDiscoveryToolRel := mdnsDiscoveryTool.GetOrCreateRelease(mdnsDiscoveryVersion) - mdnsDiscoveryToolRel.Flavors = mdnsDiscoveryFlavors - return mdnsDiscoveryToolRel -} diff --git a/commands/bundled_tools_serial_discovery.go b/commands/bundled_tools_serial_discovery.go deleted file mode 100644 index a6f0ed97d0c..00000000000 --- a/commands/bundled_tools_serial_discovery.go +++ /dev/null @@ -1,109 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package commands - -import ( - "fmt" - - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - "github.com/arduino/arduino-cli/arduino/resources" - semver "go.bug.st/relaxed-semver" -) - -var ( - serialDiscoveryVersion = semver.ParseRelaxed("1.3.0-rc1") - serialDiscoveryFlavors = []*cores.Flavor{ - { - OS: "i686-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_32bit.tar.bz2", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_Linux_32bit.tar.gz", serialDiscoveryVersion), - Size: 1633143, - Checksum: "SHA-256:2fb17882018f3eefeaf933673cbc42cea83ce739503880ccc7f9cf521de0e513", - CachePath: "tools", - }, - }, - { - OS: "x86_64-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_64bit.tar.bz2", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_Linux_64bit.tar.gz", serialDiscoveryVersion), - Size: 1688362, - Checksum: "SHA-256:e0e55ea9c5e05f12af5d89dc3a69d63e12211f54122b4bf45a7cab9f0a6f89e5", - CachePath: "tools", - }, - }, - { - OS: "i686-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_32bit.zip", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_Windows_32bit.zip", serialDiscoveryVersion), - Size: 1742668, - Checksum: "SHA-256:4acfe521d6fc3b29643ab69ced246d7dd20637772fc79fc3e509829c18290d90", - CachePath: "tools", - }, - }, - { - OS: "x86_64-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_64bit.zip", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_Windows_64bit.zip", serialDiscoveryVersion), - Size: 1709333, - Checksum: "SHA-256:82b2edea04f7c97b98cbb04de95ec48be95de64fa5f196d730dc824d7558b952", - CachePath: "tools", - }, - }, - { - OS: "x86_64-apple-darwin", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_macOS_64bit.tar.bz2", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_macOS_64bit.tar.gz", serialDiscoveryVersion), - Size: 964596, - Checksum: "SHA-256:ec4be0f5c1ed6af3f31bb01ed6a5433274a76a1dc7cb68d39813b2b0475d7337", - CachePath: "tools", - }, - }, - { - OS: "arm-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARMv6.tar.bz2", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_Linux_ARMv6.tar.gz", serialDiscoveryVersion), - Size: 1570847, - Checksum: "SHA-256:9341e2541ad41ee2cdaad1e8d851254c8bce63c937cdafd57db7d1439d8ced59", - CachePath: "tools", - }, - }, - { - OS: "arm64-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM64.tar.bz2", serialDiscoveryVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v%s_Linux_ARM64.tar.gz", serialDiscoveryVersion), - Size: 1580108, - Checksum: "SHA-256:1da38f94be8db69bbe26d6a95692b665f6bc9bf89aa62b58d4e4cfb0f7fd8733", - CachePath: "tools", - }, - }, - } -) - -func getBuiltinSerialDiscoveryTool(pm *packagemanager.PackageManager) *cores.ToolRelease { - builtinPackage := pm.Packages.GetOrCreatePackage("builtin") - serialDiscoveryTool := builtinPackage.GetOrCreateTool("serial-discovery") - serialDiscoveryToolRel := serialDiscoveryTool.GetOrCreateRelease(serialDiscoveryVersion) - serialDiscoveryToolRel.Flavors = serialDiscoveryFlavors - return serialDiscoveryToolRel -} diff --git a/commands/bundled_tools_serial_monitor.go b/commands/bundled_tools_serial_monitor.go deleted file mode 100644 index 7634b05b2a8..00000000000 --- a/commands/bundled_tools_serial_monitor.go +++ /dev/null @@ -1,109 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package commands - -import ( - "fmt" - - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - "github.com/arduino/arduino-cli/arduino/resources" - semver "go.bug.st/relaxed-semver" -) - -var ( - serialMonitorVersion = semver.ParseRelaxed("0.9.1") - serialMonitorFlavors = []*cores.Flavor{ - { - OS: "i686-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_Linux_32bit.tar.bz2", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_Linux_32bit.tar.gz", serialMonitorVersion), - Size: 1899387, - Checksum: "SHA-256:3939282c9c74dd259a0ebd66d959133efafc8b50fd800860d8c1f634615b665c", - CachePath: "tools", - }, - }, - { - OS: "x86_64-pc-linux-gnu", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_Linux_64bit.tar.bz2", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_Linux_64bit.tar.gz", serialMonitorVersion), - Size: 1954589, - Checksum: "SHA-256:f121374fc33a66350381591816b2f2a0b0a108d70cf0ca01c59cc05186e6a5ce", - CachePath: "tools", - }, - }, - { - OS: "i686-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_Windows_32bit.zip", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_Windows_32bit.zip", serialMonitorVersion), - Size: 1956735, - Checksum: "SHA-256:15157e93618365cd959df57a9a25ccaa5a79d46a34f589e8711f571fe2e318e7", - CachePath: "tools", - }, - }, - { - OS: "x86_64-mingw32", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_Windows_64bit.zip", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_Windows_64bit.zip", serialMonitorVersion), - Size: 1990791, - Checksum: "SHA-256:e45561908526e855a7b9284ee438d2503cb21f9a5421fd840c1f10cd46b10b25", - CachePath: "tools", - }, - }, - { - OS: "x86_64-apple-darwin", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_macOS_64bit.tar.bz2", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_macOS_64bit.tar.gz", serialMonitorVersion), - Size: 1871195, - Checksum: "SHA-256:ebb4750e079ec893d89e9e256cd80b0e810a6cc17cd66189978f46246f52e14a", - CachePath: "tools", - }, - }, - { - OS: "arm-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_Linux_ARMv6.tar.bz2", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_Linux_ARMv6.tar.gz", serialMonitorVersion), - Size: 1829212, - Checksum: "SHA-256:bd2cf410f7fbcb43dbe6ea9bdf265585de96bf7247cb425d050537ee59d16355", - CachePath: "tools", - }, - }, - { - OS: "arm64-linux-gnueabihf", - Resource: &resources.DownloadResource{ - ArchiveFileName: fmt.Sprintf("serial-monitor_v%s_Linux_ARM64.tar.bz2", serialMonitorVersion), - URL: fmt.Sprintf("https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v%s_Linux_ARM64.tar.gz", serialMonitorVersion), - Size: 1837454, - Checksum: "SHA-256:be774d68c72fe7d79f9f6ec53f23e63e71793a15a60ed1210d51ec78c6fc0dc1", - CachePath: "tools", - }, - }, - } -) - -func getBuiltinSerialMonitorTool(pm *packagemanager.PackageManager) *cores.ToolRelease { - builtinPackage := pm.Packages.GetOrCreatePackage("builtin") - serialMonitorTool := builtinPackage.GetOrCreateTool("serial-monitor") - serialMonitorToolRel := serialMonitorTool.GetOrCreateRelease(serialMonitorVersion) - serialMonitorToolRel.Flavors = serialMonitorFlavors - return serialMonitorToolRel -} diff --git a/commands/instances.go b/commands/instances.go index dd9c4b28ece..f09b749e23b 100644 --- a/commands/instances.go +++ b/commands/instances.go @@ -36,6 +36,7 @@ import ( "github.com/arduino/arduino-cli/arduino/utils" "github.com/arduino/arduino-cli/cli/globals" "github.com/arduino/arduino-cli/configuration" + "github.com/arduino/arduino-cli/i18n" rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" paths "github.com/arduino/go-paths-helper" "github.com/sirupsen/logrus" @@ -44,6 +45,8 @@ import ( "google.golang.org/grpc/status" ) +var tr = i18n.Tr + // this map contains all the running Arduino Core Services instances // referenced by an int32 handle var instances = map[int32]*CoreInstance{} @@ -180,10 +183,6 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro // If this is not done the information of the uninstall core is kept in memory, // even if it should not. instance.PackageManager.Clear() - ctagsTool := getBuiltinCtagsTool(instance.PackageManager) - serialDiscoveryTool := getBuiltinSerialDiscoveryTool(instance.PackageManager) - mdnsDiscoveryTool := getBuiltinMDNSDiscoveryTool(instance.PackageManager) - serialMonitorRool := getBuiltinSerialMonitorTool(instance.PackageManager) // Load Platforms urls := []string{globals.DefaultIndexURL} @@ -256,48 +255,39 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro }) } - // Install tools if necessary - ctagsHasBeenInstalled, err := instance.installToolIfMissing(ctagsTool, downloadCallback, taskCallback) - if err != nil { - s := status.Newf(codes.Internal, err.Error()) - responseCallback(&rpc.InitResponse{ - Message: &rpc.InitResponse_Error{ - Error: s.Proto(), - }, - }) - } - - serialDiscoveryHasBeenInstalled, err := instance.installToolIfMissing(serialDiscoveryTool, downloadCallback, taskCallback) - if err != nil { - s := status.Newf(codes.Internal, err.Error()) - responseCallback(&rpc.InitResponse{ - Message: &rpc.InitResponse_Error{ - Error: s.Proto(), - }, - }) - } - - mdnsDiscoveryHasBeenInstalled, err := instance.installToolIfMissing(mdnsDiscoveryTool, downloadCallback, taskCallback) - if err != nil { - s := status.Newf(codes.Internal, err.Error()) - responseCallback(&rpc.InitResponse{ - Message: &rpc.InitResponse_Error{ - Error: s.Proto(), - }, - }) + // Get builtin tools + builtinToolReleases := []*cores.ToolRelease{} + for name, tool := range instance.PackageManager.Packages.GetOrCreatePackage("builtin").Tools { + latestRelease := tool.LatestRelease() + if latestRelease == nil { + s := status.Newf(codes.Internal, tr("can't find latest release of tool %s", name)) + responseCallback(&rpc.InitResponse{ + Message: &rpc.InitResponse_Error{ + Error: s.Proto(), + }, + }) + continue + } + builtinToolReleases = append(builtinToolReleases, latestRelease) } - serialMonitorHasBeenInstalled, err := instance.installToolIfMissing(serialMonitorRool, downloadCallback, taskCallback) - if err != nil { - s := status.Newf(codes.Internal, err.Error()) - responseCallback(&rpc.InitResponse{ - Message: &rpc.InitResponse_Error{ - Error: s.Proto(), - }, - }) + toolsHaveBeenInstalled := false + // Install tools if necessary + for _, toolRelease := range builtinToolReleases { + installed, err := instance.installToolIfMissing(toolRelease, downloadCallback, taskCallback) + if err != nil { + s := status.Newf(codes.Internal, err.Error()) + responseCallback(&rpc.InitResponse{ + Message: &rpc.InitResponse_Error{ + Error: s.Proto(), + }, + }) + continue + } + toolsHaveBeenInstalled = toolsHaveBeenInstalled || installed } - if ctagsHasBeenInstalled || serialDiscoveryHasBeenInstalled || mdnsDiscoveryHasBeenInstalled || serialMonitorHasBeenInstalled { + if toolsHaveBeenInstalled { // We installed at least one new tool after loading hardware // so we must reload again otherwise we would never found them. for _, err := range instance.PackageManager.LoadHardware() {