|
| 1 | +// This file is part of arduino-cli. |
| 2 | +// |
| 3 | +// Copyright 2021 ARDUINO SA (http://www.arduino.cc/) |
| 4 | +// |
| 5 | +// This software is released under the GNU General Public License version 3, |
| 6 | +// which covers the main part of arduino-cli. |
| 7 | +// The terms of this license can be found at: |
| 8 | +// https://www.gnu.org/licenses/gpl-3.0.en.html |
| 9 | +// |
| 10 | +// You can be released from the requirements of the above licenses by purchasing |
| 11 | +// a commercial license. Buying such a license is mandatory if you want to |
| 12 | +// modify or otherwise use the software for commercial activities involving the |
| 13 | +// Arduino software without disclosing the source code of your own applications. |
| 14 | +// To purchase a commercial license, send an email to license@arduino.cc. |
| 15 | + |
| 16 | +package commands |
| 17 | + |
| 18 | +import ( |
| 19 | + "fmt" |
| 20 | + |
| 21 | + "github.com/arduino/arduino-cli/arduino/cores" |
| 22 | + "github.com/arduino/arduino-cli/arduino/cores/packagemanager" |
| 23 | + "github.com/arduino/arduino-cli/arduino/resources" |
| 24 | + semver "go.bug.st/relaxed-semver" |
| 25 | +) |
| 26 | + |
| 27 | +var ( |
| 28 | + mdnsDiscoveryVersion = semver.ParseRelaxed("1.0.0") |
| 29 | + mdnsDiscoveryFlavors = []*cores.Flavor{ |
| 30 | + { |
| 31 | + OS: "i686-pc-linux-gnu", |
| 32 | + Resource: &resources.DownloadResource{ |
| 33 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_32bit.tar.bz2", mdnsDiscoveryVersion), |
| 34 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_32bit.tar.gz", mdnsDiscoveryVersion), |
| 35 | + Size: 0, |
| 36 | + Checksum: "SHA-256:", |
| 37 | + CachePath: "tools", |
| 38 | + }, |
| 39 | + }, |
| 40 | + { |
| 41 | + OS: "x86_64-pc-linux-gnu", |
| 42 | + Resource: &resources.DownloadResource{ |
| 43 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_64bit.tar.bz2", mdnsDiscoveryVersion), |
| 44 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_64bit.tar.gz", mdnsDiscoveryVersion), |
| 45 | + Size: 0, |
| 46 | + Checksum: "SHA-256:", |
| 47 | + CachePath: "tools", |
| 48 | + }, |
| 49 | + }, |
| 50 | + { |
| 51 | + OS: "i686-mingw32", |
| 52 | + Resource: &resources.DownloadResource{ |
| 53 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Windows_32bit.zip", mdnsDiscoveryVersion), |
| 54 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Windows_32bit.zip", mdnsDiscoveryVersion), |
| 55 | + Size: 0, |
| 56 | + Checksum: "SHA-256:", |
| 57 | + CachePath: "tools", |
| 58 | + }, |
| 59 | + }, |
| 60 | + { |
| 61 | + OS: "x86_64-mingw32", |
| 62 | + Resource: &resources.DownloadResource{ |
| 63 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Windows_64bit.zip", mdnsDiscoveryVersion), |
| 64 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Windows_64bit.zip", mdnsDiscoveryVersion), |
| 65 | + Size: 0, |
| 66 | + Checksum: "SHA-256:", |
| 67 | + CachePath: "tools", |
| 68 | + }, |
| 69 | + }, |
| 70 | + { |
| 71 | + OS: "x86_64-apple-darwin", |
| 72 | + Resource: &resources.DownloadResource{ |
| 73 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_macOS_64bit.tar.bz2", mdnsDiscoveryVersion), |
| 74 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_macOS_64bit.tar.gz", mdnsDiscoveryVersion), |
| 75 | + Size: 0, |
| 76 | + Checksum: "SHA-256:", |
| 77 | + CachePath: "tools", |
| 78 | + }, |
| 79 | + }, |
| 80 | + { |
| 81 | + OS: "arm-linux-gnueabihf", |
| 82 | + Resource: &resources.DownloadResource{ |
| 83 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_ARMv6.tar.bz2", mdnsDiscoveryVersion), |
| 84 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_ARMv6.tar.gz", mdnsDiscoveryVersion), |
| 85 | + Size: 0, |
| 86 | + Checksum: "SHA-256:", |
| 87 | + CachePath: "tools", |
| 88 | + }, |
| 89 | + }, |
| 90 | + { |
| 91 | + OS: "arm64-linux-gnueabihf", |
| 92 | + Resource: &resources.DownloadResource{ |
| 93 | + ArchiveFileName: fmt.Sprintf("mdns-discovery_v%s_Linux_ARM64.tar.bz2", mdnsDiscoveryVersion), |
| 94 | + URL: fmt.Sprintf("https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v%s_Linux_ARM64.tar.gz", mdnsDiscoveryVersion), |
| 95 | + Size: 0, |
| 96 | + Checksum: "SHA-256:", |
| 97 | + CachePath: "tools", |
| 98 | + }, |
| 99 | + }, |
| 100 | + } |
| 101 | +) |
| 102 | + |
| 103 | +func getBuiltinMDNSDiscoveryTool(pm *packagemanager.PackageManager) *cores.ToolRelease { |
| 104 | + builtinPackage := pm.Packages.GetOrCreatePackage("builtin") |
| 105 | + mdnsDiscoveryTool := builtinPackage.GetOrCreateTool("mdns-discovery") |
| 106 | + mdnsDiscoveryToolRel := mdnsDiscoveryTool.GetOrCreateRelease(mdnsDiscoveryVersion) |
| 107 | + mdnsDiscoveryToolRel.Flavors = mdnsDiscoveryFlavors |
| 108 | + return mdnsDiscoveryToolRel |
| 109 | +} |
0 commit comments