Skip to content

Commit 34cdec3

Browse files
committed
Move "arches normalization" code down so it happens more consistently (for both "supported" and "missing" arches)
This also has us doing less work/calculation across "all" Go's versions.
1 parent 431c08f commit 34cdec3

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

versions.sh

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ versions=( "${versions[@]%/}" )
3636
# https://github.com/golang/go/issues/34864
3737
# 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)
3838
goVersions="$(
39-
wget -qO- 'https://golang.org/dl/?mode=json&include=all' | jq -c --argjson potentiallySupportedArches "$potentiallySupportedArches" '
39+
wget -qO- 'https://golang.org/dl/?mode=json&include=all' | jq -c '
4040
[
4141
.[]
4242
| ( .version | ltrimstr("go") ) as $version
@@ -67,21 +67,8 @@ goVersions="$(
6767
{
6868
sha256: .sha256,
6969
url: ("https://dl.google.com/go/" + .filename),
70-
supported: ($potentiallySupportedArches | index($bashbrewArch) != null),
71-
} + if $bashbrewArch == "src" then {} else {
72-
env: (
73-
{ GOOS: .os, GOARCH: .arch }
74-
+ if .arch == "386" and .os == "linux" then
75-
# i386 in Debian is non-SSE2, Alpine appears to be similar (but interesting, not FreeBSD?)
76-
{ GO386: "softfloat" }
77-
elif .arch == "amd64" and .os == "linux" then
78-
# https://tip.golang.org/doc/go1.18#amd64
79-
{ GOAMD64: "v1" }
80-
elif $bashbrewArch | startswith("arm32v") then
81-
{ GOARCH: "arm", GOARM: ($bashbrewArch | ltrimstr("arm32v")) }
82-
else {} end
83-
),
84-
} end
70+
env: { GOOS: .os, GOARCH: .arch },
71+
}
8572
),
8673
}
8774
] | add)
@@ -91,27 +78,6 @@ goVersions="$(
9178
| if (.arches | has("arm32v7") | not) and (.arches | has("arm32v6")) then
9279
.arches["arm32v7"] = (.arches["arm32v6"] | .env.GOARM = "7")
9380
else . end
94-
95-
| ( $potentiallySupportedArches - (.arches | keys) ) as $missingArches
96-
| .arches = ([
97-
.arches, (
98-
$missingArches[]
99-
| {
100-
(.): {
101-
supported: true,
102-
env: (
103-
{
104-
GOOS: "linux",
105-
GOARCH: .,
106-
}
107-
+ if startswith("arm32v") then
108-
{ GOARCH: "arm", GOARM: ltrimstr("arm32v") }
109-
else {} end
110-
)
111-
},
112-
}
113-
)
114-
] | add)
11581
]
11682
'
11783
)"
@@ -140,17 +106,52 @@ for version in "${versions[@]}"; do
140106

141107
echo "$version: $fullVersion"
142108

143-
doc="$(jq <<<"$goJson" -c '{
109+
doc="$(jq <<<"$goJson" -c --argjson potentiallySupportedArches "$potentiallySupportedArches" '{
144110
version: .version,
145-
arches: .arches,
111+
arches: (
112+
.arches
113+
| . += (
114+
( $potentiallySupportedArches - keys ) # "missing" arches that we ought to include in our list
115+
| map(
116+
{
117+
(.): {
118+
env: (
119+
# hacky, but probably close enough (cleaned up in the next block)
120+
capture("^((?<GOOS>[^-]+)-)?(?<GOARCH>.+)$")
121+
| .GOOS //= "linux"
122+
)
123+
},
124+
}
125+
)
126+
| add
127+
)
128+
| with_entries(
129+
.key as $bashbrewArch
130+
| .value.supported = ($potentiallySupportedArches | index($bashbrewArch) != null)
131+
| .value.env +=
132+
if $bashbrewArch == "i386" then
133+
# i386 in Debian is non-SSE2, Alpine appears to be similar (but interesting, not FreeBSD?)
134+
{ GOARCH: "386", GO386: "softfloat" }
135+
elif $bashbrewArch == "amd64" then
136+
# https://tip.golang.org/doc/go1.18#amd64
137+
{ GOAMD64: "v1" }
138+
# 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)
139+
elif $bashbrewArch | startswith("arm64v") then
140+
{ GOARCH: "arm64" } # TODO do something with arm64 variant
141+
elif $bashbrewArch | startswith("arm32v") then
142+
{ GOARCH: "arm", GOARM: ($bashbrewArch | ltrimstr("arm32v")) }
143+
else {} end
144+
| if $bashbrewArch == "src" then del(.value.env) else . end
145+
)
146+
),
146147
variants: [
147148
"bookworm",
148149
"bullseye",
149150
(
150151
"3.18",
151152
"3.17"
152153
| "alpine" + .),
153-
if .arches | has("windows-amd64") then
154+
if .arches | has("windows-amd64") and .["windows-amd64"].url then
154155
(
155156
"ltsc2022",
156157
"1809"

0 commit comments

Comments
 (0)