summaryrefslogtreecommitdiffstats
path: root/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2021-11-06 12:24:32 +0100
committerGitHub <noreply@github.com>2021-11-06 12:24:32 +0100
commit6ae271565dd609b05f85f3830d2257808b0f916e (patch)
treea0d769cc0886fa7b99f434b188ab4c88e5689608 /nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
parent6c187500e2b3345daffa876b6b4d5a0b4d754f71 (diff)
parent3efc2de6d1c001b55daafa60f605255e31d676ea (diff)
Merge pull request #140046 from jrobsonchase/systemd-boot/fix-regexp
nixos/systemd-boot: Fix installed version regexp
Diffstat (limited to 'nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py')
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
index c38bef9d6d4b..e9697b5f0e64 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
@@ -244,19 +244,27 @@ def main() -> None:
subprocess.check_call(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@"] + flags + ["install"])
else:
# 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)
# 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)
+
+ needs_install = False
+
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:
- sdboot_version = m.group(2)
- if systemd_version > sdboot_version:
+ sdboot_version = f'({m.group(2)})'
+ if systemd_version != sdboot_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@/loader/entries")