feat: support matching several architectures
This commit is contained in:
parent
6bb0da5082
commit
fa23cdfc54
@ -68,13 +68,14 @@ type Package struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPackage(name, srcname, version, arch string) (p Package, err error) {
|
func NewPackage(name, srcname, version string, archs []string) (
|
||||||
|
p Package, err error) {
|
||||||
|
|
||||||
p.Name = name
|
p.Name = name
|
||||||
p.Source = srcname
|
p.Source = srcname
|
||||||
p.Version = version
|
p.Version = version
|
||||||
p.Arch = arch
|
|
||||||
|
|
||||||
p.Deb.Hash, err = p.getHash()
|
p.Arch, p.Deb.Hash, err = p.getHash(archs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -110,16 +111,19 @@ func NewPackage(name, srcname, version, arch string) (p Package, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Package) getHash() (hash string, err error) {
|
func (p Package) getHash(archs []string) (arch, hash string, err error) {
|
||||||
binfiles, err := mr.GetBinfiles(p.Name, p.Version)
|
binfiles, err := mr.GetBinfiles(p.Name, p.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, res := range binfiles.Result {
|
for _, res := range binfiles.Result {
|
||||||
if res.Architecture == p.Arch {
|
for _, allowedArch := range archs {
|
||||||
hash = res.Hash
|
if res.Architecture == allowedArch {
|
||||||
return
|
arch = res.Architecture
|
||||||
|
hash = res.Hash
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,8 +296,8 @@ func filtered(s string, filter []string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func Packages(srcname, version, arch, regex string,
|
func Packages(srcname, version, regex string, archs, filter []string) (
|
||||||
filter []string) (pkgs []Package, err error) {
|
pkgs []Package, err error) {
|
||||||
|
|
||||||
binpkgs, err := mr.GetBinpackages(srcname, version)
|
binpkgs, err := mr.GetBinpackages(srcname, version)
|
||||||
if err == mr.ErrNotFound {
|
if err == mr.ErrNotFound {
|
||||||
@ -314,7 +318,7 @@ func Packages(srcname, version, arch, regex string,
|
|||||||
log.Trace().Msgf("matched %v", res.Name)
|
log.Trace().Msgf("matched %v", res.Name)
|
||||||
|
|
||||||
var pkg Package
|
var pkg Package
|
||||||
pkg, err = NewPackage(res.Name, srcname, version, arch)
|
pkg, err = NewPackage(res.Name, srcname, version, archs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ func TestSourcePackageVersions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPackages(t *testing.T) {
|
func TestPackages(t *testing.T) {
|
||||||
packages, err := Packages("linux", "3.16.5-1", "amd64",
|
rx := `^linux-(image|headers)-[0-9\.\-]*-(common|amd64|amd64-unsigned)$`
|
||||||
`^linux-(image|headers)-[0-9\.\-]*-(common|amd64|amd64-unsigned)$`,
|
packages, err := Packages("linux", "3.16.5-1", rx,
|
||||||
[]string{})
|
[]string{"amd64", "all"}, []string{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user