build source
This commit is contained in:
commit
ee1fec43ed
4171 changed files with 1351288 additions and 0 deletions
68
vendor/github.com/fergusstrange/embedded-postgres/version_strategy.go
generated
vendored
Normal file
68
vendor/github.com/fergusstrange/embedded-postgres/version_strategy.go
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package embeddedpostgres
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// VersionStrategy provides a strategy that can be used to determine which version of Postgres should be used based on
|
||||
// the operating system, architecture and desired Postgres version.
|
||||
type VersionStrategy func() (operatingSystem string, architecture string, postgresVersion PostgresVersion)
|
||||
|
||||
func defaultVersionStrategy(config Config, goos, arch string, linuxMachineName func() string, shouldUseAlpineLinuxBuild func() bool) VersionStrategy {
|
||||
return func() (string, string, PostgresVersion) {
|
||||
goos := goos
|
||||
arch := arch
|
||||
|
||||
if goos == "linux" {
|
||||
// the zonkyio/embedded-postgres-binaries project produces
|
||||
// arm binaries with the following name schema:
|
||||
// 32bit: arm32v6 / arm32v7
|
||||
// 64bit (aarch64): arm64v8
|
||||
if arch == "arm64" {
|
||||
arch += "v8"
|
||||
} else if arch == "arm" {
|
||||
machineName := linuxMachineName()
|
||||
if strings.HasPrefix(machineName, "armv7") {
|
||||
arch += "32v7"
|
||||
} else if strings.HasPrefix(machineName, "armv6") {
|
||||
arch += "32v6"
|
||||
}
|
||||
}
|
||||
|
||||
if shouldUseAlpineLinuxBuild() {
|
||||
arch += "-alpine"
|
||||
}
|
||||
}
|
||||
|
||||
// postgres below version 14.2 is not available for macos on arm
|
||||
if goos == "darwin" && arch == "arm64" {
|
||||
var majorVer, minorVer int
|
||||
if _, err := fmt.Sscanf(string(config.version), "%d.%d", &majorVer, &minorVer); err == nil &&
|
||||
(majorVer < 14 || (majorVer == 14 && minorVer < 2)) {
|
||||
arch = "amd64"
|
||||
} else {
|
||||
arch += "v8"
|
||||
}
|
||||
}
|
||||
|
||||
return goos, arch, config.version
|
||||
}
|
||||
}
|
||||
|
||||
func linuxMachineName() string {
|
||||
var uname string
|
||||
|
||||
if output, err := exec.Command("uname", "-m").Output(); err == nil {
|
||||
uname = string(output)
|
||||
}
|
||||
|
||||
return uname
|
||||
}
|
||||
|
||||
func shouldUseAlpineLinuxBuild() bool {
|
||||
_, err := os.Stat("/etc/alpine-release")
|
||||
return err == nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue