From 26482ee87c2bf3518c64a6d65c2c388eb99d91da Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 14 Jul 2026 02:32:42 -0400 Subject: [PATCH] nixos/tests/systemd-boot: Preserve length in sed --- nixos/tests/systemd-boot.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/tests/systemd-boot.nix b/nixos/tests/systemd-boot.nix index f36d3870f98e..020644db86a8 100644 --- a/nixos/tests/systemd-boot.nix +++ b/nixos/tests/systemd-boot.nix @@ -460,19 +460,17 @@ in nodes.machine = common; testScript = - let - oldVersion = "222"; - in # python '' machine.succeed("mount -o remount,rw /boot") def switch(): - # Replace version inside sd-boot with something older. See magic[] string in systemd src/boot/efi/boot.c + # Replace version inside sd-boot with something older. See SD_MAGIC in systemd src/boot/boot.c + # Note: the sed replacement has to be length-preserving, because section length matters. machine.succeed( - """ + r""" find /boot -iname '*boot*.efi' -print0 | \ - xargs -0 -I '{}' sed -i 's/#### LoaderInfo: systemd-boot .* ####/#### LoaderInfo: systemd-boot ${oldVersion} ####/' '{}' + xargs -0 -I '{}' sed -i 's/#### LoaderInfo: systemd-boot [0-9]\(.*\) ####/#### LoaderInfo: systemd-boot 0\1 ####/' '{}' """ ) return machine.succeed("/run/current-system/bin/switch-to-configuration boot 2>&1")