Skip to main content

max / alloy

2.2 KB · 54 lines History Blame Raw
1 #!/usr/bin/env bash
2 #
3 # install-disk.sh — install a variant to state/disk.raw with bootc, ready to
4 # boot with vm.sh.
5 #
6 # install-disk.sh n1
7 #
8 # Destroys whatever was on the disk. That is the point: every case starts from
9 # a freshly installed machine, and reusing a disk across shapes is how a run
10 # ends up measuring the last run.
11 #
12 # --target-imgref is what makes the rest work. Without it the installed system
13 # would point at localhost/alloy-layertest, which resolves to nothing inside
14 # the guest, and no upgrade could ever be fetched. Pointing it at the host's
15 # registry is the same trick build-iso.sh --update-target plays for the ISO.
16 #
17 # No TPM, no encryption, unlike vmtest. This harness measures what rpm-ostree
18 # and bootc do to a layered package, and the encrypted path only adds ways for
19 # a run to fail for unrelated reasons.
20 set -euo pipefail
21
22 # shellcheck source=build/layertest/common.sh
23 . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
24
25 # shellcheck source=build/privilege.sh
26 . "$HERE/../privilege.sh"
27
28 MARK="${1:-}"
29 [ -n "$MARK" ] || die "usage: install-disk.sh <mark> (n1 n2 n3 n4 r1 l1)"
30 privc podman image exists "$IMAGE:$MARK" || die "no image $IMAGE:$MARK; run build.sh"
31
32 # The firmware variables go with the disk. Leaving them behind boots the old
33 # disk's boot entries against a new install and lands at a grub prompt, which
34 # is the same lesson vmtest's README records.
35 rm -f "$STATE/disk.raw" "$STATE/OVMF_VARS.fd"
36 truncate -s 20G "$STATE/disk.raw"
37
38 say "installing $MARK to state/disk.raw"
39 privc podman run --rm --privileged --pid=host \
40 --security-opt label=type:unconfined_t \
41 -v /var/lib/containers:/var/lib/containers \
42 -v /dev:/dev \
43 -v "$STATE:/output" \
44 "$IMAGE:$MARK" \
45 bootc install to-disk --via-loopback --generic-image --filesystem ext4 \
46 --target-imgref "$HOST_FROM_GUEST:$REGISTRY_PORT/alloy-layertest:latest" \
47 /output/disk.raw
48
49 # The installed system will pull its upgrades from :latest, so :latest has to
50 # be the variant just installed or the first upgrade would be a surprise.
51 privc podman push --tls-verify=false "$IMAGE:$MARK" \
52 "127.0.0.1:$REGISTRY_PORT/alloy-layertest:latest" >/dev/null 2>&1
53 say "installed $MARK, and pushed it as :latest"
54