Skip to content

Commit

Permalink
fix: change library installation flow (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Sep 13, 2024
1 parent e3f61d6 commit 97dedb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion utils/bash/bash_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func RunCmdAsync(
}

func ExecCommandWithStdout(cmd *exec.Cmd) (bytes.Buffer, error) {
fmt.Println(cmd.String())
var stderr bytes.Buffer
var stdout bytes.Buffer
cmd.Stderr = &stderr
Expand Down
16 changes: 8 additions & 8 deletions utils/dependencies/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func InstallBinaries(bech32 string, withMockDA bool) error {
c := exec.Command("sudo", "mkdir", "-p", consts.InternalBinsDir)
_, err := bash.ExecCommandWithStdout(c)
if err != nil {
errMsg := fmt.Sprintf("failed to create %s", consts.InternalBinsDir)
errMsg := fmt.Sprintf("failed to create %s\n", consts.InternalBinsDir)
return errors.New(errMsg)
}

Expand Down Expand Up @@ -124,14 +124,14 @@ func InstallBinaries(bech32 string, withMockDA bool) error {
libVersion := "v1.2.3"

if runtime.GOOS == "linux" {
outputPath = "/usr/lib/libwasmvm.so"
outputPath = "/usr/lib"
if runtime.GOARCH == "arm64" {
libName = "libwasmvm.aarch64.so"
} else if runtime.GOARCH == "amd64" {
libName = "libwasmvm.x86_64.so"
}
} else if runtime.GOOS == "darwin" {
outputPath = "/usr/local/lib/libwasmvm.dylib"
outputPath = "/usr/local/lib"
libName = "libwasmvm.dylib"
} else {
return errors.New("unsupported OS")
Expand All @@ -143,13 +143,13 @@ func InstallBinaries(bech32 string, withMockDA bool) error {
libName,
)

fsc := exec.Command("sudo", "mkdir", "-p", filepath.Dir(outputPath))
fsc := exec.Command("sudo", "mkdir", "-p", outputPath)
_, err := bash.ExecCommandWithStdout(fsc)
if err != nil {
return err
}

c := exec.Command("sudo", "wget", "-O", outputPath, downloadPath)
c := exec.Command("sudo", "wget", "-O", filepath.Join(outputPath, libName), downloadPath)
_, err = bash.ExecCommandWithStdout(c)
if err != nil {
return err
Expand Down Expand Up @@ -190,7 +190,7 @@ func InstallBinaries(bech32 string, withMockDA bool) error {
}

func InstallBinaryFromRepo(dep types.Dependency, td string) error {
pterm.Debug.Printf("Installing %s", dep.Name)
pterm.Debug.Printf("Installing %s\n", dep.Name)
targetDir, err := os.MkdirTemp(os.TempDir(), td)
if err != nil {
return err
Expand Down Expand Up @@ -224,7 +224,7 @@ func InstallBinaryFromRepo(dep types.Dependency, td string) error {
}

pterm.Info.Printf(
"starting %s build from %s (this can take several minutes)",
"starting %s build from %s (this can take several minutes)\n",
dep.Name,
dep.Release,
)
Expand All @@ -241,7 +241,7 @@ func InstallBinaryFromRepo(dep types.Dependency, td string) error {
return err
}
pterm.Success.Printf(
"Successfully installed %s", filepath.Base(binary.BinaryDestination),
"Successfully installed %s\n", filepath.Base(binary.BinaryDestination),
)
}
return nil
Expand Down

0 comments on commit 97dedb2

Please sign in to comment.