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
df7a4781
Commit
df7a4781
authored
Aug 20, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First implementation of 'core upgrade'
parent
aead8c8d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
7 deletions
+62
-7
commands/commands_test.go
commands/commands_test.go
+27
-1
commands/core/install.go
commands/core/install.go
+33
-2
commands/core/upgrade.go
commands/core/upgrade.go
+2
-4
No files found.
commands/commands_test.go
View file @
df7a4781
...
@@ -369,6 +369,32 @@ func TestCoreCommands(t *testing.T) {
...
@@ -369,6 +369,32 @@ func TestCoreCommands(t *testing.T) {
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"arduino:avr"
)
require
.
Contains
(
t
,
string
(
d
),
"arduino:avr"
)
// Upgrade platform
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"upgrade"
,
"arduino:avr@1.6.17"
)
require
.
NotZero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Invalid item arduino:avr@1.6.17"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"upgrade"
,
"other:avr"
)
require
.
NotZero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"other:avr not found"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"upgrade"
,
"arduino:samd"
)
require
.
NotZero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"arduino:samd is not installed"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"upgrade"
,
"arduino:avr"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Updating arduino:avr@1.6.16 with "
+
AVR
)
// List updatable cores
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"list"
,
"--updatable"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
NotContains
(
t
,
string
(
d
),
"arduino:avr"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"list"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"arduino:avr"
)
// Build sketch for arduino:avr:uno
// Build sketch for arduino:avr:uno
exitCode
,
d
=
executeWithArgs
(
t
,
"sketch"
,
"new"
,
"Test1"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"sketch"
,
"new"
,
"Test1"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
...
@@ -381,7 +407,7 @@ func TestCoreCommands(t *testing.T) {
...
@@ -381,7 +407,7 @@ func TestCoreCommands(t *testing.T) {
// Uninstall arduino:avr
// Uninstall arduino:avr
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"uninstall"
,
"arduino:avr"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"uninstall"
,
"arduino:avr"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"arduino:avr@1.6.16
uninstalled"
)
require
.
Contains
(
t
,
string
(
d
),
AVR
+
"
uninstalled"
)
// Empty cores list
// Empty cores list
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"list"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"core"
,
"list"
)
...
...
commands/core/install.go
View file @
df7a4781
...
@@ -52,6 +52,8 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
...
@@ -52,6 +52,8 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
downloadPlatformByRef
(
pm
,
platformRef
)
downloadPlatformByRef
(
pm
,
platformRef
)
installPlatformByRef
(
pm
,
platformRef
)
installPlatformByRef
(
pm
,
platformRef
)
}
}
// TODO: Cleanup unused tools
}
}
func
installPlatformByRef
(
pm
*
packagemanager
.
PackageManager
,
platformRef
*
packagemanager
.
PlatformReference
)
{
func
installPlatformByRef
(
pm
*
packagemanager
.
PackageManager
,
platformRef
*
packagemanager
.
PlatformReference
)
{
...
@@ -61,6 +63,10 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
...
@@ -61,6 +63,10 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
os
.
Exit
(
commands
.
ErrBadCall
)
os
.
Exit
(
commands
.
ErrBadCall
)
}
}
// TODO: Check install prerequisites here
// TODO: Download here
for
_
,
tool
:=
range
tools
{
for
_
,
tool
:=
range
tools
{
InstallToolRelease
(
pm
,
tool
)
InstallToolRelease
(
pm
,
tool
)
}
}
...
@@ -70,8 +76,15 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
...
@@ -70,8 +76,15 @@ func installPlatformByRef(pm *packagemanager.PackageManager, platformRef *packag
func
installPlatformRelease
(
pm
*
packagemanager
.
PackageManager
,
platformRelease
*
cores
.
PlatformRelease
)
{
func
installPlatformRelease
(
pm
*
packagemanager
.
PackageManager
,
platformRelease
*
cores
.
PlatformRelease
)
{
log
:=
pm
.
Log
.
WithField
(
"platform"
,
platformRelease
)
log
:=
pm
.
Log
.
WithField
(
"platform"
,
platformRelease
)
log
.
Info
(
"Installing platform"
)
platform
:=
platformRelease
.
Platform
formatter
.
Print
(
"Installing "
+
platformRelease
.
String
()
+
"..."
)
installed
:=
platform
.
GetInstalled
()
if
installed
==
nil
{
log
.
Info
(
"Installing platform"
)
formatter
.
Print
(
"Installing "
+
platformRelease
.
String
()
+
"..."
)
}
else
{
log
.
Info
(
"Updating platform "
+
installed
.
String
())
formatter
.
Print
(
"Updating "
+
installed
.
String
()
+
" with "
+
platformRelease
.
String
()
+
"..."
)
}
err
:=
pm
.
InstallPlatform
(
platformRelease
)
err
:=
pm
.
InstallPlatform
(
platformRelease
)
if
os
.
IsExist
(
err
)
{
if
os
.
IsExist
(
err
)
{
...
@@ -84,6 +97,24 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
...
@@ -84,6 +97,24 @@ func installPlatformRelease(pm *packagemanager.PackageManager, platformRelease *
os
.
Exit
(
commands
.
ErrGeneric
)
os
.
Exit
(
commands
.
ErrGeneric
)
}
}
// If upgrading remove previous release
if
installed
!=
nil
{
err
:=
pm
.
UninstallPlatform
(
installed
)
// In case of error try to rollback
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"Error updating platform."
)
formatter
.
PrintError
(
err
,
"Error updating platform"
)
// Rollback
if
err
:=
pm
.
UninstallPlatform
(
platformRelease
);
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"Error rolling-back changes."
)
formatter
.
PrintError
(
err
,
"Error rolling-back changes."
)
}
os
.
Exit
(
commands
.
ErrGeneric
)
}
}
log
.
Info
(
"Platform installed"
)
log
.
Info
(
"Platform installed"
)
formatter
.
Print
(
platformRelease
.
String
()
+
" installed"
)
formatter
.
Print
(
platformRelease
.
String
()
+
" installed"
)
}
}
...
...
commands/core/upgrade.go
View file @
df7a4781
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
package
core
package
core
import
(
import
(
"fmt"
"os"
"os"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
...
@@ -112,8 +111,7 @@ func upgrade(pm *packagemanager.PackageManager, platformsRefs []*packagemanager.
...
@@ -112,8 +111,7 @@ func upgrade(pm *packagemanager.PackageManager, platformsRefs []*packagemanager.
}
}
for
_
,
platformRef
:=
range
toInstallRefs
{
for
_
,
platformRef
:=
range
toInstallRefs
{
fmt
.
Printf
(
"Upgrading %s
\n
"
,
platformRef
)
downloadPlatformByRef
(
pm
,
platformRef
)
// downloadPlatformByRef(pm, platformRef)
installPlatformByRef
(
pm
,
platformRef
)
// installPlatformByRef(pm, platformRef)
}
}
}
}
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