@@ -50,7 +50,6 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
5050 pm := commands .InitPackageManagerWithoutBundles ()
5151
5252 for _ , platformRef := range platformsRefs {
53- downloadPlatformByRef (pm , platformRef )
5453 installPlatformByRef (pm , platformRef )
5554 }
5655
@@ -64,19 +63,39 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
6463 os .Exit (commands .ErrBadCall )
6564 }
6665
67- // TODO: Check install prerequisites here
66+ installPlatform (pm , platform , tools )
67+ }
6868
69- // TODO: Download here
69+ func installPlatform (pm * packagemanager.PackageManager , platformRelease * cores.PlatformRelease , requiredTools []* cores.ToolRelease ) {
70+ log := pm .Log .WithField ("platform" , platformRelease )
7071
71- for _ , tool := range tools {
72- InstallToolRelease (pm , tool )
72+ // Prerequisite checks before install
73+ if platformRelease .IsInstalled () {
74+ log .Warn ("Platform already installed" )
75+ formatter .Print ("Platform " + platformRelease .String () + " already installed" )
76+ return
77+ }
78+ toolsToInstall := []* cores.ToolRelease {}
79+ for _ , tool := range requiredTools {
80+ if tool .IsInstalled () {
81+ log .WithField ("tool" , tool ).Warn ("Tool already installed" )
82+ formatter .Print ("Tool " + tool .String () + " already installed" )
83+ } else {
84+ toolsToInstall = append (toolsToInstall , tool )
85+ }
7386 }
74- installPlatformRelease (pm , platform )
75- }
7687
77- func installPlatformRelease (pm * packagemanager.PackageManager , platformRelease * cores.PlatformRelease ) {
78- log := pm .Log .WithField ("platform" , platformRelease )
88+ // Package download
89+ for _ , tool := range toolsToInstall {
90+ downloadTool (pm , tool )
91+ }
92+ downloadPlatform (pm , platformRelease )
93+
94+ for _ , tool := range toolsToInstall {
95+ InstallToolRelease (pm , tool )
96+ }
7997
98+ // Are we installing or upgrading?
8099 platform := platformRelease .Platform
81100 installed := pm .GetInstalledPlatformRelease (platform )
82101 if installed == nil {
@@ -87,12 +106,8 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
87106 formatter .Print ("Updating " + installed .String () + " with " + platformRelease .String () + "..." )
88107 }
89108
109+ // Install
90110 err := pm .InstallPlatform (platformRelease )
91- if os .IsExist (err ) {
92- log .Warn ("Platform already installed" )
93- formatter .Print ("Platform " + platformRelease .String () + " already installed" )
94- return
95- }
96111 if err != nil {
97112 log .WithError (err ).Error ("Cannot install platform" )
98113 formatter .PrintError (err , "Cannot install platform" )
@@ -125,15 +140,15 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
125140func InstallToolRelease (pm * packagemanager.PackageManager , toolRelease * cores.ToolRelease ) {
126141 log := pm .Log .WithField ("Tool" , toolRelease )
127142
128- log .Info ("Installing tool" )
129- formatter .Print ("Installing " + toolRelease .String ())
130-
131- err := pm .InstallTool (toolRelease )
132- if os .IsExist (err ) {
143+ if toolRelease .IsInstalled () {
133144 log .Warn ("Tool already installed" )
134145 formatter .Print ("Tool " + toolRelease .String () + " already installed" )
135146 return
136147 }
148+
149+ log .Info ("Installing tool" )
150+ formatter .Print ("Installing " + toolRelease .String () + "..." )
151+ err := pm .InstallTool (toolRelease )
137152 if err != nil {
138153 log .WithError (err ).Warn ("Cannot install tool" )
139154 formatter .PrintError (err , "Cannot install tool: " + toolRelease .String ())
0 commit comments