feat: add PackageUpgrader interface for targeted package upgrades

Add optional PackageUpgrader interface with UpgradePackages method
that upgrades specific installed packages (unlike Upgrade which
upgrades everything).

Each backend uses native upgrade commands:
- apt: apt-get install --only-upgrade
- dnf: dnf upgrade <pkg>
- pacman: pacman -S <pkg>
- apk: apk upgrade <pkg>
- pkg (FreeBSD): pkg upgrade <pkg>
- flatpak: flatpak update <pkg>
- snap: snap refresh <pkg>

Non-installed packages are filtered out and returned as Unchanged.

Closes #31
This commit is contained in:
2026-02-28 07:26:11 +00:00
parent 5629e41aeb
commit f2eff01ab4
22 changed files with 360 additions and 9 deletions

View File

@@ -85,3 +85,11 @@ func (p *Pkg) Version(ctx context.Context, pkg string) (string, error) {
// Verify interface compliance at compile time.
var _ snack.Manager = (*Pkg)(nil)
var _ snack.PackageUpgrader = (*Pkg)(nil)
// UpgradePackages upgrades specific installed packages.
func (p *Pkg) UpgradePackages(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) (snack.InstallResult, error) {
p.Lock()
defer p.Unlock()
return upgradePackages(ctx, pkgs, opts...)
}