Commit 928e5343 authored by Cristian Maglie's avatar Cristian Maglie

Added function PlatformRelease.RequiresToolRelease

This function will be usefult for cleanup during uninstall
parent 50ebe37a
......@@ -184,6 +184,19 @@ func (release *PlatformRelease) GetOrCreateBoard(boardID string) *Board {
return board
}
// RequiresToolRelease returns true if the PlatformRelease requires the
// toolReleased passed as parameter
func (release *PlatformRelease) RequiresToolRelease(toolRelease *ToolRelease) bool {
for _, toolDep := range release.Dependencies {
if toolDep.ToolName == toolRelease.Tool.Name &&
toolDep.ToolPackager == toolRelease.Tool.Package.Name &&
toolDep.ToolVersion == toolRelease.Version {
return true
}
}
return false
}
// RuntimeProperties returns the runtime properties for this PlatformRelease
func (release *PlatformRelease) RuntimeProperties() properties.Map {
return properties.Map{
......
......@@ -46,3 +46,19 @@ func (pm *PackageManager) InstallTool(toolRelease *cores.ToolRelease) error {
toolRelease.Version.String())
return toolResource.Install(pm.DownloadDir, pm.TempDir, destDir)
}
// IsToolRequired returns true if any of the installed platforms requires the toolRelease
// passed as parameter
func (pm *PackageManager) IsToolRequired(toolRelease *cores.ToolRelease) bool {
// Search in all installed platforms
for _, targetPackage := range pm.packages.Packages {
for _, platform := range targetPackage.Platforms {
if platformRelease := platform.GetInstalled(); platformRelease != nil {
if platformRelease.RequiresToolRelease(toolRelease) {
return true
}
}
}
}
return false
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment