env/openbsd-amd64: syspatch on first boot

syspatch is currently being invoked at the end of the installation, which
means we're trying to patch the installation ramdisk kernel, rather than the
generic kernel. Instead, invoke syspatch during the first boot of the generic
kernel. Move pkg_add as well, since that is also generally safer to run outside
of the installation.

Update golang/go#35712
Update golang/go#42542

Change-Id: Icbb384816de5859078a0183919626d223fb0060f
Reviewed-on: https://go-review.googlesource.com/c/build/+/278732
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/env/openbsd-amd64/make.bash b/env/openbsd-amd64/make.bash
index 9b0f7b9..a217b74 100755
--- a/env/openbsd-amd64/make.bash
+++ b/env/openbsd-amd64/make.bash
@@ -54,9 +54,7 @@
 mkdir -p etc
 cat >install.site <<EOF
 #!/bin/sh
-syspatch
-pkg_add -iv ${PKG_ADD_OPTIONS} bash curl git
-
+touch /firstboot
 echo 'set tty com0' > boot.conf
 EOF
 
@@ -64,6 +62,12 @@
 https://${MIRROR}/pub/OpenBSD
 EOF
 cat >etc/rc.local <<EOF
+if [[ -f /firstboot ]]; then
+  syspatch
+  pkg_add -iv ${PKG_ADD_OPTIONS} bash curl git
+  rm -f /firstboot
+fi
+
 (
   set -x