1
+ /*
2
+ * This file is part of arduino-cli.
3
+ *
4
+ * Copyright 2018 ARDUINO SA (http://www.arduino.cc/)
5
+ *
6
+ * This software is released under the GNU General Public License version 3,
7
+ * which covers the main part of arduino-cli.
8
+ * The terms of this license can be found at:
9
+ * https://www.gnu.org/licenses/gpl-3.0.en.html
10
+ *
11
+ * You can be released from the requirements of the above licenses by purchasing
12
+ * a commercial license. Buying such a license is mandatory if you want to modify or
13
+ * otherwise use the software for commercial activities involving the Arduino
14
+ * software without disclosing the source code of your own applications. To purchase
15
+ * a commercial license, send an email to license@arduino.cc.
16
+ */
17
+
1
18
package core
2
19
3
20
import (
@@ -8,13 +25,18 @@ import (
8
25
"github.com/arduino/arduino-cli/arduino/cores"
9
26
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
10
27
"github.com/arduino/arduino-cli/commands"
11
- "github.com/arduino/arduino-cli/common/formatter"
12
28
"github.com/arduino/arduino-cli/rpc"
13
29
semver "go.bug.st/relaxed-semver"
14
30
)
15
31
16
32
func PlatformInstall (ctx context.Context , req * rpc.PlatformInstallReq ,
17
33
downloadCB commands.DownloadProgressCB , taskCB commands.TaskProgressCB ) (* rpc.PlatformInstallResp , error ) {
34
+
35
+ pm := commands .GetPackageManager (req )
36
+ if pm == nil {
37
+ return nil , errors .New ("invalid instance" )
38
+ }
39
+
18
40
var version * semver.Version
19
41
if req .Version != "" {
20
42
if v , err := semver .Parse (req .Version ); err == nil {
@@ -24,11 +46,6 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
24
46
}
25
47
}
26
48
27
- pm := commands .GetPackageManager (req )
28
- if pm == nil {
29
- return nil , errors .New ("invalid instance" )
30
- }
31
-
32
49
platform , tools , err := pm .FindPlatformReleaseDependencies (& packagemanager.PlatformReference {
33
50
Package : req .PlatformPackage ,
34
51
PlatformArchitecture : req .Architecture ,
@@ -119,7 +136,6 @@ func installPlatform(pm *packagemanager.PackageManager,
119
136
if err := pm .UninstallPlatform (platformRelease ); err != nil {
120
137
log .WithError (err ).Error ("Error rolling-back changes." )
121
138
taskCB (& rpc.TaskProgress {Message : "Error rolling-back changes: " + err .Error ()})
122
- //return fmt.Errorf("rolling-back changes: %s", err)
123
139
}
124
140
125
141
return fmt .Errorf ("updating platform: %s" , errUn )
@@ -146,8 +162,7 @@ func InstallToolRelease(pm *packagemanager.PackageManager, toolRelease *cores.To
146
162
err := pm .InstallTool (toolRelease )
147
163
if err != nil {
148
164
log .WithError (err ).Warn ("Cannot install tool" )
149
- formatter .PrintError (err , "Cannot install tool: " + toolRelease .String ())
150
- return fmt .Errorf ("Cannot install tool: " + toolRelease .String (), err )
165
+ return fmt .Errorf ("installing tool %s: %s" , toolRelease , err )
151
166
}
152
167
log .Info ("Tool installed" )
153
168
taskCB (& rpc.TaskProgress {Message : toolRelease .String () + " installed" , Completed : true })
0 commit comments