internal/relui: drop v6l suffix from non-linux/arm download metadata

For historical reasons, the binary release for the linux/arm port we
provide at https://go.dev/dl/ is a bit of a special case. It differs
from other ports in that it's built with GOARM overridden to a value
of 6, and the filename has a "v6l" suffix after "arm". The download
metadata has a field "arch" where that v6l suffix is being included.

This special case needs to be handled consistently in various places,
which can be easy to get slightly wrong sometimes (e.g., CL 504820,
go.dev/issue/62514, etc.).

It turns out a GOOS == linux check was missed when porting the metadata
publishing logic from releasebot to relui, causing metadata for Go 1.21
onwards to be "armv6l" for arm ports of all OSes, not just Linux. Cease
doing that in Go 1.23 (the nearest major release, to minimize potential
disruption in minor releases).

Spotted this via https://hachyderm.io/@golang/112044405859439427 which
happened to select the netbsd/arm port. The fact that this hasn't been
reported sooner suggests this isn't a very serious problem fortunately.

Change-Id: I732ca7a6db181e81d31b265df48e7a9f47ed2c6c
Reviewed-on: https://go-review.googlesource.com/c/build/+/584403
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/internal/relui/buildrelease_test.go b/internal/relui/buildrelease_test.go
index ac54e5b..56924de 100644
--- a/internal/relui/buildrelease_test.go
+++ b/internal/relui/buildrelease_test.go
@@ -315,6 +315,14 @@
 		"go/VERSION":                        versionFile,
 		"go/tool/something_orother/compile": "",
 	})
+	checkTGZ(t, dlURL, files, "netbsd-arm.tar.gz", task.WebsiteFile{
+		OS:   "netbsd",
+		Arch: "arm" + map[int]string{21: "v6l", 22: "v6l"}[major],
+		Kind: "archive",
+	}, map[string]string{
+		"go/VERSION":                        versionFile,
+		"go/tool/something_orother/compile": "",
+	})
 	checkTGZ(t, dlURL, files, "darwin-amd64.tar.gz", task.WebsiteFile{
 		OS:   "darwin",
 		Arch: "amd64",
diff --git a/internal/relui/workflows.go b/internal/relui/workflows.go
index 85f49a4..65072bb 100644
--- a/internal/relui/workflows.go
+++ b/internal/relui/workflows.go
@@ -1626,9 +1626,18 @@
 		if a.Target != nil {
 			f.OS = a.Target.GOOS
 			f.Arch = a.Target.GOARCH
-			if a.Target.GOARCH == "arm" {
+			if a.Target.GOOS == "linux" && a.Target.GOARCH == "arm" && slices.Contains(a.Target.ExtraEnv, "GOARM=6") {
 				f.Arch = "armv6l"
 			}
+			if task.CompareGoVersions(version, "go1.23") == -1 { // TODO: Delete this after Go 1.24.0 is out and this becomes dead code.
+				// Due to an oversight, we've been inadvertently setting the "arch" field
+				// of published download metadata to "armv6l" for all arm ports, not just
+				// linux/arm port as intended. Keep doing it for the rest of Go 1.22/1.21
+				// minor releases only.
+				if a.Target.GOARCH == "arm" {
+					f.Arch = "armv6l"
+				}
+			}
 		}
 		switch a.Suffix {
 		case "src.tar.gz":
diff --git a/internal/task/gover.go b/internal/task/gover.go
index dfcde86..70d9460 100644
--- a/internal/task/gover.go
+++ b/internal/task/gover.go
@@ -8,12 +8,12 @@
 
 package task
 
-// compareGoVersions returns -1, 0, or +1 depending on whether
+// CompareGoVersions returns -1, 0, or +1 depending on whether
 // x < y, x == y, or x > y, interpreted as toolchain versions.
 // The versions x and y must begin with a "go" prefix: "go1.21" not "1.21".
 // Malformed versions compare less than well-formed versions and equal to each other.
 // The language version "go1.21" compares less than the release candidate and eventual releases "go1.21rc1" and "go1.21.0".
-func compareGoVersions(x, y string) int {
+func CompareGoVersions(x, y string) int {
 	vx := parse(x)
 	vy := parse(y)
 
diff --git a/internal/task/updateproxytestrepo.go b/internal/task/updateproxytestrepo.go
index df8cf24..67c7ccd 100644
--- a/internal/task/updateproxytestrepo.go
+++ b/internal/task/updateproxytestrepo.go
@@ -38,7 +38,7 @@
 	}
 	// If the published version is lower than the current go.mod version, don't update.
 	// If we could parse the go.mod file, assume we should update.
-	if f.Go != nil && compareGoVersions(published.Version, "go"+f.Go.Version) < 0 {
+	if f.Go != nil && CompareGoVersions(published.Version, "go"+f.Go.Version) < 0 {
 		return "no update", nil
 	}