Skip to content

Commit 24b0a19

Browse files
committed
run_qemu.sh: refactor loader.conf logic to disable and append
Instead of editing in place, comment out and append. This preserves "history", especially when building in incremental mode. This is the "zero functional change" part of the QEMU / KVM / breakpoint PR #135 for issue #11 Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent ac8228b commit 24b0a19

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

run_qemu.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,13 +937,25 @@ update_rootfs_boot_kernel()
937937
sudo cp "$builddir/mkosi.extra/boot/vmlinuz-$kver" "$builddir/mnt/run-qemu-kernel/$kver/vmlinuz"
938938

939939
defconf="$builddir/mnt/loader/loader.conf"
940+
local loader_timeout=4
941+
942+
# mkosi->"bootctl install ..." creates a stub loader.conf.
943+
# It can also come from a previous run of this script.
940944
if [ -f "$defconf" ]; then
941-
sudo sed -i -e 's/^#.*timeout.*/timeout 4/' "$defconf"
942-
sudo sed -i -e '/default.*/d' "$defconf"
943-
else
944-
echo "timeout 4" | sudo tee "$defconf"
945+
# Comment out existing values. Last value seems to win but it's not
946+
# documented in "man loader.conf" so let's not rely on it
947+
sudo sed -i -e 's/^[[:blank:]]*timeout\(.*\)/# timeout \1/' "$defconf"
948+
sudo sed -i -e 's/^[[:blank:]]*default\(.*\)/# default \1/' "$defconf"
945949
fi
946-
echo "default run-qemu-kernel-$kver.conf" | sudo tee -a "$defconf"
950+
951+
{
952+
generatedfrom_header "update_rootfs_boot_kernel() >> $defconf"
953+
cat <<EOF
954+
timeout $loader_timeout
955+
default run-qemu-kernel-$kver.conf
956+
957+
EOF
958+
} | sudo tee -a "$defconf"
947959

948960
[[ "$_arg_legacy_bios" == 'on' ]] || install_opt_efi_shell
949961

0 commit comments

Comments
 (0)