Skip to content

Commit

Permalink
fix: Nethermind installation errors (#273)
Browse files Browse the repository at this point in the history
* Check for other archs supported by build

* Check for aarch as well

* Check nimbus
  • Loading branch information
Wolmin authored Dec 9, 2024
1 parent b51ae5a commit d07b652
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 41 deletions.
10 changes: 8 additions & 2 deletions common/system/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"os/exec"
"runtime"
"slices"
"strconv"
"strings"

Expand All @@ -21,8 +22,9 @@ const (
)

var (
Arch = runtime.GOARCH
Os = runtime.GOOS
Arch = runtime.GOARCH
Os = runtime.GOOS
SupportedArchs = []string{"x86_64", "aarch64", "arm", "i686"}
)

func IsRoot() (isRoot bool, err error) {
Expand Down Expand Up @@ -71,5 +73,9 @@ func GetArch() (arch string) {
fallback()
}

if !slices.Contains(SupportedArchs, arch) {
fallback()
}

return
}
7 changes: 3 additions & 4 deletions dependencies/clients/nethermind.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (n *NethermindClient) Start(ctx *cli.Context, arguments []string) (err erro
func (n *NethermindClient) ParseUrl(tag, commitHash string) (url string) {
url = n.baseUrl
osName := system.Os
archName := getUnameArch()
archName := system.GetArch()

if osName == system.Macos {
osName = "macos"
Expand All @@ -141,9 +141,8 @@ func (n *NethermindClient) ParseUrl(tag, commitHash string) (url string) {
if archName == "x86_64" {
archName = "x64"
}

if n.name == gethDependencyName && system.Os == system.Macos {
url = strings.Replace(url, "|ARCH|", "amd64", -1)
if archName == "arm" || archName == "aarch64" {
archName = "arm64"
}

url = strings.Replace(url, "|TAG|", tag, -1)
Expand Down
11 changes: 9 additions & 2 deletions dependencies/clients/nimbus2.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ func (n *Nimbus2Client) PrepareStartFlags(ctx *cli.Context) (startFlags []string
}

func (n *Nimbus2Client) ParseUrl(tag, commitHash string) (url string) {
var urlSystem string
var (
urlSystem string
arch = system.GetArch()
)

switch system.Os {
case system.Ubuntu:
Expand All @@ -63,11 +66,15 @@ func (n *Nimbus2Client) ParseUrl(tag, commitHash string) (url string) {
urlSystem = "Linux"
}

if arch == "arm" || arch == "aarch64" {
arch = "arm64v8"
}

url = n.baseUrl
url = strings.ReplaceAll(url, "|TAG|", tag)
url = strings.ReplaceAll(url, "|OS|", urlSystem)
url = strings.ReplaceAll(url, "|COMMIT|", commitHash)
url = strings.ReplaceAll(url, "|ARCH|", system.Arch)
url = strings.ReplaceAll(url, "|ARCH|", arch)

return
}
Expand Down
33 changes: 0 additions & 33 deletions dependencies/clients/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,39 +861,6 @@ func unzipDir(dst string, r *zip.Reader) (err error) {
return nil
}

func getUnameArch() (arch string) {
fallback := func() {
log.Info("⚠️ Unknown OS detected: proceeding with x86_64 as a default arch")
arch = "x86_64"
}

switch system.Os {
case system.Ubuntu, system.Macos:
buf := new(bytes.Buffer)

uname := exec.Command("uname", "-m")
uname.Stdout = buf

err := uname.Run()
if err != nil {
fallback()

break
}

arch = strings.Trim(buf.String(), "\n\t ")

default:
fallback()
}

if arch != "x86_64" && arch != "aarch64" {
fallback()
}

return
}

func isJdkInstalled() bool {
// JDK installed outside of the CLI
_, isInstalled := os.LookupEnv(system.JavaHomeEnv)
Expand Down

0 comments on commit d07b652

Please sign in to comment.