mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge pull request #140046 from jrobsonchase/systemd-boot/fix-regexp
nixos/systemd-boot: Fix installed version regexp
This commit is contained in:
commit
6ae271565d
2 changed files with 16 additions and 8 deletions
|
@ -244,19 +244,27 @@ def main() -> None:
|
||||||
subprocess.check_call(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@"] + flags + ["install"])
|
subprocess.check_call(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@"] + flags + ["install"])
|
||||||
else:
|
else:
|
||||||
# Update bootloader to latest if needed
|
# Update bootloader to latest if needed
|
||||||
systemd_version = subprocess.check_output(["@systemd@/bin/bootctl", "--version"], universal_newlines=True).split()[1]
|
systemd_version = subprocess.check_output(["@systemd@/bin/bootctl", "--version"], universal_newlines=True).split()[2]
|
||||||
sdboot_status = subprocess.check_output(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@", "status"], universal_newlines=True)
|
sdboot_status = subprocess.check_output(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@", "status"], universal_newlines=True)
|
||||||
|
|
||||||
# See status_binaries() in systemd bootctl.c for code which generates this
|
# See status_binaries() in systemd bootctl.c for code which generates this
|
||||||
m = re.search("^\W+File:.*/EFI/(BOOT|systemd)/.*\.efi \(systemd-boot (\d+)\)$",
|
m = re.search("^\W+File:.*/EFI/(BOOT|systemd)/.*\.efi \(systemd-boot ([\d.]+[^)]*)\)$",
|
||||||
sdboot_status, re.IGNORECASE | re.MULTILINE)
|
sdboot_status, re.IGNORECASE | re.MULTILINE)
|
||||||
|
|
||||||
|
needs_install = False
|
||||||
|
|
||||||
if m is None:
|
if m is None:
|
||||||
print("could not find any previously installed systemd-boot")
|
print("could not find any previously installed systemd-boot, installing.")
|
||||||
|
# Let systemd-boot attempt an installation if a previous one wasn't found
|
||||||
|
needs_install = True
|
||||||
else:
|
else:
|
||||||
sdboot_version = m.group(2)
|
sdboot_version = f'({m.group(2)})'
|
||||||
if systemd_version > sdboot_version:
|
if systemd_version != sdboot_version:
|
||||||
print("updating systemd-boot from %s to %s" % (sdboot_version, systemd_version))
|
print("updating systemd-boot from %s to %s" % (sdboot_version, systemd_version))
|
||||||
subprocess.check_call(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@", "update"])
|
needs_install = True
|
||||||
|
|
||||||
|
if needs_install:
|
||||||
|
subprocess.check_call(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@", "update"])
|
||||||
|
|
||||||
mkdir_p("@efiSysMountPoint@/efi/nixos")
|
mkdir_p("@efiSysMountPoint@/efi/nixos")
|
||||||
mkdir_p("@efiSysMountPoint@/loader/entries")
|
mkdir_p("@efiSysMountPoint@/loader/entries")
|
||||||
|
|
|
@ -102,12 +102,12 @@ in
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"""
|
"""
|
||||||
find /boot -iname '*.efi' -print0 | \
|
find /boot -iname '*.efi' -print0 | \
|
||||||
xargs -0 -I '{}' sed -i 's/#### LoaderInfo: systemd-boot .* ####/#### LoaderInfo: systemd-boot 001 ####/' '{}'
|
xargs -0 -I '{}' sed -i 's/#### LoaderInfo: systemd-boot .* ####/#### LoaderInfo: systemd-boot 000.0-1-notnixos ####/' '{}'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
output = machine.succeed("/run/current-system/bin/switch-to-configuration boot")
|
output = machine.succeed("/run/current-system/bin/switch-to-configuration boot")
|
||||||
assert "updating systemd-boot from 001 to " in output
|
assert "updating systemd-boot from (000.0-1-notnixos) to " in output
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue