Skip to content

Commit b2523aa

Browse files
committed
dashboard/env: add script to create OpenBSD GCE image
This is almost entirely the work of @mdempsky; I just ran it a bunch and reported bugs or tweaked things until it worked and booted the buildlet on GCE. Update #8642 Change-Id: If5d50bcdf90bc6aa648472cc951ed1c53b46eef3 Reviewed-on: https://go-review.googlesource.com/2156 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 538acf1 commit b2523aa

File tree

3 files changed

+250
-0
lines changed

3 files changed

+250
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
boot.conf
2+
disk.raw
3+
etc
4+
install.site
5+
install56-patched.iso
6+
install56.iso
7+
random.seed
8+
site56.tgz

dashboard/env/openbsd-amd64/README

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
make.bash creates a Google Compute Engine VM image to run the Go
2+
OpenBSD builder, booting up to run the buildlet.
3+
4+
make.bash should be run on a Linux box with qemu.
5+
6+
After it completes, it creates a file openbsd-amd64-gce.tar.gz
7+
8+
Upload openbsd-amd64-gce.tar.gz to gs://go-builder-data/openbsd-amd64-gce.tar.gz
9+
I just use the web UI at:
10+
https://console.developers.google.com/project/symbolic-datum-552/storage/browser/go-builder-data/
11+
12+
Then:
13+
gcloud compute --project symbolic-datum-552 images create openbsd-amd64-56 --source-uri gs://go-builder-data/openbsd-amd64-gce.tar.gz
14+
15+
The VM needs to be run with the GCE metadata attribute "buildlet-binary-url" set to a URL
16+
of the OpenBSD builetlet (cross-compiled, typically).
17+
18+
buildlet-binary-url == http://storage.googleapis.com/go-builder-data/buildlet.openbsd-amd64

dashboard/env/openbsd-amd64/make.bash

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
#!/bin/bash
2+
# Copyright 2014 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+
set -e
7+
8+
# Download kernel, sets, etc. from ftp.usa.openbsd.org
9+
if ! [ -e install56.iso ]; then
10+
curl -O ftp://ftp.usa.openbsd.org/pub/OpenBSD/5.6/amd64/install56.iso
11+
fi
12+
13+
# XXX: Download and save bash, curl, and their dependencies too?
14+
# Currently we download them from the network during the install process.
15+
16+
# Create custom site56.tgz set.
17+
mkdir -p etc
18+
cat >install.site <<EOF
19+
#!/bin/sh
20+
env PKG_PATH=ftp://ftp.usa.openbsd.org/pub/OpenBSD/5.6/packages/amd64 pkg_add -iv bash curl
21+
22+
# See https://code.google.com/p/google-compute-engine/issues/detail?id=77
23+
echo "ignore classless-static-routes;" >> /etc/dhclient.conf
24+
EOF
25+
cat >etc/rc.local <<EOF
26+
(
27+
set -x
28+
echo "starting buildlet script"
29+
netstat -rn
30+
cat /etc/resolv.conf
31+
dig metadata.google.internal
32+
(
33+
set -e
34+
export PATH="\$PATH:/usr/local/bin"
35+
/usr/local/bin/curl -o /buildlet \$(/usr/local/bin/curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/buildlet-binary-url)
36+
chmod +x /buildlet
37+
exec /buildlet
38+
)
39+
echo "giving up"
40+
sleep 10
41+
halt -p
42+
)
43+
EOF
44+
chmod +x install.site
45+
tar -zcvf site56.tgz install.site etc/rc.local
46+
47+
# Hack install CD a bit.
48+
echo 'set tty com0' > boot.conf
49+
dd if=/dev/urandom of=random.seed bs=4096 count=1
50+
cp install56.iso install56-patched.iso
51+
growisofs -M install56-patched.iso -l -R -graft-points \
52+
/5.6/amd64/site56.tgz=site56.tgz \
53+
/etc/boot.conf=boot.conf \
54+
/etc/random.seed=random.seed
55+
56+
# Initialize disk image.
57+
rm -f disk.raw
58+
qemu-img create -f raw disk.raw 10G
59+
60+
# Run the installer to create the disk image.
61+
expect <<EOF
62+
spawn qemu-system-x86_64 -nographic -smp 2 -drive if=virtio,file=disk.raw -cdrom install56-patched.iso -net nic,model=virtio -net user -boot once=d
63+
64+
expect "boot>"
65+
send "\n"
66+
67+
# Need to wait for the kernel to boot.
68+
expect -timeout 600 "\(I\)nstall, \(U\)pgrade, \(A\)utoinstall or \(S\)hell\?"
69+
send "i\n"
70+
71+
expect "Terminal type\?"
72+
send "vt220\n"
73+
74+
expect "System hostname\?"
75+
send "buildlet\n"
76+
77+
expect "Which network interface do you wish to configure\?"
78+
send "vio0\n"
79+
80+
expect "IPv4 address for vio0\?"
81+
send "dhcp\n"
82+
83+
expect "IPv6 address for vio0\?"
84+
send "none\n"
85+
86+
expect "Which network interface do you wish to configure\?"
87+
send "done\n"
88+
89+
expect "Password for root account\?"
90+
send "root\n"
91+
92+
expect "Password for root account\?"
93+
send "root\n"
94+
95+
expect "Start sshd\(8\) by default\?"
96+
send "yes\n"
97+
98+
expect "Start ntpd\(8\) by default\?"
99+
send "no\n"
100+
101+
expect "Do you expect to run the X Window System\?"
102+
send "no\n"
103+
104+
expect "Do you want the X Window System to be started by xdm\(1\)\?"
105+
send "no\n"
106+
107+
expect "Do you want to suspend on lid close\?"
108+
send "no\n"
109+
110+
expect "Change the default console to com0\?"
111+
send "yes\n"
112+
113+
expect "Which speed should com0 use\?"
114+
send "115200\n"
115+
116+
expect "Setup a user\?"
117+
send "gopher\n"
118+
119+
expect "Full name for user gopher\?"
120+
send "Gopher Gopherson\n"
121+
122+
expect "Password for user gopher\?"
123+
send "gopher\n"
124+
125+
expect "Password for user gopher\?"
126+
send "gopher\n"
127+
128+
expect "Since you set up a user, disable sshd\(8\) logins to root\?"
129+
send "yes\n"
130+
131+
expect "What timezone are you in\?"
132+
send "US/Pacific\n"
133+
134+
expect "Which disk is the root disk\?"
135+
send "sd0\n"
136+
137+
expect "Use DUIDs rather than device names in fstab\?"
138+
send "yes\n"
139+
140+
expect "Use \(W\)hole disk or \(E\)dit the MBR\?"
141+
send "whole\n"
142+
143+
expect "Use \(A\)uto layout, \(E\)dit auto layout, or create \(C\)ustom layout\?"
144+
send "custom\n"
145+
146+
expect "> "
147+
send "z\n"
148+
149+
expect "> "
150+
send "a b\n"
151+
expect "offset: "
152+
send "\n"
153+
expect "size: "
154+
send "1G\n"
155+
expect "FS type: "
156+
send "swap\n"
157+
158+
expect "> "
159+
send "a a\n"
160+
expect "offset: "
161+
send "\n"
162+
expect "size: "
163+
send "\n"
164+
expect "FS type: "
165+
send "4.2BSD\n"
166+
expect "mount point: "
167+
send "/\n"
168+
169+
expect "> "
170+
send "w\n"
171+
expect "> "
172+
send "q\n"
173+
174+
expect "Location of sets\?"
175+
send "cd\n"
176+
177+
expect "Which CD-ROM contains the install media\?"
178+
send "cd0\n"
179+
180+
expect "Pathname to the sets\?"
181+
send "5.6/amd64\n"
182+
183+
expect "Set name\(s\)\?"
184+
send "+*\n"
185+
186+
expect "Set name\(s\)\?"
187+
send " -x*\n"
188+
189+
expect "Set name\(s\)\?"
190+
send " -game*\n"
191+
192+
expect "Set name\(s\)\?"
193+
send " -man*\n"
194+
195+
expect "Set name\(s\)\?"
196+
send "done\n"
197+
198+
expect "Directory does not contain SHA256\.sig\. Continue without verification\?"
199+
send "yes\n"
200+
201+
# Need to wait for previous sets to unpack.
202+
expect -timeout 600 "Location of sets\?"
203+
send "done\n"
204+
205+
# Need to wait for install.site to install curl.
206+
expect -timeout 600 "CONGRATULATIONS!"
207+
208+
expect "# "
209+
send "halt\n"
210+
211+
expect "Please press any key to reboot.\n"
212+
send "\n"
213+
214+
expect "boot>"
215+
send "\n"
216+
217+
expect -timeout 600 eof
218+
EOF
219+
220+
# Create Compute Engine disk image.
221+
echo "Zipping disk.raw... (this may take a while)"
222+
tar -Szcf openbsd-amd64-gce.tar.gz disk.raw
223+
224+
echo "Done. GCE image is openbsd-amd64-gce.tar.gz."

0 commit comments

Comments
 (0)