Skip to content

Commit d9a54db

Browse files
committed
version strategy: zonkio's arm arch name are different from GOOARCH
on arm (32bit), use 'uname -m' to get the excact arm version
1 parent a50b550 commit d9a54db

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

version_strategy.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package embeddedpostgres
22

33
import (
44
"os"
5+
"os/exec"
56
"runtime"
7+
"strings"
68
)
79

810
// VersionStrategy provides a strategy that can be used to determine which version of Postgres should be used based on
@@ -14,8 +16,24 @@ func defaultVersionStrategy(config Config) VersionStrategy {
1416
goos := runtime.GOOS
1517
arch := runtime.GOARCH
1618

17-
// use alpine specific build
1819
if goos == "linux" {
20+
// the zonkyio/embedded-postgres-binaries project produces
21+
// arm binaries with the following name schema:
22+
// 32bit: arm32v6 / arm32v7
23+
// 64bit (aarch64): arm64v8
24+
if arch == "arm64" {
25+
arch += "v8"
26+
} else if arch == "arm" {
27+
if out, err := exec.Command("uname", "-m").Output(); err == nil {
28+
s := string(out)
29+
if strings.HasPrefix(s, "armv7") {
30+
arch += "32v7"
31+
} else if strings.HasPrefix(s, "armv6") {
32+
arch += "32v6"
33+
}
34+
}
35+
}
36+
// check alpine specific build
1937
if _, err := os.Stat("/etc/alpine-release"); err == nil {
2038
arch += "-alpine"
2139
}

0 commit comments

Comments
 (0)