feat(packages): implement PlanForce to reinstall all packages

Adds Reinstall method to PackageManager and AURHelper interfaces
so modules can invoke the concrete Reinstall helpers behind the
interface. *Pacman and *Yay already satisfy it.
This commit is contained in:
MDietermann
2026-04-14 21:55:08 +02:00
parent 613363e993
commit 58bd532dba
4 changed files with 37 additions and 2 deletions

View File

@@ -3,7 +3,6 @@ package packages
import (
"context"
"errors"
"fmt"
"strings"
@@ -75,5 +74,13 @@ 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")
if len(m.pkgs) == 0 {
return module.Plan{}, nil
}
pkgs := append([]string{}, m.pkgs...)
return module.Plan{Actions: []module.Action{{
Description: "pacman -S (force) " + strings.Join(pkgs, ", "),
Kind: module.ActionPackageInstall,
Exec: func(ctx context.Context) error { return m.pm.Reinstall(ctx, pkgs) },
}}}, nil
}