@@ -17,13 +17,13 @@ package core
17
17
18
18
import (
19
19
"context"
20
- "errors"
21
20
"fmt"
22
21
23
22
"github.com/arduino/arduino-cli/arduino/cores"
24
23
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
25
24
"github.com/arduino/arduino-cli/commands"
26
25
rpc "github.com/arduino/arduino-cli/rpc/commands"
26
+ "github.com/pkg/errors"
27
27
)
28
28
29
29
// PlatformInstall FIXMEDOC
@@ -49,7 +49,7 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
49
49
return nil , fmt .Errorf ("finding platform dependencies: %s" , err )
50
50
}
51
51
52
- err = installPlatform (pm , platform , tools , downloadCB , taskCB )
52
+ err = installPlatform (pm , platform , tools , downloadCB , taskCB , req . GetSkipPostInstall () )
53
53
if err != nil {
54
54
return nil , err
55
55
}
@@ -64,7 +64,8 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
64
64
65
65
func installPlatform (pm * packagemanager.PackageManager ,
66
66
platformRelease * cores.PlatformRelease , requiredTools []* cores.ToolRelease ,
67
- downloadCB commands.DownloadProgressCB , taskCB commands.TaskProgressCB ) error {
67
+ downloadCB commands.DownloadProgressCB , taskCB commands.TaskProgressCB ,
68
+ skipPostInstall bool ) error {
68
69
log := pm .Log .WithField ("platform" , platformRelease )
69
70
70
71
// Prerequisite checks before install
@@ -138,6 +139,14 @@ func installPlatform(pm *packagemanager.PackageManager,
138
139
}
139
140
}
140
141
142
+ // Perform post install
143
+ if ! skipPostInstall && platformRelease .IsTrusted {
144
+ log .Info ("Running post_install script" )
145
+ if err := pm .RunPostInstallScript (platformRelease ); err != nil {
146
+ return errors .Errorf ("running post install: %s" , err )
147
+ }
148
+ }
149
+
141
150
log .Info ("Platform installed" )
142
151
taskCB (& rpc.TaskProgress {Message : platformRelease .String () + " installed" , Completed : true })
143
152
return nil
0 commit comments