Skip to content

Commit

Permalink
Merge pull request #246 from ramanverma2k/fix-233
Browse files Browse the repository at this point in the history
Notify if installing on linux with musl library
  • Loading branch information
mefellows authored Oct 26, 2022
2 parents eb77795 + 736262a commit 3bb31bc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func NewInstaller(opts ...installerConfig) (*Installer, error) {
log.Println("[WARN] amd64 architecture not detected, defaulting to x86_64. Behaviour may be undefined")
}

// Only perform a check if current OS is linux
if runtime.GOOS == "linux" {
err := i.checkMusl()
if err != nil {
return nil, err
}
}

return i, nil
}

Expand Down Expand Up @@ -311,6 +319,23 @@ func checkVersion(lib, version, versionRange string) error {
return fmt.Errorf("version %s of %s does not match constraint %s", version, lib, versionRange)
}

// checkMusl checks if the OS uses musl library instead of glibc
func (i *Installer) checkMusl() error {
lddPath, err := exec.LookPath("ldd")
if err != nil {
return fmt.Errorf("could not find ldd in environment path")
}

cmd := exec.Command(lddPath, "/bin/echo")
out, err := cmd.CombinedOutput()

if strings.Contains(string(out), "musl") {
log.Println("[WARN] Usage of musl library is known to cause problems, prefer using glibc instead.")
}

return err
}

// download template structure: "https://github.com/pact-foundation/pact-reference/releases/download/PACKAGE-vVERSION/LIBNAME-OS-ARCH.EXTENSION.gz"
var downloadTemplate = "https://github.com/pact-foundation/pact-reference/releases/download/%s-v%s/%s-%s-%s.%s.gz"

Expand Down

0 comments on commit 3bb31bc

Please sign in to comment.