dashboard, env/netbsd-{amd64,386}: add NetBSD 9.0 builders

Update NetBSD amd64 and 386 builders to the latest NetBSD 9.0 release,
using the latest versions of anita (2.3) and pkgsrc packages (2019Q4).

Also increase the image disk size from 4 GB to 16 GB. The motivation
is to help tests that require more disk space and large dependencies.
Additional adjustments to the image building script will need to be
made to make use of increased disk space for the /tmp volume, as it
is currently being mounted in RAM with size equal to 25% of memory.

Remove the manual invocation of the mozilla-rootcerts install command.
It no longer works as is in NetBSD 9.0. The mozilla-rootcerts-openssl
package is added instead, which successfully performs that same task.
Hopefully this will be a more robust approach for the future.

Continue to use an explicit URL for the NetBSD release download, and
remove unused find_latest_release.

The plan is to roll out these builders first (without trybots), gain
more confidence, enable trybots, and then remove NetBSD 8.0 builders.

For golang/go#37244.
For golang/go#30839.
For golang/go#31858.
For golang/go#31726.
For golang/go#38283.

Change-Id: Id41278eaebe64cfbcf7b1ab9bfd64e550ee0bbf1
Reviewed-on: https://go-review.googlesource.com/c/build/+/226977
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
diff --git a/dashboard/builders.go b/dashboard/builders.go
index b7b2869..c323b22 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -356,6 +356,22 @@
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-netbsd-386-0b3b511.tar.gz",
 		SSHUsername:        "root",
 	},
+	"host-netbsd-amd64-9_0": &HostConfig{
+		VMImage:            "netbsd-amd64-9-0-2019q4",
+		Notes:              "NetBSD 9.0; GCE VM is built from script in build/env/netbsd-amd64",
+		machineType:        "n1-highcpu-4",
+		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.netbsd-amd64",
+		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-netbsd-amd64-2da6b33.tar.gz",
+		SSHUsername:        "root",
+	},
+	"host-netbsd-386-9_0": &HostConfig{
+		VMImage:            "netbsd-i386-9-0-2019q4",
+		Notes:              "NetBSD 9.0; GCE VM is built from script in build/env/netbsd-386",
+		machineType:        "n1-highcpu-4",
+		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.netbsd-386",
+		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-netbsd-386-0b3b511.tar.gz",
+		SSHUsername:        "root",
+	},
 	"host-netbsd-arm-bsiegert": &HostConfig{
 		IsReverse:   true,
 		ExpectNum:   1,
@@ -1935,6 +1951,20 @@
 		buildsRepo: disabledBuilder,
 	})
 	addBuilder(BuildConfig{
+		Name:              "netbsd-amd64-9_0",
+		HostType:          "host-netbsd-amd64-9_0",
+		KnownIssue:        37244,
+		shouldRunDistTest: noTestDirAndNoReboot,
+		tryBot:            nil, // Not yet, gain confidence first.
+	})
+	addBuilder(BuildConfig{
+		Name:              "netbsd-386-9_0",
+		HostType:          "host-netbsd-386-9_0",
+		KnownIssue:        37244,
+		shouldRunDistTest: noTestDirAndNoReboot,
+		tryBot:            nil, // Not yet, gain confidence first.
+	})
+	addBuilder(BuildConfig{
 		Name:              "netbsd-arm-bsiegert",
 		HostType:          "host-netbsd-arm-bsiegert",
 		shouldRunDistTest: noTestDirAndNoReboot,
diff --git a/env/netbsd-386/Makefile b/env/netbsd-386/Makefile
index d254f21..5f65aee 100644
--- a/env/netbsd-386/Makefile
+++ b/env/netbsd-386/Makefile
@@ -4,17 +4,17 @@
 
 upload-staging:
 	go install golang.org/x/build/cmd/upload
-	upload --verbose --file=netbsd-i386-8.0_2018Q1.tar.gz --public dev-go-builder-data/vm-image-netbsd-i386-8.0_2018Q1.tar.gz
+	upload --verbose --file=netbsd-i386-9.0_2019Q4.tar.gz --public dev-go-builder-data/vm-image-netbsd-i386-9.0_2019Q4.tar.gz
 
 upload-prod:
 	go install golang.org/x/build/cmd/upload
-	upload --verbose --file=netbsd-i386-8.0_2018Q1.tar.gz --public go-builder-data/vm-image-netbsd-i386-8.0_2018Q1.tar.gz
+	upload --verbose --file=netbsd-i386-9.0_2019Q4.tar.gz --public go-builder-data/vm-image-netbsd-i386-9.0_2019Q4.tar.gz
 
 create-image-staging:
-	gcloud compute --project go-dashboard-dev images create netbsd-i386-8-0-2018q1 --source-uri gs://dev-go-builder-data/vm-image-netbsd-i386-8.0_2018Q1.tar.gz
+	gcloud compute --project go-dashboard-dev images create netbsd-i386-9-0-2019q4 --source-uri gs://dev-go-builder-data/vm-image-netbsd-i386-9.0_2019Q4.tar.gz
 
 create-image-prod:
-	gcloud compute --project symbolic-datum-552 images create netbsd-i386-8-0-2018q1 --source-uri gs://go-builder-data/vm-image-netbsd-i386-8.0_2018Q1.tar.gz
+	gcloud compute --project symbolic-datum-552 images create netbsd-i386-9-0-2019q4 --source-uri gs://go-builder-data/vm-image-netbsd-i386-9.0_2019Q4.tar.gz
 
 clean:
 	rm -rf netbsd-*.tar.gz work-NetBSD-* anita-*.tar.gz anita-*/
diff --git a/env/netbsd-386/anita-1.44.tar.gz.sha1 b/env/netbsd-386/anita-1.44.tar.gz.sha1
deleted file mode 100644
index 48ee3d6..0000000
--- a/env/netbsd-386/anita-1.44.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-92b3d080302e5f5c62b1479a7aa8e4c148fa68ec  anita-1.44.tar.gz
diff --git a/env/netbsd-386/anita-2.3.tar.gz.sha1 b/env/netbsd-386/anita-2.3.tar.gz.sha1
new file mode 100644
index 0000000..2026804
--- /dev/null
+++ b/env/netbsd-386/anita-2.3.tar.gz.sha1
@@ -0,0 +1 @@
+003b5dca54c0931480a5e055659140b94cf87d76  anita-2.3.tar.gz
diff --git a/env/netbsd-386/make.bash b/env/netbsd-386/make.bash
index 13f74a8..bb7fe73 100755
--- a/env/netbsd-386/make.bash
+++ b/env/netbsd-386/make.bash
@@ -13,10 +13,10 @@
 
 set -e -x
 
-ANITA_VERSION=1.44
+ANITA_VERSION=2.3
 ARCH=i386
 # The release that the packages have been built for.
-RELEASE=8.0_2018Q1
+RELEASE=9.0_2019Q4
 
 # Must use GNU tar. On NetBSD, tar is BSD tar and gtar is GNU.
 TAR=tar
@@ -33,7 +33,7 @@
 
 # Download and build anita (automated NetBSD installer).
 if ! sha1sum -c anita-${ANITA_VERSION}.tar.gz.sha1; then
-  curl -vO http://www.gson.org/netbsd/anita/download/anita-${ANITA_VERSION}.tar.gz
+  curl -vO https://www.gson.org/netbsd/anita/download/anita-${ANITA_VERSION}.tar.gz
   sha1sum -c anita-${ANITA_VERSION}.tar.gz.sha1 || exit 1
 fi
 
diff --git a/env/netbsd-amd64/Makefile b/env/netbsd-amd64/Makefile
index 7713cb7..ad84827 100644
--- a/env/netbsd-amd64/Makefile
+++ b/env/netbsd-amd64/Makefile
@@ -4,17 +4,17 @@
 
 upload-staging:
 	go install golang.org/x/build/cmd/upload
-	upload --verbose --file=netbsd-amd64-8.0_2018Q1.tar.gz --public dev-go-builder-data/vm-image-netbsd-amd64-8.0_2018Q1.tar.gz
+	upload --verbose --file=netbsd-amd64-9.0_2019Q4.tar.gz --public dev-go-builder-data/vm-image-netbsd-amd64-9.0_2019Q4.tar.gz
 
 upload-prod:
 	go install golang.org/x/build/cmd/upload
-	upload --verbose --file=netbsd-amd64-8.0_2018Q1.tar.gz --public go-builder-data/vm-image-netbsd-amd64-8.0_2018Q1.tar.gz
+	upload --verbose --file=netbsd-amd64-9.0_2019Q4.tar.gz --public go-builder-data/vm-image-netbsd-amd64-9.0_2019Q4.tar.gz
 
 create-image-staging:
-	gcloud compute --project go-dashboard-dev images create netbsd-amd64-8-0-2018q1 --source-uri gs://dev-go-builder-data/vm-image-netbsd-amd64-8.0_2018Q1.tar.gz
+	gcloud compute --project go-dashboard-dev images create netbsd-amd64-9-0-2019q4 --source-uri gs://dev-go-builder-data/vm-image-netbsd-amd64-9.0_2019Q4.tar.gz
 
 create-image-prod:
-	gcloud compute --project symbolic-datum-552 images create netbsd-amd64-8-0-2018q1 --source-uri gs://go-builder-data/vm-image-netbsd-amd64-8.0_2018Q1.tar.gz
+	gcloud compute --project symbolic-datum-552 images create netbsd-amd64-9-0-2019q4 --source-uri gs://go-builder-data/vm-image-netbsd-amd64-9.0_2019Q4.tar.gz
 
 clean:
 	rm -rf netbsd-*.tar.gz work-NetBSD-* anita-*.tar.gz anita-*/
diff --git a/env/netbsd-amd64/anita-1.44.tar.gz.sha1 b/env/netbsd-amd64/anita-1.44.tar.gz.sha1
deleted file mode 100644
index 48ee3d6..0000000
--- a/env/netbsd-amd64/anita-1.44.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-92b3d080302e5f5c62b1479a7aa8e4c148fa68ec  anita-1.44.tar.gz
diff --git a/env/netbsd-amd64/anita-2.3.tar.gz.sha1 b/env/netbsd-amd64/anita-2.3.tar.gz.sha1
new file mode 100644
index 0000000..2026804
--- /dev/null
+++ b/env/netbsd-amd64/anita-2.3.tar.gz.sha1
@@ -0,0 +1 @@
+003b5dca54c0931480a5e055659140b94cf87d76  anita-2.3.tar.gz
diff --git a/env/netbsd-amd64/make.bash b/env/netbsd-amd64/make.bash
index 521a0e9..ea24251 100755
--- a/env/netbsd-amd64/make.bash
+++ b/env/netbsd-amd64/make.bash
@@ -13,10 +13,10 @@
 
 set -e -x
 
-ANITA_VERSION=1.44
+ANITA_VERSION=2.3
 ARCH=amd64
 # The release that the packages have been built for.
-RELEASE=8.0_2019Q1
+RELEASE=9.0_2019Q4
 
 # Must use GNU tar. On NetBSD, tar is BSD tar and gtar is GNU.
 TAR=tar
@@ -33,7 +33,7 @@
 
 # Download and build anita (automated NetBSD installer).
 if ! sha1sum -c anita-${ANITA_VERSION}.tar.gz.sha1; then
-  curl -vO http://www.gson.org/netbsd/anita/download/anita-${ANITA_VERSION}.tar.gz
+  curl -vO https://www.gson.org/netbsd/anita/download/anita-${ANITA_VERSION}.tar.gz
   sha1sum -c anita-${ANITA_VERSION}.tar.gz.sha1 || exit 1
 fi
 
diff --git a/env/netbsd-amd64/mkvm.py b/env/netbsd-amd64/mkvm.py
index fae1e8d..ed5ed32 100644
--- a/env/netbsd-amd64/mkvm.py
+++ b/env/netbsd-amd64/mkvm.py
@@ -4,33 +4,8 @@
 # license that can be found in the LICENSE file.
 
 import anita
-import ftplib
 import sys
 
-def find_latest_release(branch, arch):
-  """Find the latest NetBSD-current release for the given arch.
-
-  Args:
-    branch: the NetBSD branch (e.g. HEAD, netbsd-8).
-    arch: the architecture (e.g. amd64).
-
-  Returns:
-    the full path to the release.
-  """
-  conn = ftplib.FTP('nyftp.netbsd.org')
-  conn.login()
-  conn.cwd('/pub/NetBSD-daily/%s' % branch)
-  releases = conn.nlst()
-  releases.sort(reverse=True)
-  for r in releases:
-    archs = conn.nlst(r)
-    if not archs:
-      next
-    has_arch = [a for a in archs if a.endswith(arch)]
-    if has_arch:
-      return "https://nyftp.netbsd.org/pub/NetBSD-daily/%s/%s/" % (branch, has_arch[0])
-
-
 arch = sys.argv[1]
 release = sys.argv[2]
 
@@ -62,7 +37,7 @@
     "dhcpcd",
     "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add bash curl" % (arch, release),
     "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add git-base" % (arch, release),
-    "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add mozilla-rootcerts go14" % (arch, release),
+    "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add mozilla-rootcerts mozilla-rootcerts-openssl go14" % (arch, release),
     # Interactive debugging tools for users using gomote ssh:
     "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add emacs25-nox11 vim screen" % (arch, release),
     # For https://golang.org/issue/24354
@@ -72,20 +47,17 @@
 %s/wd0/sd0/
 wq
 EOF""",
-    "touch /etc/openssl/openssl.cnf",
-    "/usr/pkg/sbin/mozilla-rootcerts install",
     "echo sshd=yes >> /etc/rc.conf",
     "echo PermitRootLogin without-password >> /etc/ssh/sshd_config",
     "/etc/rc.d/sshd restart",
     "sync; shutdown -hp now",
 ]
 
-
 a = anita.Anita(
-    anita.URL('https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.1/%s/' % arch),
+    anita.URL('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/%s/' % arch),
     workdir="work-NetBSD-%s" % arch,
-    disk_size="4G",
-    memory_size = "1G",
+    disk_size="16G",
+    memory_size="2G",
     persist=True)
 child = a.boot()
 anita.login(child)