mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
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.
This commit is contained in:
21
dpkg/normalize.go
Normal file
21
dpkg/normalize.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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, ""
|
||||
}
|
||||
Reference in New Issue
Block a user