Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move "arches normalization" code down so it happens more consistently… #475

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 41 additions & 40 deletions versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ versions=( "${versions[@]%/}" )
# https://github.com/golang/go/issues/34864
# https://github.com/golang/website/blob/41e922072f17ab2826d9479338314c025602a3a1/internal/dl/server.go#L174-L182 ... (the only way to get "unstable" releases is via "all", so we get to sort through "archive" releases too)
goVersions="$(
wget -qO- 'https://golang.org/dl/?mode=json&include=all' | jq -c --argjson potentiallySupportedArches "$potentiallySupportedArches" '
wget -qO- 'https://golang.org/dl/?mode=json&include=all' | jq -c '
[
.[]
| ( .version | ltrimstr("go") ) as $version
Expand Down Expand Up @@ -67,21 +67,8 @@ goVersions="$(
{
sha256: .sha256,
url: ("https://dl.google.com/go/" + .filename),
supported: ($potentiallySupportedArches | index($bashbrewArch) != null),
} + if $bashbrewArch == "src" then {} else {
env: (
{ GOOS: .os, GOARCH: .arch }
+ if .arch == "386" and .os == "linux" then
# i386 in Debian is non-SSE2, Alpine appears to be similar (but interesting, not FreeBSD?)
{ GO386: "softfloat" }
elif .arch == "amd64" and .os == "linux" then
# https://tip.golang.org/doc/go1.18#amd64
{ GOAMD64: "v1" }
elif $bashbrewArch | startswith("arm32v") then
{ GOARCH: "arm", GOARM: ($bashbrewArch | ltrimstr("arm32v")) }
else {} end
),
} end
env: { GOOS: .os, GOARCH: .arch },
}
),
}
] | add)
Expand All @@ -91,27 +78,6 @@ goVersions="$(
| if (.arches | has("arm32v7") | not) and (.arches | has("arm32v6")) then
.arches["arm32v7"] = (.arches["arm32v6"] | .env.GOARM = "7")
else . end

| ( $potentiallySupportedArches - (.arches | keys) ) as $missingArches
| .arches = ([
.arches, (
$missingArches[]
| {
(.): {
supported: true,
env: (
{
GOOS: "linux",
GOARCH: .,
}
+ if startswith("arm32v") then
{ GOARCH: "arm", GOARM: ltrimstr("arm32v") }
else {} end
)
},
}
)
] | add)
]
'
)"
Expand Down Expand Up @@ -140,17 +106,52 @@ for version in "${versions[@]}"; do

echo "$version: $fullVersion"

doc="$(jq <<<"$goJson" -c '{
doc="$(jq <<<"$goJson" -c --argjson potentiallySupportedArches "$potentiallySupportedArches" '{
version: .version,
arches: .arches,
arches: (
.arches
| . += (
( $potentiallySupportedArches - keys ) # "missing" arches that we ought to include in our list
| map(
{
(.): {
env: (
# hacky, but probably close enough (cleaned up in the next block)
capture("^((?<GOOS>[^-]+)-)?(?<GOARCH>.+)$")
| .GOOS //= "linux"
)
},
}
)
| add
)
| with_entries(
.key as $bashbrewArch
| .value.supported = ($potentiallySupportedArches | index($bashbrewArch) != null)
| .value.env +=
if $bashbrewArch == "i386" then
# i386 in Debian is non-SSE2, Alpine appears to be similar (but interesting, not FreeBSD?)
{ GOARCH: "386", GO386: "softfloat" }
elif $bashbrewArch == "amd64" then
# https://tip.golang.org/doc/go1.18#amd64
{ GOAMD64: "v1" }
# TODO ^^ figure out what to do with GOAMD64 / GO386 if/when the OS baselines change and these choices needs to be per-variant /o\ (probably move it to the template instead, in fact, since that is where we can most easily toggle based on variant)
elif $bashbrewArch | startswith("arm64v") then
{ GOARCH: "arm64" } # TODO do something with arm64 variant
elif $bashbrewArch | startswith("arm32v") then
{ GOARCH: "arm", GOARM: ($bashbrewArch | ltrimstr("arm32v")) }
else {} end
| if $bashbrewArch == "src" then del(.value.env) else . end
)
),
variants: [
"bookworm",
"bullseye",
(
"3.18",
"3.17"
| "alpine" + .),
if .arches | has("windows-amd64") then
if .arches | has("windows-amd64") and .["windows-amd64"].url then
(
"ltsc2022",
"1809"
Expand Down