feat: add per-provider mutex and Target-aware implementations

- Add snack.Locker embed for per-provider mutex serialization
- Update all providers (pacman, apk, apt, dpkg) to use []Target
  with version pinning support (pkg=version syntax)
- Add lock/unlock to all mutating operations (Install, Remove, Purge,
  Upgrade, Update)
- Add snack.TargetNames helper and formatTargets per provider
- apt: add FromRepo (-t) and Reinstall support
- dpkg: use Target.Source for .deb file paths in Install
This commit is contained in:
2026-02-25 20:35:45 +00:00
parent 6cbfc96e3d
commit 0d6c5d9e17
14 changed files with 198 additions and 52 deletions

View File

@@ -8,7 +8,9 @@ import (
)
// Dpkg implements the snack.Manager interface using dpkg and dpkg-query.
type Dpkg struct{}
type Dpkg struct {
snack.Locker
}
// New returns a new Dpkg manager.
func New() *Dpkg {
@@ -19,17 +21,23 @@ func New() *Dpkg {
func (d *Dpkg) Name() string { return "dpkg" }
// Install one or more .deb files.
func (d *Dpkg) Install(ctx context.Context, pkgs []string, opts ...snack.Option) error {
func (d *Dpkg) Install(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) error {
d.Lock()
defer d.Unlock()
return install(ctx, pkgs, opts...)
}
// Remove one or more packages.
func (d *Dpkg) Remove(ctx context.Context, pkgs []string, opts ...snack.Option) error {
func (d *Dpkg) Remove(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) error {
d.Lock()
defer d.Unlock()
return remove(ctx, pkgs, opts...)
}
// Purge one or more packages including config files.
func (d *Dpkg) Purge(ctx context.Context, pkgs []string, opts ...snack.Option) error {
func (d *Dpkg) Purge(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) error {
d.Lock()
defer d.Unlock()
return purge(ctx, pkgs, opts...)
}