@@ -17,13 +17,13 @@ package core
1717
1818import (
1919 "context"
20- "errors"
2120 "fmt"
2221
2322 "github.com/arduino/arduino-cli/arduino/cores"
2423 "github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2524 "github.com/arduino/arduino-cli/commands"
2625 rpc "github.com/arduino/arduino-cli/rpc/commands"
26+ "github.com/pkg/errors"
2727)
2828
2929// PlatformInstall FIXMEDOC
@@ -49,7 +49,7 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
4949 return nil , fmt .Errorf ("finding platform dependencies: %s" , err )
5050 }
5151
52- err = installPlatform (pm , platform , tools , downloadCB , taskCB )
52+ err = installPlatform (pm , platform , tools , downloadCB , taskCB , req . GetSkipPostInstall () )
5353 if err != nil {
5454 return nil , err
5555 }
@@ -64,7 +64,8 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
6464
6565func installPlatform (pm * packagemanager.PackageManager ,
6666 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 {
6869 log := pm .Log .WithField ("platform" , platformRelease )
6970
7071 // Prerequisite checks before install
@@ -138,6 +139,14 @@ func installPlatform(pm *packagemanager.PackageManager,
138139 }
139140 }
140141
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+
141150 log .Info ("Platform installed" )
142151 taskCB (& rpc.TaskProgress {Message : platformRelease .String () + " installed" , Completed : true })
143152 return nil
0 commit comments