Account for backwards compatibility of ARM
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
e7e742d98d
commit
10893c07c3
8
build.go
8
build.go
|
@ -689,10 +689,14 @@ func archMatches(architectures []string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if slices.Contains(architectures, "arm") {
|
for _, arch := range architectures {
|
||||||
architectures = append(architectures, cpu.ARMVariant())
|
if strings.HasPrefix(arch, "arm") {
|
||||||
|
architectures = append(architectures, cpu.CompatibleARMReverse(arch)...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(architectures)
|
||||||
|
|
||||||
return slices.Contains(architectures, cpu.Arch())
|
return slices.Contains(architectures, cpu.Arch())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,55 @@ func ARMVariant() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CompatibleARM returns all the compatible ARM variants given the system architecture
|
||||||
|
func CompatibleARM(variant string) []string {
|
||||||
|
switch variant {
|
||||||
|
case "arm7", "arm":
|
||||||
|
return []string{"arm7", "arm6", "arm5"}
|
||||||
|
case "arm6":
|
||||||
|
return []string{"arm6", "arm5"}
|
||||||
|
case "arm5":
|
||||||
|
return []string{"arm5"}
|
||||||
|
default:
|
||||||
|
return []string{variant}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompatibleARMReverse returns all the compatible ARM variants given the package's architecture
|
||||||
|
func CompatibleARMReverse(variant string) []string {
|
||||||
|
switch variant {
|
||||||
|
case "arm7":
|
||||||
|
return []string{"arm7"}
|
||||||
|
case "arm6":
|
||||||
|
return []string{"arm6", "arm7"}
|
||||||
|
case "arm5", "arm":
|
||||||
|
return []string{"arm5", "arm6", "arm7"}
|
||||||
|
default:
|
||||||
|
return []string{variant}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Arch returns the canonical CPU architecture of the system
|
// Arch returns the canonical CPU architecture of the system
|
||||||
func Arch() string {
|
func Arch() string {
|
||||||
arch := os.Getenv("LURE_ARCH")
|
arch := os.Getenv("LURE_ARCH")
|
||||||
if arch != "" {
|
if arch == "" {
|
||||||
return arch
|
arch = runtime.GOARCH
|
||||||
}
|
}
|
||||||
arch = runtime.GOARCH
|
|
||||||
if arch == "arm" {
|
if arch == "arm" {
|
||||||
arch = ARMVariant()
|
arch = ARMVariant()
|
||||||
}
|
}
|
||||||
return arch
|
return arch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Arches returns all the architectures the system is compatible with
|
||||||
|
func Arches() []string {
|
||||||
|
arch := os.Getenv("LURE_ARCH")
|
||||||
|
if arch == "" {
|
||||||
|
arch = runtime.GOARCH
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(arch, "arm") {
|
||||||
|
return append(CompatibleARM(arch), "arm")
|
||||||
|
} else {
|
||||||
|
return []string{Arch()}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package overrides
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.elara.ws/lure/distro"
|
"go.elara.ws/lure/distro"
|
||||||
|
@ -59,13 +58,7 @@ func Resolve(info *distro.OSRelease, opts *Opts) ([]string, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
architectures := []string{runtime.GOARCH}
|
architectures := cpu.Arches()
|
||||||
|
|
||||||
if runtime.GOARCH == "arm" {
|
|
||||||
// More specific goes first
|
|
||||||
architectures[0] = cpu.ARMVariant()
|
|
||||||
architectures = append(architectures, "arm")
|
|
||||||
}
|
|
||||||
|
|
||||||
distros := []string{info.ID}
|
distros := []string{info.ID}
|
||||||
if opts.LikeDistros {
|
if opts.LikeDistros {
|
||||||
|
|
Loading…
Reference in New Issue