feat(renode): implement PlanForce to reinstall packages and rewrite assets
This commit is contained in:
@@ -5,7 +5,6 @@ package renode
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"embed"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -188,5 +187,50 @@ func (m Module) Verify(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (m Module) PlanForce(ctx context.Context) (module.Plan, error) {
|
||||
return module.Plan{}, errors.New("PlanForce not implemented")
|
||||
bin, err := binPath()
|
||||
if err != nil {
|
||||
return module.Plan{}, err
|
||||
}
|
||||
rendered, err := m.renderSim()
|
||||
if err != nil {
|
||||
return module.Plan{}, err
|
||||
}
|
||||
simPath := filepath.Join(bin, "arduino-sim")
|
||||
wokwiPath := filepath.Join(bin, "wokwi-cli")
|
||||
|
||||
actions := []module.Action{
|
||||
{
|
||||
Description: "ensure yay installed",
|
||||
Kind: module.ActionPackageInstall,
|
||||
Exec: func(ctx context.Context) error { return m.aur.EnsureInstalled(ctx) },
|
||||
},
|
||||
{
|
||||
Description: "yay -S (force) renode-bin",
|
||||
Kind: module.ActionPackageInstall,
|
||||
Exec: func(ctx context.Context) error { return m.aur.Reinstall(ctx, []string{"renode-bin"}) },
|
||||
},
|
||||
{
|
||||
Description: "pacman -S (force) arm-none-eabi-gdb",
|
||||
Kind: module.ActionPackageInstall,
|
||||
Exec: func(ctx context.Context) error { return m.pm.Reinstall(ctx, []string{"arm-none-eabi-gdb"}) },
|
||||
},
|
||||
{
|
||||
Description: "rewrite arduino-sim helper (force)",
|
||||
Kind: module.ActionFileWrite,
|
||||
Exec: func(ctx context.Context) error {
|
||||
return platform.WriteUserFile(simPath, rendered, 0o755)
|
||||
},
|
||||
},
|
||||
{
|
||||
Description: "redownload wokwi-cli " + m.cfg.WokwiVersion + " (force)",
|
||||
Kind: module.ActionFileWrite,
|
||||
Exec: func(ctx context.Context) error {
|
||||
if err := os.MkdirAll(filepath.Dir(wokwiPath), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
return platform.Download(ctx, m.cfg.WokwiURL, wokwiPath, 0o755)
|
||||
},
|
||||
},
|
||||
}
|
||||
return module.Plan{Actions: actions}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user