@@ -50,7 +50,6 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
50
50
pm := commands .InitPackageManagerWithoutBundles ()
51
51
52
52
for _ , platformRef := range platformsRefs {
53
- downloadPlatformByRef (pm , platformRef )
54
53
installPlatformByRef (pm , platformRef )
55
54
}
56
55
@@ -64,19 +63,39 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
64
63
os .Exit (commands .ErrBadCall )
65
64
}
66
65
67
- // TODO: Check install prerequisites here
66
+ installPlatform (pm , platform , tools )
67
+ }
68
68
69
- // TODO: Download here
69
+ func installPlatform (pm * packagemanager.PackageManager , platformRelease * cores.PlatformRelease , requiredTools []* cores.ToolRelease ) {
70
+ log := pm .Log .WithField ("platform" , platformRelease )
70
71
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
+ }
73
86
}
74
- installPlatformRelease (pm , platform )
75
- }
76
87
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
+ }
79
97
98
+ // Are we installing or upgrading?
80
99
platform := platformRelease .Platform
81
100
installed := pm .GetInstalledPlatformRelease (platform )
82
101
if installed == nil {
@@ -87,12 +106,8 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
87
106
formatter .Print ("Updating " + installed .String () + " with " + platformRelease .String () + "..." )
88
107
}
89
108
109
+ // Install
90
110
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
- }
96
111
if err != nil {
97
112
log .WithError (err ).Error ("Cannot install platform" )
98
113
formatter .PrintError (err , "Cannot install platform" )
@@ -125,15 +140,15 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
125
140
func InstallToolRelease (pm * packagemanager.PackageManager , toolRelease * cores.ToolRelease ) {
126
141
log := pm .Log .WithField ("Tool" , toolRelease )
127
142
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 () {
133
144
log .Warn ("Tool already installed" )
134
145
formatter .Print ("Tool " + toolRelease .String () + " already installed" )
135
146
return
136
147
}
148
+
149
+ log .Info ("Installing tool" )
150
+ formatter .Print ("Installing " + toolRelease .String () + "..." )
151
+ err := pm .InstallTool (toolRelease )
137
152
if err != nil {
138
153
log .WithError (err ).Warn ("Cannot install tool" )
139
154
formatter .PrintError (err , "Cannot install tool: " + toolRelease .String ())
0 commit comments