Skip to content

Commit 453f0a4

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 2638346 commit 453f0a4

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
@@ -932,13 +932,25 @@ update_rootfs_boot_kernel()
932932
sudo cp "$builddir/mkosi.extra/boot/vmlinuz-$kver" "$builddir/mnt/run-qemu-kernel/$kver/vmlinuz"
933933

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

943955
[[ "$_arg_legacy_bios" == 'on' ]] || install_opt_efi_shell
944956

0 commit comments

Comments
 (0)