Files
snack/dpkg/normalize.go
Tai Groot e5c749558f feat(apt,dpkg): implement capability interfaces
apt: VersionQuerier, Holder, Cleaner, FileOwner, RepoManager, KeyManager, NameNormalizer
dpkg: FileOwner, NameNormalizer

All new interfaces follow the existing pattern of exported methods on
struct delegating to unexported platform-specific functions. Mutating
operations use Lock/Unlock; read-only operations do not.

Platform stubs in _other.go files return ErrUnsupportedPlatform.
Compile-time interface checks added for all implemented interfaces.
2026-02-25 20:47:44 +00:00

22 lines
433 B
Go

package dpkg
import "strings"
func normalizeName(name string) string {
n, _ := parseArch(name)
return n
}
func parseArch(name string) (string, string) {
if idx := strings.LastIndex(name, ":"); idx >= 0 {
pkg := name[:idx]
arch := name[idx+1:]
switch arch {
case "amd64", "i386", "arm64", "armhf", "armel", "mips", "mipsel",
"mips64el", "ppc64el", "s390x", "all", "any":
return pkg, arch
}
}
return name, ""
}