@@ -32,7 +32,7 @@ import (
3232// DownloadAndInstallPlatformUpgrades runs a full installation process to upgrade the given platform.
3333// This method takes care of downloading missing archives, upgrading platforms and tools, and
3434// removing the previously installed platform/tools that are no longer needed after the upgrade.
35- func (pm * PackageManager ) DownloadAndInstallPlatformUpgrades (
35+ func (pme * Explorer ) DownloadAndInstallPlatformUpgrades (
3636 platformRef * PlatformReference ,
3737 downloadCB rpc.DownloadProgressCB ,
3838 taskCB rpc.TaskProgressCB ,
@@ -43,11 +43,11 @@ func (pm *PackageManager) DownloadAndInstallPlatformUpgrades(
4343 }
4444
4545 // Search the latest version for all specified platforms
46- platform := pm .FindPlatform (platformRef )
46+ platform := pme .FindPlatform (platformRef )
4747 if platform == nil {
4848 return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
4949 }
50- installed := pm .GetInstalledPlatformRelease (platform )
50+ installed := pme .GetInstalledPlatformRelease (platform )
5151 if installed == nil {
5252 return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
5353 }
@@ -57,11 +57,11 @@ func (pm *PackageManager) DownloadAndInstallPlatformUpgrades(
5757 }
5858 platformRef .PlatformVersion = latest .Version
5959
60- platformRelease , tools , err := pm .FindPlatformReleaseDependencies (platformRef )
60+ platformRelease , tools , err := pme .FindPlatformReleaseDependencies (platformRef )
6161 if err != nil {
6262 return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
6363 }
64- if err := pm .DownloadAndInstallPlatformAndTools (platformRelease , tools , downloadCB , taskCB , skipPostInstall ); err != nil {
64+ if err := pme .DownloadAndInstallPlatformAndTools (platformRelease , tools , downloadCB , taskCB , skipPostInstall ); err != nil {
6565 return err
6666 }
6767
@@ -71,11 +71,11 @@ func (pm *PackageManager) DownloadAndInstallPlatformUpgrades(
7171// DownloadAndInstallPlatformAndTools runs a full installation process for the given platform and tools.
7272// This method takes care of downloading missing archives, installing/upgrading platforms and tools, and
7373// removing the previously installed platform/tools that are no longer needed after the upgrade.
74- func (pm * PackageManager ) DownloadAndInstallPlatformAndTools (
74+ func (pme * Explorer ) DownloadAndInstallPlatformAndTools (
7575 platformRelease * cores.PlatformRelease , requiredTools []* cores.ToolRelease ,
7676 downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB ,
7777 skipPostInstall bool ) error {
78- log := pm .log .WithField ("platform" , platformRelease )
78+ log := pme .log .WithField ("platform" , platformRelease )
7979
8080 // Prerequisite checks before install
8181 toolsToInstall := []* cores.ToolRelease {}
@@ -91,23 +91,23 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
9191 // Package download
9292 taskCB (& rpc.TaskProgress {Name : tr ("Downloading packages" )})
9393 for _ , tool := range toolsToInstall {
94- if err := pm .DownloadToolRelease (tool , nil , downloadCB ); err != nil {
94+ if err := pme .DownloadToolRelease (tool , nil , downloadCB ); err != nil {
9595 return err
9696 }
9797 }
98- if err := pm .DownloadPlatformRelease (platformRelease , nil , downloadCB ); err != nil {
98+ if err := pme .DownloadPlatformRelease (platformRelease , nil , downloadCB ); err != nil {
9999 return err
100100 }
101101 taskCB (& rpc.TaskProgress {Completed : true })
102102
103103 // Install tools first
104104 for _ , tool := range toolsToInstall {
105- if err := pm .InstallTool (tool , taskCB ); err != nil {
105+ if err := pme .InstallTool (tool , taskCB ); err != nil {
106106 return err
107107 }
108108 }
109109
110- installed := pm .GetInstalledPlatformRelease (platformRelease .Platform )
110+ installed := pme .GetInstalledPlatformRelease (platformRelease .Platform )
111111 installedTools := []* cores.ToolRelease {}
112112 if installed == nil {
113113 // No version of this platform is installed
@@ -127,29 +127,29 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
127127 // This must be done so tools used by the currently installed version are
128128 // removed if not used also by the newly installed version.
129129 var err error
130- _ , installedTools , err = pm .FindPlatformReleaseDependencies (platformRef )
130+ _ , installedTools , err = pme .FindPlatformReleaseDependencies (platformRef )
131131 if err != nil {
132132 return & arduino.NotFoundError {Message : tr ("Can't find dependencies for platform %s" , platformRef ), Cause : err }
133133 }
134134 }
135135
136136 // Install
137- if err := pm .InstallPlatform (platformRelease ); err != nil {
137+ if err := pme .InstallPlatform (platformRelease ); err != nil {
138138 log .WithError (err ).Error ("Cannot install platform" )
139139 return & arduino.FailedInstallError {Message : tr ("Cannot install platform" ), Cause : err }
140140 }
141141
142142 // If upgrading remove previous release
143143 if installed != nil {
144- uninstallErr := pm .UninstallPlatform (installed , taskCB )
144+ uninstallErr := pme .UninstallPlatform (installed , taskCB )
145145
146146 // In case of error try to rollback
147147 if uninstallErr != nil {
148148 log .WithError (uninstallErr ).Error ("Error upgrading platform." )
149149 taskCB (& rpc.TaskProgress {Message : tr ("Error upgrading platform: %s" , uninstallErr )})
150150
151151 // Rollback
152- if err := pm .UninstallPlatform (platformRelease , taskCB ); err != nil {
152+ if err := pme .UninstallPlatform (platformRelease , taskCB ); err != nil {
153153 log .WithError (err ).Error ("Error rolling-back changes." )
154154 taskCB (& rpc.TaskProgress {Message : tr ("Error rolling-back changes: %s" , err )})
155155 }
@@ -160,8 +160,8 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
160160 // Uninstall unused tools
161161 for _ , tool := range installedTools {
162162 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 )
165165 }
166166 }
167167
@@ -171,7 +171,7 @@ func (pm *PackageManager) DownloadAndInstallPlatformAndTools(
171171 if ! skipPostInstall {
172172 log .Info ("Running post_install script" )
173173 taskCB (& rpc.TaskProgress {Message : tr ("Configuring platform." )})
174- if err := pm .RunPostInstallScript (platformRelease ); err != nil {
174+ if err := pme .RunPostInstallScript (platformRelease ); err != nil {
175175 taskCB (& rpc.TaskProgress {Message : tr ("WARNING cannot configure platform: %s" , err )})
176176 }
177177 } else {
@@ -223,7 +223,7 @@ func (pm *PackageManager) cacheInstalledJSON(platformRelease *cores.PlatformRele
223223
224224// RunPostInstallScript runs the post_install.sh (or post_install.bat) script for the
225225// specified platformRelease.
226- func (pm * PackageManager ) RunPostInstallScript (platformRelease * cores.PlatformRelease ) error {
226+ func (pme * Explorer ) RunPostInstallScript (platformRelease * cores.PlatformRelease ) error {
227227 if ! platformRelease .IsInstalled () {
228228 return errors .New (tr ("platform not installed" ))
229229 }
@@ -233,7 +233,7 @@ func (pm *PackageManager) RunPostInstallScript(platformRelease *cores.PlatformRe
233233 }
234234 postInstall := platformRelease .InstallDir .Join (postInstallFilename )
235235 if postInstall .Exist () && postInstall .IsNotDir () {
236- cmd , err := executils .NewProcessFromPath (pm .GetEnvVarsForSpawnedProcess (), postInstall )
236+ cmd , err := executils .NewProcessFromPath (pme .GetEnvVarsForSpawnedProcess (), postInstall )
237237 if err != nil {
238238 return err
239239 }
@@ -382,11 +382,11 @@ func (pm *PackageManager) UninstallTool(toolRelease *cores.ToolRelease, taskCB r
382382
383383// IsToolRequired returns true if any of the installed platforms requires the toolRelease
384384// passed as parameter
385- func (pm * PackageManager ) IsToolRequired (toolRelease * cores.ToolRelease ) bool {
385+ func (pme * Explorer ) IsToolRequired (toolRelease * cores.ToolRelease ) bool {
386386 // Search in all installed platforms
387- for _ , targetPackage := range pm . Packages {
387+ for _ , targetPackage := range pme . packages {
388388 for _ , platform := range targetPackage .Platforms {
389- if platformRelease := pm .GetInstalledPlatformRelease (platform ); platformRelease != nil {
389+ if platformRelease := pme .GetInstalledPlatformRelease (platform ); platformRelease != nil {
390390 if platformRelease .RequiresToolRelease (toolRelease ) {
391391 return true
392392 }
0 commit comments