Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
eb0f5d53
Commit
eb0f5d53
authored
Nov 02, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved core install/uninstall precodition checks
parent
3dcd1ca4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
36 deletions
+56
-36
arduino/cores/cores.go
arduino/cores/cores.go
+5
-0
commands/core/download.go
commands/core/download.go
+16
-16
commands/core/install.go
commands/core/install.go
+34
-19
commands/core/uninstall.go
commands/core/uninstall.go
+1
-1
No files found.
arduino/cores/cores.go
View file @
eb0f5d53
...
...
@@ -214,6 +214,11 @@ func (release *PlatformRelease) GetLibrariesDir() *paths.Path {
return
nil
}
// IsInstalled returns true if the PlatformRelease is installed
func
(
release
*
PlatformRelease
)
IsInstalled
()
bool
{
return
release
.
InstallDir
!=
nil
}
func
(
release
*
PlatformRelease
)
String
()
string
{
version
:=
""
if
release
.
Version
!=
nil
{
...
...
commands/core/download.go
View file @
eb0f5d53
...
...
@@ -60,31 +60,30 @@ func downloadPlatformByRef(pm *packagemanager.PackageManager, platformsRef *pack
formatter
.
PrintError
(
err
,
"Could not determine platform dependencies"
)
os
.
Exit
(
commands
.
ErrBadCall
)
}
// Check if all tools have a flavor available for the current OS
downloadPlatform
(
pm
,
platform
)
for
_
,
tool
:=
range
tools
{
if
tool
.
GetCompatibleFlavour
()
==
nil
{
formatter
.
PrintErrorMessage
(
"The tool "
+
tool
.
String
()
+
" is not available for the current OS"
)
os
.
Exit
(
commands
.
ErrGeneric
)
}
downloadTool
(
pm
,
tool
)
}
}
// Download tools
for
_
,
tool
:=
range
tools
{
DownloadToolRelease
(
pm
,
tool
)
}
func
downloadPlatform
(
pm
*
packagemanager
.
PackageManager
,
platformRelease
*
cores
.
PlatformRelease
)
{
// Download platform
resp
,
err
:=
pm
.
DownloadPlatformRelease
(
platformRelease
)
download
(
resp
,
err
,
platformRelease
.
String
())
}
// Download cores
formatter
.
Print
(
"Downloading "
+
platform
.
String
()
+
"..."
)
resp
,
err
:=
pm
.
DownloadPlatformRelease
(
platform
)
download
(
resp
,
err
,
platform
.
String
())
func
downloadTool
(
pm
*
packagemanager
.
PackageManager
,
tool
*
cores
.
ToolRelease
)
{
// Check if tool has a flavor available for the current OS
if
tool
.
GetCompatibleFlavour
()
==
nil
{
formatter
.
PrintErrorMessage
(
"The tool "
+
tool
.
String
()
+
" is not available for the current OS"
)
os
.
Exit
(
commands
.
ErrGeneric
)
}
logrus
.
Info
(
"Done"
)
DownloadToolRelease
(
pm
,
tool
)
}
// DownloadToolRelease downloads a ToolRelease
func
DownloadToolRelease
(
pm
*
packagemanager
.
PackageManager
,
toolRelease
*
cores
.
ToolRelease
)
{
formatter
.
Print
(
"Downloading "
+
toolRelease
.
String
()
+
"..."
)
resp
,
err
:=
pm
.
DownloadToolRelease
(
toolRelease
)
download
(
resp
,
err
,
toolRelease
.
String
())
}
...
...
@@ -98,6 +97,7 @@ func download(d *downloader.Downloader, err error, label string) {
formatter
.
Print
(
label
+
" already downloaded"
)
return
}
formatter
.
Print
(
"Downloading "
+
label
+
"..."
)
formatter
.
DownloadProgressBar
(
d
,
label
)
if
d
.
Error
()
!=
nil
{
formatter
.
PrintError
(
d
.
Error
(),
"Error downloading "
+
label
)
...
...
commands/core/install.go
View file @
eb0f5d53
...
...
@@ -50,7 +50,6 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
pm
:=
commands
.
InitPackageManagerWithoutBundles
()
for
_
,
platformRef
:=
range
platformsRefs
{
downloadPlatformByRef
(
pm
,
platformRef
)
installPlatformByRef
(
pm
,
platformRef
)
}
...
...
@@ -64,19 +63,39 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
os
.
Exit
(
commands
.
ErrBadCall
)
}
// TODO: Check install prerequisites here
installPlatform
(
pm
,
platform
,
tools
)
}
// TODO: Download here
func
installPlatform
(
pm
*
packagemanager
.
PackageManager
,
platformRelease
*
cores
.
PlatformRelease
,
requiredTools
[]
*
cores
.
ToolRelease
)
{
log
:=
pm
.
Log
.
WithField
(
"platform"
,
platformRelease
)
for
_
,
tool
:=
range
tools
{
InstallToolRelease
(
pm
,
tool
)
// Prerequisite checks before install
if
platformRelease
.
IsInstalled
()
{
log
.
Warn
(
"Platform already installed"
)
formatter
.
Print
(
"Platform "
+
platformRelease
.
String
()
+
" already installed"
)
return
}
toolsToInstall
:=
[]
*
cores
.
ToolRelease
{}
for
_
,
tool
:=
range
requiredTools
{
if
tool
.
IsInstalled
()
{
log
.
WithField
(
"tool"
,
tool
)
.
Warn
(
"Tool already installed"
)
formatter
.
Print
(
"Tool "
+
tool
.
String
()
+
" already installed"
)
}
else
{
toolsToInstall
=
append
(
toolsToInstall
,
tool
)
}
}
installPlatformRelease
(
pm
,
platform
)
}
func
installPlatformRelease
(
pm
*
packagemanager
.
PackageManager
,
platformRelease
*
cores
.
PlatformRelease
)
{
log
:=
pm
.
Log
.
WithField
(
"platform"
,
platformRelease
)
// Package download
for
_
,
tool
:=
range
toolsToInstall
{
downloadTool
(
pm
,
tool
)
}
downloadPlatform
(
pm
,
platformRelease
)
for
_
,
tool
:=
range
toolsToInstall
{
InstallToolRelease
(
pm
,
tool
)
}
// Are we installing or upgrading?
platform
:=
platformRelease
.
Platform
installed
:=
pm
.
GetInstalledPlatformRelease
(
platform
)
if
installed
==
nil
{
...
...
@@ -87,12 +106,8 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
formatter
.
Print
(
"Updating "
+
installed
.
String
()
+
" with "
+
platformRelease
.
String
()
+
"..."
)
}
// Install
err
:=
pm
.
InstallPlatform
(
platformRelease
)
if
os
.
IsExist
(
err
)
{
log
.
Warn
(
"Platform already installed"
)
formatter
.
Print
(
"Platform "
+
platformRelease
.
String
()
+
" already installed"
)
return
}
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"Cannot install platform"
)
formatter
.
PrintError
(
err
,
"Cannot install platform"
)
...
...
@@ -125,15 +140,15 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
func
InstallToolRelease
(
pm
*
packagemanager
.
PackageManager
,
toolRelease
*
cores
.
ToolRelease
)
{
log
:=
pm
.
Log
.
WithField
(
"Tool"
,
toolRelease
)
log
.
Info
(
"Installing tool"
)
formatter
.
Print
(
"Installing "
+
toolRelease
.
String
())
err
:=
pm
.
InstallTool
(
toolRelease
)
if
os
.
IsExist
(
err
)
{
if
toolRelease
.
IsInstalled
()
{
log
.
Warn
(
"Tool already installed"
)
formatter
.
Print
(
"Tool "
+
toolRelease
.
String
()
+
" already installed"
)
return
}
log
.
Info
(
"Installing tool"
)
formatter
.
Print
(
"Installing "
+
toolRelease
.
String
()
+
"..."
)
err
:=
pm
.
InstallTool
(
toolRelease
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Warn
(
"Cannot install tool"
)
formatter
.
PrintError
(
err
,
"Cannot install tool: "
+
toolRelease
.
String
())
...
...
commands/core/uninstall.go
View file @
eb0f5d53
...
...
@@ -103,7 +103,7 @@ func uninstallToolRelease(pm *packagemanager.PackageManager, toolRelease *cores.
log
:=
pm
.
Log
.
WithField
(
"Tool"
,
toolRelease
)
log
.
Info
(
"Uninstalling tool"
)
formatter
.
Print
(
"Uninstalling "
+
toolRelease
.
String
())
formatter
.
Print
(
"Uninstalling "
+
toolRelease
.
String
()
+
"..."
)
if
err
:=
pm
.
UninstallTool
(
toolRelease
);
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"Error uninstalling"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment