-
Notifications
You must be signed in to change notification settings - Fork 28
/
archs.go
33 lines (29 loc) · 862 Bytes
/
archs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package distri
import "strings"
// Architectures contains one entry for each known architecture identifier.
var Architectures = map[string]bool{
"amd64": true,
"i686": true,
"arm64": true,
}
// HasArchSuffix reports whether pkg ends in an architecture identifier
// (e.g. emacs-amd64) and returns the identifier.
func HasArchSuffix(pkg string) (archIdentifier string, ok bool) {
for a := range Architectures {
// unversioned, but ending in an architecture already (e.g. emacs-amd64)
if strings.HasSuffix(pkg, "-"+a) {
return a, true
}
}
return "", false
}
// LikelyFullySpecified returns true if the provided pkg contains an
// architecture suffix in the middle, e.g. systemd-amd64-239.
func LikelyFullySpecified(pkg string) bool {
for a := range Architectures {
if strings.Contains(pkg, "-"+a+"-") {
return true
}
}
return false
}