@@ -32,7 +32,7 @@ import (
32
32
// DownloadAndInstallPlatformUpgrades runs a full installation process to upgrade the given platform.
33
33
// This method takes care of downloading missing archives, upgrading platforms and tools, and
34
34
// removing the previously installed platform/tools that are no longer needed after the upgrade.
35
- func (pm * PackageManager ) DownloadAndInstallPlatformUpgrades (
35
+ func (pme * Explorer ) DownloadAndInstallPlatformUpgrades (
36
36
platformRef * PlatformReference ,
37
37
downloadCB rpc.DownloadProgressCB ,
38
38
taskCB rpc.TaskProgressCB ,
@@ -43,11 +43,11 @@ func (pm *PackageManager) DownloadAndInstallPlatformUpgrades(
43
43
}
44
44
45
45
// Search the latest version for all specified platforms
46
- platform := pm .FindPlatform (platformRef )
46
+ platform := pme .FindPlatform (platformRef )
47
47
if platform == nil {
48
48
return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
49
49
}
50
- installed := pm .GetInstalledPlatformRelease (platform )
50
+ installed := pme .GetInstalledPlatformRelease (platform )
51
51
if installed == nil {
52
52
return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
53
53
}
@@ -57,11 +57,11 @@ func (pm *PackageManager) DownloadAndInstallPlatformUpgrades(
57
57
}
58
58
platformRef .PlatformVersion = latest .Version
59
59
60
- platformRelease , tools , err := pm .FindPlatformReleaseDependencies (platformRef )
60
+ platformRelease , tools , err := pme .FindPlatformReleaseDependencies (platformRef )
61
61
if err != nil {
62
62
return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
63
63
}
64
- if err := pm .DownloadAndInstallPlatformAndTools (platformRelease , tools , downloadCB , taskCB , skipPostInstall ); err != nil {
64
+ if err := pme .DownloadAndInstallPlatformAndTools (platformRelease , tools , downloadCB , taskCB , skipPostInstall ); err != nil {
65
65
return err
66
66
}
67
67
@@ -71,11 +71,11 @@ func (pm *PackageManager) DownloadAndInstallPlatformUpgrades(
71
71
// DownloadAndInstallPlatformAndTools runs a full installation process for the given platform and tools.
72
72
// This method takes care of downloading missing archives, installing/upgrading platforms and tools, and
73
73
// removing the previously installed platform/tools that are no longer needed after the upgrade.
74
- func (pm * PackageManager ) DownloadAndInstallPlatformAndTools (
74
+ func (pme * Explorer ) DownloadAndInstallPlatformAndTools (
75
75
platformRelease * cores.PlatformRelease , requiredTools []* cores.ToolRelease ,
76
76
downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB ,
77
77
skipPostInstall bool ) error {
78
- log := pm .log .WithField ("platform" , platformRelease )
78
+ log := pme .log .WithField ("platform" , platformRelease )
79
79
80
80
// Prerequisite checks before install
81
81
toolsToInstall := []* cores.ToolRelease {}
@@ -91,23 +91,23 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
91
91
// Package download
92
92
taskCB (& rpc.TaskProgress {Name : tr ("Downloading packages" )})
93
93
for _ , tool := range toolsToInstall {
94
- if err := pm .DownloadToolRelease (tool , nil , downloadCB ); err != nil {
94
+ if err := pme .DownloadToolRelease (tool , nil , downloadCB ); err != nil {
95
95
return err
96
96
}
97
97
}
98
- if err := pm .DownloadPlatformRelease (platformRelease , nil , downloadCB ); err != nil {
98
+ if err := pme .DownloadPlatformRelease (platformRelease , nil , downloadCB ); err != nil {
99
99
return err
100
100
}
101
101
taskCB (& rpc.TaskProgress {Completed : true })
102
102
103
103
// Install tools first
104
104
for _ , tool := range toolsToInstall {
105
- if err := pm .InstallTool (tool , taskCB ); err != nil {
105
+ if err := pme .InstallTool (tool , taskCB ); err != nil {
106
106
return err
107
107
}
108
108
}
109
109
110
- installed := pm .GetInstalledPlatformRelease (platformRelease .Platform )
110
+ installed := pme .GetInstalledPlatformRelease (platformRelease .Platform )
111
111
installedTools := []* cores.ToolRelease {}
112
112
if installed == nil {
113
113
// No version of this platform is installed
@@ -127,29 +127,29 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
127
127
// This must be done so tools used by the currently installed version are
128
128
// removed if not used also by the newly installed version.
129
129
var err error
130
- _ , installedTools , err = pm .FindPlatformReleaseDependencies (platformRef )
130
+ _ , installedTools , err = pme .FindPlatformReleaseDependencies (platformRef )
131
131
if err != nil {
132
132
return & arduino.NotFoundError {Message : tr ("Can't find dependencies for platform %s" , platformRef ), Cause : err }
133
133
}
134
134
}
135
135
136
136
// Install
137
- if err := pm .InstallPlatform (platformRelease ); err != nil {
137
+ if err := pme .InstallPlatform (platformRelease ); err != nil {
138
138
log .WithError (err ).Error ("Cannot install platform" )
139
139
return & arduino.FailedInstallError {Message : tr ("Cannot install platform" ), Cause : err }
140
140
}
141
141
142
142
// If upgrading remove previous release
143
143
if installed != nil {
144
- uninstallErr := pm .UninstallPlatform (installed , taskCB )
144
+ uninstallErr := pme .UninstallPlatform (installed , taskCB )
145
145
146
146
// In case of error try to rollback
147
147
if uninstallErr != nil {
148
148
log .WithError (uninstallErr ).Error ("Error upgrading platform." )
149
149
taskCB (& rpc.TaskProgress {Message : tr ("Error upgrading platform: %s" , uninstallErr )})
150
150
151
151
// Rollback
152
- if err := pm .UninstallPlatform (platformRelease , taskCB ); err != nil {
152
+ if err := pme .UninstallPlatform (platformRelease , taskCB ); err != nil {
153
153
log .WithError (err ).Error ("Error rolling-back changes." )
154
154
taskCB (& rpc.TaskProgress {Message : tr ("Error rolling-back changes: %s" , err )})
155
155
}
@@ -160,8 +160,8 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
160
160
// Uninstall unused tools
161
161
for _ , tool := range installedTools {
162
162
taskCB (& rpc.TaskProgress {Name : tr ("Uninstalling %s, tool is no more required" , tool )})
163
- if ! pm .IsToolRequired (tool ) {
164
- pm .UninstallTool (tool , taskCB )
163
+ if ! pme .IsToolRequired (tool ) {
164
+ pme .UninstallTool (tool , taskCB )
165
165
}
166
166
}
167
167
@@ -171,7 +171,7 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
171
171
if ! skipPostInstall {
172
172
log .Info ("Running post_install script" )
173
173
taskCB (& rpc.TaskProgress {Message : tr ("Configuring platform." )})
174
- if err := pm .RunPostInstallScript (platformRelease ); err != nil {
174
+ if err := pme .RunPostInstallScript (platformRelease ); err != nil {
175
175
taskCB (& rpc.TaskProgress {Message : tr ("WARNING cannot configure platform: %s" , err )})
176
176
}
177
177
} else {
@@ -223,7 +223,7 @@ func (pm *PackageManager) cacheInstalledJSON(platformRelease *cores.PlatformRele
223
223
224
224
// RunPostInstallScript runs the post_install.sh (or post_install.bat) script for the
225
225
// specified platformRelease.
226
- func (pm * PackageManager ) RunPostInstallScript (platformRelease * cores.PlatformRelease ) error {
226
+ func (pme * Explorer ) RunPostInstallScript (platformRelease * cores.PlatformRelease ) error {
227
227
if ! platformRelease .IsInstalled () {
228
228
return errors .New (tr ("platform not installed" ))
229
229
}
@@ -233,7 +233,7 @@ func (pm *PackageManager) RunPostInstallScript(platformRelease *cores.PlatformRe
233
233
}
234
234
postInstall := platformRelease .InstallDir .Join (postInstallFilename )
235
235
if postInstall .Exist () && postInstall .IsNotDir () {
236
- cmd , err := executils .NewProcessFromPath (pm .GetEnvVarsForSpawnedProcess (), postInstall )
236
+ cmd , err := executils .NewProcessFromPath (pme .GetEnvVarsForSpawnedProcess (), postInstall )
237
237
if err != nil {
238
238
return err
239
239
}
@@ -382,11 +382,11 @@ func (pm *PackageManager) UninstallTool(toolRelease *cores.ToolRelease, taskCB r
382
382
383
383
// IsToolRequired returns true if any of the installed platforms requires the toolRelease
384
384
// passed as parameter
385
- func (pm * PackageManager ) IsToolRequired (toolRelease * cores.ToolRelease ) bool {
385
+ func (pme * Explorer ) IsToolRequired (toolRelease * cores.ToolRelease ) bool {
386
386
// Search in all installed platforms
387
- for _ , targetPackage := range pm . Packages {
387
+ for _ , targetPackage := range pme . packages {
388
388
for _ , platform := range targetPackage .Platforms {
389
- if platformRelease := pm .GetInstalledPlatformRelease (platform ); platformRelease != nil {
389
+ if platformRelease := pme .GetInstalledPlatformRelease (platform ); platformRelease != nil {
390
390
if platformRelease .RequiresToolRelease (toolRelease ) {
391
391
return true
392
392
}
0 commit comments