-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/systemd-boot: fix systemd-boot-builder dowgrade to fail #172849
nixos/systemd-boot: fix systemd-boot-builder dowgrade to fail #172849
Conversation
bd65afe
to
e7ba0c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
Could you please have a look, @dasJ ? |
e7ba0c6
to
eee2e62
Compare
See also systemd/systemd#23450 |
Ping @jrobsonchase |
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
eee2e62
to
50e166e
Compare
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
50e166e
to
b541dd9
Compare
I improved the commit with what @mweinelt suggestend and additionally renamed the variables to have |
b541dd9
to
a6f293e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel comfortable reviewing that Python code.
If others think it's good, I have no objections to the change in general.
I added the backport label for 22.05 so we can get it on the release branch as well since we have already branched off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will work.
One more nit, regarding the regex parsing. It didn't originate in this pull request, but since you're touching it we might as well.
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
Since, 4ddc788 systemd-boot-builder is broken in two ways: * if no systemd-boot is currently installed *and* the NIXOS_INSTALL_BOOTLOADER env variable is not set, it will try to run "bootctl update", which will fail * if the currently installed systemd-boot version is newer than the version we're about to install, it will also try to run "bootctl update", which will fail This patch changes the behaviour, * for the first case to still fail, but not even bother to try running "bootctl update" and instead erroring out with an exception * for the second case to leave the newer version in place, restoring the pre - 4ddc788 behaviour To do the proper version check a new "should_update" helper function was introduced, mimicing the compare_product C function from bootctl. If the following systemd issue gets resolved, we would have a nice way to get rid of this function: > systemd/systemd#23450 This change allows to again switch to a different NixOS configuration which contains an older systemd-boot. Co-authored-by: Martin Weinelt <[email protected]>
67a6d16
to
a30de3b
Compare
@mweinelt I wanted to add that I just tested this again and it still works. Thanks for merging! |
Successfully created backport PR #175115 for |
Shouldn't this and #175611 both get backported to NixOS 21.11 as well? I thought we had an additional month of support for 21.11. I was unable to rollback from 22.05 back to 21.11, since the 21.11 branch doesn't include these changes. (This is potentially a good example of why tying the bootloader entry generation to the NixOS generation is problematic, and that whatever program generates bootloader entries from NixOS bootspec definitions should be independently upgradable.) CC @grahamc |
I'm a bit late to the party, but I just wanted to point out that the
message is a bit poorly worded, IMHO. Maybe, I am just paranoid, but to me this message reads like |
Since, 4ddc788 systemd-boot-builder
is broken in two ways:
env variable is not set, it will try to run "bootctl update", which will fail
we're about to install, it will also try to run "bootctl update", which will fail
This patch changes the behaviour,
"bootctl update" and instead throwing erroring out with an exception
the pre - 4ddc788 behaviour
To do the proper version check a new "should_update" helper function was introduced,
mimicing the compare_product C function from bootctl.
This change allows to again switch to a different NixOS configuration which contains
an older systemd-boot.