diff --git a/src/cmd-build b/src/cmd-build index bcb052cb9c..33b891ea31 100755 --- a/src/cmd-build +++ b/src/cmd-build @@ -230,9 +230,17 @@ img_base=tmp/${imageprefix}-base.qcow2 # forgive me for this sin checksum_location=$(find /usr/lib/coreos-assembler-anaconda/ -name '*CHECKSUM' | head -1) +build_image() { + local size + size="$(python3 -c 'import sys, yaml; print(yaml.load(sys.stdin)["size"])' < "$configdir/image.yaml")G" + qemu-img create -f qcow2 "$workdir/diskimage.qcow2" "$size" + runvm /usr/lib/coreos-assembler/create_disk.sh /dev/vda "$tmprepo" "${ref-:${commit}}" /usr/lib/coreos-assembler/grub.cfg + mv "$workdir/diskimage.qcow2" "$img_base" +} + if [ -n "${build_qemu}" ]; then img_qemu=${imageprefix}-qemu.qcow2 - run_virtinstall "${tmprepo}" "${ref}" "${PWD}"/"${img_base}" --variant=cloud + build_image /usr/lib/coreos-assembler/gf-platformid "$(pwd)"/"${img_base}" "$(pwd)"/"${img_qemu}" qemu fi diff --git a/src/cmdlib.sh b/src/cmdlib.sh index b9a843b28c..ffe781a06c 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -367,6 +367,12 @@ EOF arch_args='-bios /usr/share/AAVMF/AAVMF_CODE.fd' fi + # if a disk image exists, attach it too + extradisk=() + if [ -f "${workdir}/diskimage.qcow2" ]; then + extradisk=("-drive" "if=virtio,id=target,format=qcow2,file=${workdir}/diskimage.qcow2") + fi + #shellcheck disable=SC2086 ${QEMU_KVM} ${arch_args:-} \ -nodefaults -nographic -m 2048 -no-reboot -cpu host \ @@ -381,7 +387,8 @@ EOF -drive if=none,id=drive-scsi0-0-0-1,discard=unmap,file="${workdir}/cache/cache.qcow2" \ -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 \ -virtfs local,id=workdir,path="${workdir}",security_model=none,mount_tag=workdir \ - "${srcvirtfs[@]}" -serial stdio -append "root=/dev/sda console=${VM_TERMINAL} selinux=1 enforcing=0 autorelabel=1" + "${srcvirtfs[@]}" -serial stdio -append "root=/dev/sda console=${VM_TERMINAL} selinux=1 enforcing=0 autorelabel=1" \ + "${extradisk[@]}" if [ ! -f "${workdir}"/tmp/rc ]; then fatal "Couldn't find rc file, something went terribly wrong!" diff --git a/src/gf-platformid b/src/gf-platformid index 01c48095b6..2cf1996d0c 100755 --- a/src/gf-platformid +++ b/src/gf-platformid @@ -38,22 +38,7 @@ chmod u+w "${tmp_dest}" coreos_gf_run_mount "${tmp_dest}" # Inject PLATFORM label in all relevant places: -# * grub config # * BLS config (for subsequent config regeneration) -# First, the grub config. -if [ "$(coreos_gf exists '/boot/efi')" == 'true' ]; then - grubcfg_path=$(coreos_gf glob-expand /boot/efi/EFI/*/grub.cfg) -else - grubcfg_path=/boot/loader/grub.cfg -fi -coreos_gf download "${grubcfg_path}" "${tmpd}"/grub.cfg -# Remove any platformid currently there -sed -i -e 's, ignition.platform.id=[a-zA-Z0-9]*,,g' "${tmpd}"/grub.cfg -# Insert our new platformid -# Match linux16, linux and linuxefi since only linux is available on aarch64 -# and linuxefi is available in grub2.cfg for UEFI -sed -i -e 's,^\(linux\(16\|efi\)\? .*\),\1 ignition.platform.id='"${platformid}"',' "${tmpd}"/grub.cfg -coreos_gf upload "${tmpd}"/grub.cfg "${grubcfg_path}" # Now the BLS version blscfg_path=$(coreos_gf glob-expand /boot/loader/entries/ostree-*.conf) coreos_gf download "${blscfg_path}" "${tmpd}"/bls.conf