mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
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:
16
dpkg/dpkg.go
16
dpkg/dpkg.go
@@ -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...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user