systemd-boot: Unlink loader.conf if it exists
Since systemd version 232 the install subcommand of bootctl opens the loader.conf with fopen() modes "wxe", where the "e" stands for exclusive, so the call will fail if the file exists. For installing the boot loader just once this is fine, but if we're using NIXOS_INSTALL_BOOTLOADER on a systemd where the bootloader is already present this will fail. Exactly this is done within the simpleUefiGummiboot installer test, where nixos-install is called twice and thus the bootloader is also installed twice, resulting in an error during the fopen call: Failed to open loader.conf for writing: File exists Removing the file prior to calling bootctl should fix this. I've tested this using the installer.simpleUefiGummiboot test and it now succeeds. Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @edolstra, @shlevy, @mic92 Fixes: #22925
This commit is contained in:
parent
4daccf208f
commit
dc31a1ea29
@ -118,6 +118,10 @@ def main():
|
||||
os.environ["NIXOS_INSTALL_BOOTLOADER"] = "1"
|
||||
|
||||
if os.getenv("NIXOS_INSTALL_BOOTLOADER") == "1":
|
||||
# bootctl uses fopen() with modes "wxe" and fails if the file exists.
|
||||
if os.path.exists("@efiSysMountPoint@/loader/loader.conf"):
|
||||
os.unlink("@efiSysMountPoint@/loader/loader.conf")
|
||||
|
||||
if "@canTouchEfiVariables@" == "1":
|
||||
subprocess.check_call(["@systemd@/bin/bootctl", "--path=@efiSysMountPoint@", "install"])
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user