nixos/systemd-boot: Fix installed version regexp#140046
nixos/systemd-boot: Fix installed version regexp#140046flokli merged 5 commits intoNixOS:stagingfrom
Conversation
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
aa30ae6 to
b8ad1c3
Compare
|
Changed the I'm still on the fence about capturing vs not capturing the extra suffix like in the arch case. Could be swayed either way. I'm also not sure that this check is actually correct. Should it be "always upgrade and never downgrade" or "make it match the version the module expects?" If the later, an equivalence check would be better than the string order. |
There was a problem hiding this comment.
That doesn't seem right. Later in this code the result of this check is used for string comparison. For instance, if a current version of systemd is 249.9, and we are going to install 249.10 then the comparison will fail.
>>> "249.10" > "249.9"
False(to be fair, the code below was wrong previously, however it likely wouldn't cause issues until release of systemd 1000)
|
Yeah, that's true. We'd need to parse the version as either a float if we assume it'll only ever contain one
That assumes that it ever actually got to that check, which it wouldn't 😛 Is there any reason we shouldn't just capture the entire version string and ensure that it always completely matches the version from nixpkgs? It might even be prudent to add a hash to the end of our version to make sure that it's actually the nixos binary and not just one that shares the same version. |
|
Just to add a bit of context here since I originally wrote this code: I did incorrectly assume the version string would always just be a series of digits, however, if it was originally installed by NixOS then it would be. From a closer look at the code ( static const char _used_ _section_(".sdmagic") magic[] = "#### LoaderInfo: systemd-boot " GIT_VERSION " ####";
Another thing is that Since |
That sounds like the right approach to me. At worst, the bootctl version check will get it wrong and install an older version from nixpkgs, which is arguably more correct anyway. Edit: Hmm, after playing with it, I might understand the original rationale. The version check in |
|
Looks like this commit would solve that issue, but I don't believe it's in the current systemd used in NixOS yet: |
56bd2d7 to
cacb6fd
Compare
|
This is interesting, this change has bigger ramifications:
I think this would actually fix a case of NixOS installs failing on systems like... say the raspberry pi4, with u-boot ->efi-> It seems like I really don't get why
Seems like it would've allowed more appropriate, granular behavior. |
Instead of comparing if the new version is greater, I think it would then be sufficient to just check if the version strings are different: If the new version is lower, |
This is exactly what I suggested here, though I was unaware that |
74bfb31 to
5e2ea28
Compare
|
@SuperSandro2000 Is there anything left blocking this from being merged? |
me not knowing anything about systemd-boot. |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/could-not-find-any-previously-installed-systemd-boot/15627/3 |
|
The change works 👍. Working systemd-boot post ~248 exposes some users to systemd/systemd#19191 (see #143847). The? documented way to rollback the bootloader is also broken #144007. |
Should we patch our systemd with systemd/systemd@e98d271 before merging this? |
|
cc @flokli (re patching systemd) |
I replied on the issue for that (#143847 (comment)). Let's do the discussion about patching or not there. |
5e2ea28 to
51725b4
Compare
This should fail since the regexp in systemd-boot-builder.py won't match the '.' in the version string.
The regexp was only matching numbers and not the '.', so everyone using systemd-boot would always see `could not find any previously installed systemd-boot` on a `nixos-rebuild`.
bootctl does it as a part of its update process anyway, so we're just duplicating code.
51725b4 to
3efc2de
Compare
Done! |
|
Thanks! |
|
Those should now both end in the staging-next cycle after #144730. |
|
WHY IS THIS PARSED ANYWAY I’m sorry but why the heck are we parsing display output of bootctl? Is there no machine-readable output format? |
Motivation for this change
The regexp was only matching numbers and not the '.', so everyone using
systemd-boot would always see
could not find any previously installed systemd-booton anixos-rebuild.Things done
- [ ] x86_64-darwin- [ ] aarch64-darwin- [ ] For non-Linux: Issandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"<- Not sure if this is relevant?- [ ] Tested execution of all binary files (usually in./result/bin/)- [ ] (Package updates) Added a release notes entry if the change is major or breaking- [ ] (Module updates) Added a release notes entry if the change is significant- [ ] (Module addition) Added a release notes entry if adding a new NixOS module