Skip to content

Commit a0b6353

Browse files
mknyszekgopherbot
authored andcommitted
env/freebsd-amd64: port to LUCI and upgrade to 14.1
Port to LUCI includes: - Install Python. - Install bootstrapswarm. - Use bootstrapswarm instead of buildlet. For golang/go#61095. Change-Id: Ie787f6d098186259398ad135b60758e1ce8b489c Reviewed-on: https://go-review.googlesource.com/c/build/+/616836 Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent c4345a7 commit a0b6353

File tree

3 files changed

+51
-19
lines changed

3 files changed

+51
-19
lines changed

env/freebsd-amd64/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44
upload-staging:
55
go install golang.org/x/build/cmd/upload
6-
upload --verbose --file=freebsd-amd64-112.tar.gz --public dev-go-builder-data/freebsd-amd64-112.tar.gz
6+
upload --verbose --file=freebsd-amd64-141.tar.gz --public dev-go-builder-data/freebsd-amd64-141.tar.gz
77

88
upload-prod:
99
go install golang.org/x/build/cmd/upload
10-
upload --verbose --file=freebsd-amd64-112.tar.gz --public go-builder-data/freebsd-amd64-112.tar.gz
10+
upload --verbose --file=freebsd-amd64-141.tar.gz --public go-builder-data/freebsd-amd64-141.tar.gz
1111

1212
create-image-staging:
13-
gcloud compute --project go-dashboard-dev images create freebsd-amd64-112 --source-uri gs://dev-go-builder-data/freebsd-amd64-112.tar.gz
13+
gcloud compute --project go-dashboard-dev images create freebsd-amd64-141 --source-uri gs://dev-go-builder-data/freebsd-amd64-141.tar.gz
1414

1515
create-image-prod:
16-
gcloud compute --project symbolic-datum-552 images create freebsd-amd64-112 --source-uri gs://go-builder-data/freebsd-amd64-112.tar.gz
16+
gcloud compute --project symbolic-datum-552 images create freebsd-amd64-141 --source-uri gs://go-builder-data/freebsd-amd64-141.tar.gz
1717

1818
delete-image-prod:
19-
gcloud compute --project symbolic-datum-552 images delete freebsd-amd64-112
19+
gcloud compute --project symbolic-datum-552 images delete freebsd-amd64-141

env/freebsd-amd64/buildlet

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,42 @@ load_rc_config $name
2222
buildlet_prestart()
2323
{
2424
local buildlet_url
25+
local project
26+
local gcehost
27+
local buildletsh
28+
local swarming
2529

2630
info $(netstat -rn)
2731
info $(cat /etc/resolv.conf)
2832

29-
buildlet_url=$(/usr/local/bin/curl -s -H "Metadata-Flavor: Google" \
30-
http://metadata.google.internal/computeMetadata/v1/instance/attributes/buildlet-binary-url)
33+
project=$(/usr/local/bin/curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/project/project-id)
34+
info "Found project GCE ${project}."
35+
case "$project" in
36+
*luci*)
37+
info "Setting up bootstrapswarm..."
3138

32-
if ! /usr/local/bin/curl -o /buildlet "${buildlet_url}"; then
33-
warn "failed to download buildlet from ${buildlet_url}"
34-
poweroff
35-
return 1
36-
fi
39+
gcehost=$(/usr/local/bin/curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/hostname | cut -d . -f 1)
40+
info "Found GCE host ${gcehost}."
41+
42+
swarming=$(/usr/local/bin/curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/swarming | cut -d . -f 1)
43+
swarming="${swarming}.appspot.com"
44+
info "Found Swarming host ${swarming}."
45+
46+
buildletsh="#!/bin/sh\n\nset -x\n\nsu -l swarming -c \"/usr/local/bin/bootstrapswarm --hostname $gcehost --swarming $swarming\"\n"
47+
echo -e $buildletsh >/buildlet
48+
;;
49+
*)
50+
info "Setting up buildlet..."
51+
buildlet_url=$(/usr/local/bin/curl -s -H "Metadata-Flavor: Google" \
52+
http://metadata.google.internal/computeMetadata/v1/instance/attributes/buildlet-binary-url)
53+
54+
if ! /usr/local/bin/curl -o /buildlet "${buildlet_url}"; then
55+
warn "failed to download buildlet from ${buildlet_url}"
56+
poweroff
57+
return 1
58+
fi
59+
;;
60+
esac
3761

3862
chmod a+x /buildlet
3963
}

env/freebsd-amd64/make.bash

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Builds FreeBSD image based on raw disk images provided by FreeBSD.org
77
# This script boots the image once, side-loads GCE Go builder configuration via
88
# an ISO mounted as the CD-ROM, and customizes the system before powering down.
9-
# SSH is enabled, and a user gopher, password gopher, is created.
9+
# SSH is enabled, and a user swarming, password swarming, is created.
1010

1111
# Only tested on Ubuntu 20.04.
1212
# Requires packages: qemu-system-x86 qemu-img expect genisoimage
@@ -99,9 +99,15 @@ case $1 in
9999
readonly SHA256=7b8fcc2330c8d9f66dd012c5859167d56c227ece39188c8f55b2bddbf688875f # https://lists.freebsd.org/archives/freebsd-snapshots/2021-December/000036.html
100100
readonly BLIND_SWITCH_CONSOLE=1
101101
;;
102+
14.1)
103+
readonly VERSION=14.1-RELEASE
104+
readonly VERSION_TRAILER=
105+
readonly SHA256=f2eb6f0033e573f580d43f0cf5a0e9c17c6994de9e502c711fd2325dac3b8f69
106+
readonly BLIND_SWITCH_CONSOLE=1
107+
;;
102108
*)
103109
echo "Usage: $0 <version>"
104-
echo " version - FreeBSD version to build. Valid choices: 9.3 10.3 10.4 11.0 11.1 11.2 11.3 11.4 12.0 12.1 12.2 13.0 13.0-SNAPSHOT"
110+
echo " version - FreeBSD version to build. Valid choices: 9.3 10.3 10.4 11.0 11.1 11.2 11.3 11.4 12.0 12.1 12.2 13.0 13.0-SNAPSHOT 14.1"
105111
exit 1
106112
esac
107113

@@ -120,26 +126,28 @@ fi
120126

121127
qemu-img create -f qcow2 -b FreeBSD-${VERSION:?}-amd64${VERSION_TRAILER}.raw -F raw disk.qcow2 16G
122128

123-
mkdir -p iso/boot iso/etc iso/usr/local/etc/rc.d
129+
mkdir -p iso/boot iso/etc iso/usr/local/etc/rc.d iso/usr/local/bin
124130
cp loader.conf iso/boot
125131
cp rc.conf iso/etc
126132
cp sysctl.conf iso/etc
127133
cp buildlet iso/usr/local/etc/rc.d
134+
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o iso/usr/local/bin/bootstrapswarm golang.org/x/build/cmd/bootstrapswarm
128135

129136
cat >iso/install.sh <<'EOF'
130137
#!/bin/sh
131138
set -x
132139
133-
mkdir -p /usr/local/etc/rc.d/
140+
mkdir -p /usr/local/etc/rc.d/ /usr/local/bin/
134141
cp /mnt/usr/local/etc/rc.d/buildlet /usr/local/etc/rc.d/buildlet
135142
chmod +x /usr/local/etc/rc.d/buildlet
136143
cp /mnt/boot/loader.conf /boot/loader.conf
137144
cp /mnt/etc/rc.conf /etc/rc.conf
145+
cp /mnt/usr/local/bin/bootstrapswarm /usr/local/bin/bootstrapswarm
138146
cat /mnt/etc/sysctl.conf >> /etc/sysctl.conf
139147
adduser -f - <<ADDUSEREOF
140-
gopher::::::Gopher Gopherson::/bin/sh:gopher
148+
swarming::::::Swarming Gopher Gopherson::/bin/sh:swarming
141149
ADDUSEREOF
142-
pw user mod gopher -G wheel
150+
pw user mod swarming -G wheel
143151
144152
# Enable serial console early in boot process.
145153
echo '-h' > /boot.conf
@@ -238,7 +246,7 @@ if {$::env(DOWNLOAD_UPDATES)} {
238246
239247
expect -re $prompt
240248
sleep 1
241-
send "pkg install -y bash curl git gdb\n"
249+
send "pkg install -y bash curl git gdb python\n"
242250
243251
expect -re $prompt
244252
send "sync\n"

0 commit comments

Comments
 (0)