mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
fix(ports,detect): remove duplicate funcs and fix windows build
ports/capabilities_openbsd.go duplicated autoremove, clean, fileList, and owner already defined in ports_openbsd.go, breaking OpenBSD builds. detect/detect_other.go build tag didn't exclude windows, conflicting with detect_windows.go declarations.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
//go:build !linux && !freebsd && !openbsd && !darwin
|
//go:build !linux && !freebsd && !openbsd && !darwin && !windows
|
||||||
|
|
||||||
package detect
|
package detect
|
||||||
|
|
||||||
|
|||||||
@@ -78,40 +78,6 @@ func versionCmp(_ context.Context, ver1, ver2 string) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoremove(ctx context.Context, opts ...snack.Option) error {
|
|
||||||
o := snack.ApplyOptions(opts...)
|
|
||||||
_, err := runCmd(ctx, "pkg_delete", []string{"-a"}, o)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func clean(_ context.Context) error {
|
|
||||||
// OpenBSD does not maintain a package cache like FreeBSD/apt.
|
|
||||||
// Downloaded packages are removed after installation by default.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func fileList(ctx context.Context, pkg string) ([]string, error) {
|
|
||||||
out, err := runCmd(ctx, "pkg_info", []string{"-L", pkg}, snack.Options{})
|
|
||||||
if err != nil {
|
|
||||||
if strings.Contains(err.Error(), "exit status 1") {
|
|
||||||
return nil, fmt.Errorf("ports fileList %s: %w", pkg, snack.ErrNotInstalled)
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("ports fileList: %w", err)
|
|
||||||
}
|
|
||||||
return parseFileListOutput(out), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func owner(ctx context.Context, path string) (string, error) {
|
|
||||||
out, err := runCmd(ctx, "pkg_info", []string{"-E", path}, snack.Options{})
|
|
||||||
if err != nil {
|
|
||||||
if strings.Contains(err.Error(), "exit status 1") {
|
|
||||||
return "", fmt.Errorf("ports owner %s: %w", path, snack.ErrNotFound)
|
|
||||||
}
|
|
||||||
return "", fmt.Errorf("ports owner: %w", err)
|
|
||||||
}
|
|
||||||
return parseOwnerOutput(out), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func upgradePackages(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) (snack.InstallResult, error) {
|
func upgradePackages(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) (snack.InstallResult, error) {
|
||||||
o := snack.ApplyOptions(opts...)
|
o := snack.ApplyOptions(opts...)
|
||||||
var toUpgrade []snack.Target
|
var toUpgrade []snack.Target
|
||||||
|
|||||||
Reference in New Issue
Block a user