env,dashboard: add OpenBSD 7.1 and 7.2

While here modify make.bash to accept a VERSION variable.

For golang/go#55161.
For golang/go#57496.

Change-Id: I395af9cfa59e38757635c9dd703ef292c8b35a87
GitHub-Last-Rev: e2dd699bff7972f4a7899e92d97cc8960f51268e
GitHub-Pull-Request: golang/build#49
Reviewed-on: https://go-review.googlesource.com/c/build/+/456295
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 928b59a..c5aa51d 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -476,6 +476,20 @@
 		SSHUsername: "gopher",
 		GoBootstrap: "go1.19.2", // Go 1.17 is too old; see go.dev/issue/42422
 	},
+	"host-openbsd-386-71": {
+		VMImage:     "openbsd-386-71",
+		machineType: "n2", // force Intel; see go.dev/issue/49209
+		Notes:       "OpenBSD 7.1; GCE VM, built from build/env/openbsd-386",
+		SSHUsername: "gopher",
+		GoBootstrap: "go1.19.2", // Go 1.17 is too old; see go.dev/issue/42422
+	},
+	"host-openbsd-386-72": {
+		VMImage:     "openbsd-386-72",
+		machineType: "n2", // force Intel; see go.dev/issue/49209
+		Notes:       "OpenBSD 7.2; GCE VM, built from build/env/openbsd-386",
+		SSHUsername: "gopher",
+		GoBootstrap: "go1.19.2", // Go 1.17 is too old; see go.dev/issue/42422
+	},
 	"host-openbsd-amd64-68": {
 		VMImage:     "openbsd-amd64-68-v3", // v3 adds 009_exit syspatch; see go.dev/cl/278732.
 		machineType: "n2",                  // force Intel; see go.dev/issue/49209
@@ -490,6 +504,20 @@
 		SSHUsername: "gopher",
 		GoBootstrap: "go1.19.2", // Go 1.17 is too old; see go.dev/issue/42422
 	},
+	"host-openbsd-amd64-71": {
+		VMImage:     "openbsd-amd64-71",
+		machineType: "n2", // force Intel; see go.dev/issue/49209
+		Notes:       "OpenBSD 7.1; GCE VM, built from build/env/openbsd-amd64",
+		SSHUsername: "gopher",
+		GoBootstrap: "go1.19.2", // Go 1.17 is too old; see go.dev/issue/42422
+	},
+	"host-openbsd-amd64-72": {
+		VMImage:     "openbsd-amd64-72",
+		machineType: "n2", // force Intel; see go.dev/issue/49209
+		Notes:       "OpenBSD 7.2; GCE VM, built from build/env/openbsd-amd64",
+		SSHUsername: "gopher",
+		GoBootstrap: "go1.19.2", // Go 1.17 is too old; see go.dev/issue/42422
+	},
 	"host-openbsd-arm-joelsing": {
 		IsReverse:   true,
 		ExpectNum:   1,
@@ -1978,6 +2006,20 @@
 		numTryTestHelpers: 4,
 	})
 	addBuilder(BuildConfig{
+		Name:              "openbsd-amd64-71",
+		HostType:          "host-openbsd-amd64-71",
+		KnownIssues:       []int{57496},
+		distTestAdjust:    noTestDirAndNoReboot,
+		numTryTestHelpers: 4,
+	})
+	addBuilder(BuildConfig{
+		Name:              "openbsd-amd64-72",
+		HostType:          "host-openbsd-amd64-72",
+		KnownIssues:       []int{57496},
+		distTestAdjust:    noTestDirAndNoReboot,
+		numTryTestHelpers: 4,
+	})
+	addBuilder(BuildConfig{
 		Name:     "openbsd-386-70",
 		HostType: "host-openbsd-386-70",
 		tryBot:   explicitTrySet("sys"),
@@ -1990,6 +2032,30 @@
 		numTryTestHelpers: 4,
 	})
 	addBuilder(BuildConfig{
+		Name:        "openbsd-386-71",
+		HostType:    "host-openbsd-386-71",
+		KnownIssues: []int{57496},
+		buildsRepo: func(repo, branch, goBranch string) bool {
+			// https://go.dev/issue/49529: git seems to be too slow on this
+			// platform.
+			return repo != "review" && buildRepoByDefault(repo)
+		},
+		distTestAdjust:    noTestDirAndNoReboot,
+		numTryTestHelpers: 4,
+	})
+	addBuilder(BuildConfig{
+		Name:        "openbsd-386-72",
+		HostType:    "host-openbsd-386-72",
+		KnownIssues: []int{57496},
+		buildsRepo: func(repo, branch, goBranch string) bool {
+			// https://go.dev/issue/49529: git seems to be too slow on this
+			// platform.
+			return repo != "review" && buildRepoByDefault(repo)
+		},
+		distTestAdjust:    noTestDirAndNoReboot,
+		numTryTestHelpers: 4,
+	})
+	addBuilder(BuildConfig{
 		// This builder is only for the runtime team to use investigating golang/go#49209.
 		Name:           "openbsd-386-70-n2d",
 		HostType:       "host-openbsd-386-70-n2d",
diff --git a/env/openbsd-386/make.bash b/env/openbsd-386/make.bash
index 00358d9..3431342 100755
--- a/env/openbsd-386/make.bash
+++ b/env/openbsd-386/make.bash
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # Copyright 2014 The Go Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
diff --git a/env/openbsd-amd64/README b/env/openbsd-amd64/README
index 09fd4fe..6520b67 100644
--- a/env/openbsd-amd64/README
+++ b/env/openbsd-amd64/README
@@ -3,17 +3,18 @@
 
 make.bash should be run on a Linux box with expect and qemu.
 Debian packages: expect qemu-utils qemu-system-x86 growisofs genisoimage.
+    VERSION=7.2 ARCH=amd64 ./make.bash
 
-After it completes, it creates a file openbsd-amd64-gce.tar.gz
+After it completes, it creates a file openbsd-${VERSION}-${ARCH}-gce.tar.gz
 
 Then:
-    gsutil cp -a public-read openbsd-amd64-gce.tar.gz gs://go-builder-data/openbsd-amd64-70.tar.gz
+    gsutil cp -a public-read openbsd-7.2-amd64-gce.tar.gz gs://go-builder-data/openbsd-amd64-72.tar.gz
 Or just use the web UI at:
     https://console.developers.google.com/project/symbolic-datum-552/storage/browser/go-builder-data/
 
 Then:
-   gcloud compute --project symbolic-datum-552 images delete openbsd-amd64-70
-   gcloud compute --project symbolic-datum-552 images create openbsd-amd64-70 --source-uri gs://go-builder-data/openbsd-amd64-70.tar.gz
+    gcloud compute --project symbolic-datum-552 images delete openbsd-amd64-72
+    gcloud compute --project symbolic-datum-552 images create openbsd-amd64-72 --source-uri gs://go-builder-data/openbsd-amd64-72.tar.gz
 
 The VM needs to be run with the GCE metadata attribute "buildlet-binary-url" set to a URL
 of the OpenBSD buildlet (cross-compiled, typically).
diff --git a/env/openbsd-amd64/make.bash b/env/openbsd-amd64/make.bash
index a2466eb..2369a80 100755
--- a/env/openbsd-amd64/make.bash
+++ b/env/openbsd-amd64/make.bash
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # Copyright 2014 The Go Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
@@ -6,7 +6,8 @@
 set -e
 set -u
 
-readonly VERSION="7.0"
+# Update to the version listed on https://openbsd.org
+readonly VERSION="${VERSION:-7.2}"
 readonly RELNO="${VERSION/./}"
 readonly SNAPSHOT=false
 
@@ -62,6 +63,9 @@
 cat >etc/rc.local <<EOF
 if [[ -f /firstboot ]]; then
   syspatch
+  # Run syspatch twice in case syspatch itself needs patching (this is the case with OpenBSD
+  # 7.1: https://www.openbsd.org/errata71.html )
+  syspatch
   pkg_add -iv ${PKG_ADD_OPTIONS} bash curl git
   rm -f /firstboot
 fi
@@ -170,6 +174,6 @@
 
 # Create Compute Engine disk image.
 echo "Archiving disk.raw... (this may take a while)"
-tar -Szcf "openbsd-${ARCH}-gce.tar.gz" disk.raw
+tar -Szcf "openbsd-${VERSION}-${ARCH}-gce.tar.gz" disk.raw
 
-echo "Done. GCE image is openbsd-${ARCH}-gce.tar.gz."
+echo "Done. GCE image is openbsd-${VERSION}-${ARCH}-gce.tar.gz."