Skip to content

Commit

Permalink
livecd2.bats: fix the fragile way we removed the sudi disk from machine
Browse files Browse the repository at this point in the history
Signed-off-by: Serge Hallyn <[email protected]>
  • Loading branch information
hallyn committed Sep 6, 2023
1 parent a94bd4d commit 538c088
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
libseccomp-dev libsquashfs-dev lxc lxc-dev make mtools\
openssl pip pkgconf skopeo socat squashfuse swtpm jq \
uidmap umoci qemu-utils qemu-system-x86 xorriso \
ubuntu-dev-tools make gcc squashfs-tools sbsigntool
ubuntu-dev-tools make gcc squashfs-tools sbsigntool \
python3-yaml
sudo modprobe kvm
sudo adduser $(whoami) kvm
sudo chmod o+rw /dev/kvm
Expand Down Expand Up @@ -153,8 +154,8 @@ jobs:
apt-get install -q -y git golang-go;
apt-get install -y bats golang make openssl swtpm tpm2-tools \
libcryptsetup-dev libgpgme-dev libcap-dev qemu-kvm \
libdevmapper-dev libacl1-dev libarchive-tools pip squashfs-tools \
sbsigntool wget
libdevmapper-dev libacl1-dev libarchive-tools pip python3-yaml \
sbsigntool squashfs-tools wget
pip install virt-firmware
mv /usr/lib/go /usr/lib/go.no || true
cd /tmp/
Expand Down
6 changes: 4 additions & 2 deletions tests/livecd2.bats
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ EOF
--bootkit-layer oci:oci:bootkit-squashfs \
--output install.iso --tlayer oci:oci:target-rootfs-squashfs

mv -f install.iso $HOME/.local/share/machine/trust/keys/snakeoil/artifacts/install.iso
echo "updating ${VMNAME} to boot from install.iso"
echo "yaml before:"
machine info "${VMNAME}"
cat > sed1.bash << EOF
#!/bin/bash
sed -i 's/provision.iso/install.iso/' \$*
# There has to be a better way than to delete 6 lines...
sed -i '/sudi.vfat/,+3d' \$*
EOF
chmod 755 sed1.bash
VISUAL=$(pwd)/sed1.bash machine edit "${VMNAME}"
export VISUAL=${TOPDIR}/tools/machine_remove_sudi.py
timeout 10s machine edit "${VMNAME}"
export -n VISUAL
machine start "${VMNAME}"
wait_for_vm
echo "about to start provisioned machine to install"
Expand Down
19 changes: 19 additions & 0 deletions tools/machine_remove_sudi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /usr/bin/env python3

import yaml
import sys

if len(sys.argv) != 2:
print("filename is a required argument")
sys.exit(1)
filename = sys.argv[1]
with open(filename) as f:
m = yaml.safe_load(f)
l = len(m['config']['disks'])
d = m['config']['disks']
for i in range(0,l):
if d[i]['file'].endswith('sudi.vfat'):
del m['config']['disks'][i]
with open(filename, "w") as f:
yaml.dump(m, f)

0 comments on commit 538c088

Please sign in to comment.