Skip to content

Commit 0bebfd9

Browse files
authored
Merge pull request #1847 from flatcar/kai/unify-qemu
Set up symlinks for same image artifacts to remove qemu/qemu_uefi_secure
2 parents 385b929 + de4eb8f commit 0bebfd9

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,23 @@ jobs:
218218
formats=$(echo "$formats" | tr ' ' '\n' | sed 's/equinix_metal/packet/g')
219219
220220
for format in ${formats}; do
221+
if [ "${format}" = qemu ] || [ "${format}" = qemu_uefi_secure ]; then
222+
continue
223+
fi
221224
echo " ################### VENDOR '${format}' ################### "
222225
./run_sdk_container -n "${container_name}" \
223226
./image_to_vm.sh --format "${format}" --board="${arch}-usr" \
224227
--from "${CI_CONTAINER_ARTIFACT_ROOT}/${arch}-usr/latest" \
225228
--image_compression_formats=bz2
226229
done
227230
231+
# Zip doesn't handle symlinks well, remove them
232+
rm -f artifacts/${arch}-usr/latest/flatcar_production_{qemu,qemu_uefi_secure}_image.img*
233+
# or create an explicit copy:
234+
if [ -e artifacts/${arch}-usr/latest/flatcar_production_pxe.vmlinuz ]; then
235+
rm -f artifacts/${arch}-usr/latest/flatcar_production_pxe.vmlinuz
236+
cp artifacts/${arch}-usr/latest/flatcar_production_{image,pxe}.vmlinuz
237+
fi
228238
# upload-artifacts cannot handle artifact uploads from sym-linked directories (no, really)
229239
# so we move things around.
230240
mkdir -p artifacts/images

build_library/release_util.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,21 @@ compress_file() {
6767
;;
6868
esac
6969

70-
${IMAGE_ZIPPER} -f "${filepath}" 2>&1 >/dev/null || die "failed to compress ${filepath}"
70+
# Check if symlink in which case we set up a "compressed" symlink
71+
local compressed_name="${filepath}.${compression_format}"
72+
if [ -L "${filepath}" ]; then
73+
# We could also test if the target exists and otherwise do the compression
74+
# but we might then end up with two different compressed artifacts
75+
local link_target
76+
link_target=$(readlink -f "${filepath}")
77+
local target_basename
78+
target_basename=$(basename "${link_target}")
79+
ln -fs "${target_basename}.${compression_format}" "${compressed_name}"
80+
else
81+
${IMAGE_ZIPPER} -f "${filepath}" 2>&1 >/dev/null || die "failed to compress ${filepath}"
82+
fi
7183

72-
echo -n "${filepath}.${compression_format}"
84+
echo -n "${compressed_name}"
7385
}
7486

7587
compress_disk_images() {
@@ -85,7 +97,7 @@ compress_disk_images() {
8597
# Files that did not match the filter for disk images.
8698
local -n local_extra_files="$3"
8799

88-
info "Compressing images"
100+
info "Compressing ${#local_files_to_evaluate[@]} images"
89101
# We want to compress images, but we also want to remove the uncompressed files
90102
# from the list of uploadable files.
91103
for filename in "${local_files_to_evaluate[@]}"; do
@@ -98,6 +110,9 @@ compress_disk_images() {
98110

99111
# An associative array we set an element on whenever we process a format.
100112
# This way we don't process the same format twice. A unique for array elements.
113+
# (But first we need to unset the previous loop or we can only compress a single
114+
# file per list of files).
115+
unset processed_format
101116
declare -A processed_format
102117
for format in "${FORMATS[@]}";do
103118
if [ -z "${processed_format[${format}]}" ]; then
@@ -113,7 +128,10 @@ compress_disk_images() {
113128
[ "${filename##*/}" != "flatcar_production_image.bin" ] &&
114129
[ "${filename##*/}" != "flatcar_production_update.bin" ] &&
115130
! echo "${FORMATS[@]}" | grep -q "none"; then
131+
info "Removing ${filename}"
116132
rm "${filename}"
133+
else
134+
info "Keeping ${filename}"
117135
fi
118136
else
119137
local_extra_files+=( "${filename}" )

build_library/vm_image_util.sh

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ VALID_IMG_TYPES=(
2323
packet
2424
parallels
2525
pxe
26-
qemu
2726
qemu_uefi
28-
qemu_uefi_secure
2927
rackspace
3028
rackspace_onmetal
3129
rackspace_vhd
@@ -126,27 +124,13 @@ IMG_DEFAULT_MEM=2048
126124
IMG_DEFAULT_CPUS=2
127125

128126
## qemu
129-
IMG_qemu_DISK_FORMAT=qcow2
130-
IMG_qemu_DISK_LAYOUT=vm
131-
IMG_qemu_CONF_FORMAT=qemu
132-
IMG_qemu_OEM_USE=qemu
133-
IMG_qemu_OEM_PACKAGE=common-oem-files
134-
IMG_qemu_OEM_SYSEXT=oem-qemu
135-
136127
IMG_qemu_uefi_DISK_FORMAT=qcow2
137128
IMG_qemu_uefi_DISK_LAYOUT=vm
138129
IMG_qemu_uefi_CONF_FORMAT=qemu_uefi
139130
IMG_qemu_uefi_OEM_USE=qemu
140131
IMG_qemu_uefi_OEM_PACKAGE=common-oem-files
141132
IMG_qemu_uefi_OEM_SYSEXT=oem-qemu
142133

143-
IMG_qemu_uefi_secure_DISK_FORMAT=qcow2
144-
IMG_qemu_uefi_secure_DISK_LAYOUT=vm
145-
IMG_qemu_uefi_secure_CONF_FORMAT=qemu_uefi_secure
146-
IMG_qemu_uefi_secure_OEM_USE=qemu
147-
IMG_qemu_uefi_secure_OEM_PACKAGE=common-oem-files
148-
IMG_qemu_uefi_secure_OEM_SYSEXT=oem-qemu
149-
150134
## xen
151135
IMG_xen_CONF_FORMAT=xl
152136

@@ -326,7 +310,7 @@ get_default_vm_type() {
326310
local board="$1"
327311
case "$board" in
328312
amd64-usr)
329-
echo "qemu"
313+
echo "qemu_uefi"
330314
;;
331315
arm64-usr)
332316
echo "qemu_uefi"
@@ -603,6 +587,18 @@ write_vm_disk() {
603587
info "Writing $disk_format image $(basename "${VM_DST_IMG}")"
604588
_write_${disk_format}_disk "${VM_TMP_IMG}" "${VM_DST_IMG}"
605589

590+
# We now only support building qemu_uefi and set up symlinks
591+
# for the qemu and qemu_uefi_secure images
592+
if [ "${VM_IMG_TYPE}" = qemu_uefi ]; then
593+
local qemu="${VM_DST_IMG/qemu_uefi/qemu}"
594+
local qemu_uefi_secure="${VM_DST_IMG/qemu_uefi/qemu_uefi_secure}"
595+
local target_basename
596+
target_basename=$(basename "${VM_DST_IMG}")
597+
ln -fs "${target_basename}" "${qemu}"
598+
ln -fs "${target_basename}" "${qemu_uefi_secure}"
599+
VM_GENERATED_FILES+=( "${qemu}" "${qemu_uefi_secure}" )
600+
fi
601+
606602
# Add disk image to final file list if it isn't going to be bundled
607603
if [[ -z "$(_get_vm_opt BUNDLE_FORMAT)" ]]; then
608604
VM_GENERATED_FILES+=( "${VM_DST_IMG}" )
@@ -693,7 +689,7 @@ _write_cpio_disk() {
693689
local grub_name="$(_dst_name "_grub.efi")"
694690
_write_cpio_common $@
695691
# Pull the kernel and loader out of the filesystem
696-
cp "${base_dir}"/boot/flatcar/vmlinuz-a "${dst_dir}/${vmlinuz_name}"
692+
ln -fs flatcar_production_image.vmlinuz "${dst_dir}/${vmlinuz_name}"
697693

698694
local grub_arch
699695
case $BOARD in
@@ -809,6 +805,13 @@ _write_qemu_uefi_conf() {
809805
sed -e "s%^VM_PFLASH_RO=.*%VM_PFLASH_RO='${flash_ro}'%" \
810806
-e "s%^VM_PFLASH_RW=.*%VM_PFLASH_RW='${flash_rw}'%" -i "${script}"
811807
VM_GENERATED_FILES+=( "$(_dst_dir)/${flash_ro}" "$(_dst_dir)/${flash_rw}" )
808+
809+
# We now only support building qemu_uefi and generate the
810+
# other artifacts from here
811+
if [ "${VM_IMG_TYPE}" = qemu_uefi ]; then
812+
VM_IMG_TYPE=qemu _write_qemu_conf
813+
VM_IMG_TYPE=qemu_uefi_secure _write_qemu_uefi_secure_conf
814+
fi
812815
}
813816

814817
_write_qemu_uefi_secure_conf() {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- SDK: Unified qemu image formats, so that the `qemu_uefi` build target provides the regular `qemu` and the `qemu_uefi_secure` artifacts ([scripts#1847](https://github.com/flatcar/scripts/pull/1847))

ci-automation/vms.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ function _vm_build_impl() {
125125
mv "${images_in}" "${CONTAINER_IMAGE_ROOT}/${arch}-usr/latest-input"
126126

127127
for format in ${formats}; do
128+
if [ "${format}" = qemu ] || [ "${format}" = qemu_uefi_secure ]; then
129+
continue
130+
fi
128131
echo " ################### VENDOR '${format}' ################### "
129132
COMPRESSION_FORMAT="bz2"
130133
if [[ "${format}" =~ ^(openstack_mini|digitalocean)$ ]];then

0 commit comments

Comments
 (0)