nixos/systemd-boot-builder: use pathlib.Path where possible#434767
nixos/systemd-boot-builder: use pathlib.Path where possible#434767JulienMalka merged 1 commit intoNixOS:masterfrom
Conversation
|
@ofborg test installer.simpleUefiSystemdBoot systemd-boot.extraFiles systemd-boot.specialisations |
|
Thank you! Running the tests locally |
|
I'd also appreciate some input on whether we should backport this; it would be nice to have the bug fixed on stable as well, but it is a fairly big refactor that comes with some risk and I'm not sure the tests cover all the ground we should be covering.
|
|
This version of this change doesn't actually fix the bug it's supposed to fix, because it's now comparing relative paths to absolute ones |
`switch-to-configuration boot` was taking suspiciously long on a machine of mine where the boot partition is on a slow SD card. Some tracing led me to discover that it was in fact deleting all the kernels and initrds every time, only to rewrite them. This turned out to be because of the naive (non-path-normalising) string concatenation used to construct paths in `known_paths`, so all the files were recognised as obsolete and deleted: known_paths=['/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/xri8qzfvzclf89x7nfwgq248miw7jbp0-initrd-linux-6.15.7-initrd.efi', '/EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi', '/EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi', '/EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi', '/EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi', '/EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi', '/EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi', '/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi', '/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi', '/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi'] path='/boot//EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi' path='/boot//EFI/nixos/xri8qzfvzclf89x7nfwgq248miw7jbp0-initrd-linux-6.15.7-initrd.efi' path='/boot//EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi' path='/boot//EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi' path='/boot//EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi' This can be avoided by using pathlib.Path, which normalises paths and generally provides a more consistent and convenient API. I therefore went ahead and replaced all use of `str` for path handling with `Path` in the builder. This may fix some other, similar bugs, as well, but I haven't checked in detail.
d90a7b0 to
f2ca990
Compare
|
I would not take the risk to backport this, I have seen changes to the systemd-boot backend failing in ways that we have difficulty to predict even with careful review, so I'd leave this in unstable. |
|
Otherwise code changes look good and all tests are passing. |
switch-to-configuration bootwas taking suspiciously long on a machine of mine where the boot partition is on a slow SD card. Some tracing led me to discover that it was in fact deleting all the kernels and initrds every time, only to rewrite them.This turned out to be because of the naive (non-path-normalising) string concatenation used to construct paths in
known_paths, so all the files were recognised as obsolete and deleted:This can be avoided by using pathlib.Path, which normalises paths and generally provides a more consistent and convenient API. I therefore went ahead and replaced all use of
strfor path handling withPathin the builder. This may fix some other, similar bugs, as well, but I haven't checked in detail.Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.
cc maintainer @JulienMalka