Skip to content

Commit

Permalink
Prepare image build scripts for automated rebuilds (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
delan committed Jan 2, 2025
1 parent 37b7bd0 commit bb54d2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ To build the base vm image:

- Download images into /var/lib/libvirt/images
- Windows 10 (multi-edition ISO), English (United States): [Win10_22H2_English_x64v1.iso](https://www.microsoft.com/en-us/software-download/windows10ISO) (sha256 = a6f470ca6d331eb353b815c043e327a347f594f37ff525f17764738fe812852e)
- Run the build script: `windows10/build-image.sh`
- Run the build script: `windows10/build-image.sh <pick a snapshot name>`
- FIXME: if Windows fails to autologon (stuck at lock screen): `virsh reboot servo-windows10.new`
- Update the profile config in `monitor/monitor.toml` to point to the new zvol snapshot, e.g. `base_image_snapshot = "build-image-2025-01-01T11:30Z"`
- Update the profile config in `monitor/monitor.toml` to point to the new zvol snapshot, e.g. `base_image_snapshot = "<snapshot name>"`
- Restart the monitor: `systemctl restart monitor`

To clone and start a new runner:

Expand All @@ -130,8 +131,9 @@ Runners created from this image preinstall all dependencies (including those spe

To build the base vm image:

- Run the build script: `ubuntu2204/build-image.sh`
- Update the profile config in `monitor/monitor.toml` to point to the new zvol snapshot, e.g. `base_image_snapshot = "build-image-2025-01-01T11:30Z"`
- Run the build script: `ubuntu2204/build-image.sh <pick a snapshot name>`
- Update the profile config in `monitor/monitor.toml` to point to the new zvol snapshot, e.g. `base_image_snapshot = "<snapshot name>"`
- Restart the monitor: `systemctl restart monitor`

To clone and start a new runner:

Expand Down
9 changes: 5 additions & 4 deletions ubuntu2204/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env zsh
# usage: ubuntu2204/build-image.sh
# usage: ubuntu2204/build-image.sh <snapshot_name>
image_dir=${0:a:h}
script_dir=${0:a:h}/..
. "$script_dir/common.sh"
Expand All @@ -9,6 +9,7 @@ cache_dir=$script_dir/cache
. "$script_dir/inject.sh"
undo_commands=$(mktemp)
image_name=servo-ubuntu2204
snapshot_name=$1; shift

>&2 echo '[*] Caching downloads'
download "$cache_dir" https://cloud-images.ubuntu.com/jammy/20241217/jammy-server-cloudimg-amd64.img 0d8345a343c2547e55ac815342e6cb4a593aa5556872651eb47e6856a2bb0cdd
Expand All @@ -21,6 +22,7 @@ zfs list -Ho name "$SERVO_CI_ZFS_CLONE_PREFIX/$image_name" || zfs create -V 90G

>&2 echo '[*] Creating libvirt guest (or recreating it with new config)'
if virsh domstate -- "$image_name"; then
virsh destroy -- "$image_name" || : # FIXME make this idempotent in a less noisy way?
virsh undefine -- "$image_name"
fi
virsh define -- "$image_dir/guest.xml"
Expand Down Expand Up @@ -74,8 +76,7 @@ fi
>&2 echo '[*] Checking that Servo was built correctly'
./mount-runner.sh "$image_name" sh -c 'ls init/built_servo_once_successfully'

snapshot=$(date -u +\%FT\%RZ)
>&2 echo "[*] Taking zvol snapshot: $SERVO_CI_ZFS_CLONE_PREFIX/$image_name@build-image-$snapshot"
zfs snapshot "$SERVO_CI_ZFS_CLONE_PREFIX/$image_name@build-image-$snapshot"
>&2 echo "[*] Taking zvol snapshot: $SERVO_CI_ZFS_CLONE_PREFIX/$image_name@$snapshot_name"
zfs snapshot "$SERVO_CI_ZFS_CLONE_PREFIX/$image_name@$snapshot_name"

>&2 echo '[*] Done!'
9 changes: 5 additions & 4 deletions windows10/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env zsh
# usage: windows10/build-image.sh
# usage: windows10/build-image.sh <snapshot_name>
image_dir=${0:a:h}
script_dir=${0:a:h}/..
. "$script_dir/common.sh"
Expand All @@ -9,6 +9,7 @@ cache_dir=$script_dir/cache
. "$script_dir/inject.sh"
undo_commands=$(mktemp)
image_name=servo-windows10
snapshot_name=$1; shift

>&2 echo '[*] Caching downloads'
download "$cache_dir" https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.240-1/virtio-win-0.1.240.iso ebd48258668f7f78e026ed276c28a9d19d83e020ffa080ad69910dc86bbcbcc6
Expand All @@ -18,6 +19,7 @@ zfs list -Ho name "$SERVO_CI_ZFS_CLONE_PREFIX/$image_name" || zfs create -V 90G

>&2 echo '[*] Creating libvirt guest (or recreating it with new config)'
if virsh domstate -- "$image_name"; then
virsh destroy -- "$image_name" || : # FIXME make this idempotent in a less noisy way?
virsh undefine -- "$image_name"
fi
virsh define -- "$image_dir/guest.xml"
Expand Down Expand Up @@ -71,8 +73,7 @@ fi
>&2 echo '[*] Checking that Servo was built correctly'
./mount-runner.sh "$image_name" sh -c 'ls -l init/built_servo_once_successfully'

snapshot=$(date -u +\%FT\%RZ)
>&2 echo "[*] Taking zvol snapshot: $SERVO_CI_ZFS_CLONE_PREFIX/$image_name@build-image-$snapshot"
zfs snapshot "$SERVO_CI_ZFS_CLONE_PREFIX/$image_name@build-image-$snapshot"
>&2 echo "[*] Taking zvol snapshot: $SERVO_CI_ZFS_CLONE_PREFIX/$image_name@$snapshot_name"
zfs snapshot "$SERVO_CI_ZFS_CLONE_PREFIX/$image_name@$snapshot_name"

>&2 echo '[*] Done!'

0 comments on commit bb54d2a

Please sign in to comment.