golang.org/x/build@v0.0.0-20240506185731-218518f32b70/env/netbsd-amd64/mkvm.py (about) 1 #!/usr/bin/env python 2 # Copyright 2016 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 import anita 7 import sys 8 9 arch = sys.argv[1] 10 release = sys.argv[2] 11 pkg_release = sys.argv[3] 12 13 commands = [ 14 """cat >> /etc/rc.local <<EOF 15 ( 16 export PATH=/usr/pkg/bin:/usr/pkg/sbin:${PATH} 17 export GOROOT_BOOTSTRAP=/usr/pkg/go14 18 set -x 19 echo 'starting buildlet script' 20 netstat -rn 21 cat /etc/resolv.conf 22 dig metadata.google.internal 23 ( 24 set -e 25 curl -o /buildlet \$(curl -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/attributes/buildlet-binary-url) 26 chmod +x /buildlet 27 exec /buildlet 28 ) 29 echo 'giving up' 30 sleep 10 31 halt -p 32 ) 33 EOF""", 34 """cat > /etc/ifconfig.vioif0 << EOF 35 !dhcpcd 36 mtu 1460 37 EOF""", 38 "dhcpcd", 39 "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add bash curl" % (arch, pkg_release), 40 "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add git-base" % (arch, pkg_release), 41 "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add mozilla-rootcerts mozilla-rootcerts-openssl go14" % (arch, pkg_release), 42 # Interactive debugging tools for users using gomote ssh: 43 "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add emacs25-nox11 vim screen" % (arch, pkg_release), 44 # For https://golang.org/issue/24354 45 "env PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/%s/%s/All/ pkg_add clang cmake" % (arch, pkg_release), 46 47 # Remove the /tmp entry, because it's mounted as tmpfs -s=ram%25 by default, which isn't enough disk space. 48 """ed /etc/fstab << EOF 49 H 50 /\\/tmp/d 51 wq 52 EOF""", 53 54 "echo sshd=yes >> /etc/rc.conf", 55 "echo PermitRootLogin without-password >> /etc/ssh/sshd_config", 56 "/etc/rc.d/sshd restart", 57 "sync; shutdown -hp now", 58 ] 59 60 a = anita.Anita( 61 anita.URL('https://nycdn.netbsd.org/pub/NetBSD-daily/NetBSD-9/latest/%s/' % arch), 62 workdir="work-NetBSD-%s" % arch, 63 disk_size="16G", 64 memory_size="2G", 65 persist=True) 66 child = a.boot() 67 anita.login(child) 68 69 for cmd in commands: 70 anita.shell_cmd(child, cmd, 3600) 71 72 # Sometimes, the halt command times out, even though it has completed 73 # successfully. 74 try: 75 a.halt() 76 except: 77 pass