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
[merged] Introducing ostree-grub-generator #228
Conversation
One thing that's worth noting here as well is that Peter Jones wrote this: http://pkgs.fedoraproject.org/cgit/rpms/grub2.git/tree/0029-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch?id=dcaf8f68832f12983a03aa57275627c7c7167021 Which fits in a bit better with the original intention of the BLS...I forget why we're not using it in Fedora Atomic right now. It might be as prosaic as it not being enabled by default? That'd likely be easy to fix. Possibly a larger issue is the uncertain state of the BLS (https://www.redhat.com/archives/anaconda-devel-list/2014-July/msg00002.html etc). Anyways, this approach is also quite simple. GRUB2 is critical path for me so I'll need to take some time to test this. Doing so now. |
{ | ||
# Prepend "boot/" prefix when boot/ directory is on the same partition as usr/, | ||
# if boot/ directory is on a separate partition, set boot_prefix="" | ||
boot_prefix="/boot" |
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.
See #215 - I wonder if we could have OSTree pass this down via environment variable? Though that only works on-target. Perhaps anyone doing a cross system like OpenEmbedded could have that set the OSTREE_BOOT_PARTITION
environment variable there?
Having to set 1 extra envvar when building image not-on-target device sounds reasonable and maintainable to me. |
fb99e66
to
da5b15f
Compare
Can one of the admins verify this patch?
|
bot, test pull request |
I was not aware of this plugin. I can see how it could be handy on Desktop and if other operating systems / boot loaders actually followed the Boot Loader Specification. And as you already mentioned, state of BLS seems to be unclear. But if we compare ostree-grub-generator vs GRUB BLS plugin [1] the advantage for ostree-grub-generator is:
|
while read -r line | ||
do | ||
record=$(echo ${line} | cut -f 1 -d ' ') | ||
value=$(echo ${line} | cut -s -f2- -d ' ') |
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.
This is a clear enough script, but it's tempting to move the logic into C, basically what we're doing in the syslinux/u-boot ones. We don't have to do that now though, and shell script is convenient for customization.
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.
At some point though I do want to revisit #228 (comment) - I didn't quite understand you reply there. The GRUB2 builtin BLS loader wouldn't have any on-target dependencies either, but it would need some changes to be possibly more flexible/configurable?
What I meant here is that this logic could be implemented entirely in ostree. Instead of working on making a GRUB2 builtin BLS loader more configurable, there could be a C binary (configurable) in ostree project that does what normally would be the job of "GRUB2 builtin BLS loader".
Then we could reuse the same code path what is currently used by ostree-grub-generator. Where ostree instead of executing ostree-grub-generator shell script would execute the above mentioned C binary. The benefit would be that the code is better localized. Probably there are some benefits at developing this upstream (in grub2 repo) too.
Hopefully this clarifies it better.
Yeah. |
cat >> ${new_grub2_cfg} <<EOF | ||
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 | ||
default=boot | ||
timeout=10 |
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.
This is the sort of thing where we should probably have a config file at least for any general purpose use. It's basically what /etc/grub.d/00_header
is right?
I guess this is where things are a bit nicer with the state we have with syslinux where the ostree-syslinux code edits just the entries in there, otherwise admins can edit it by hand. But that's only really possible because the syslinux format is easy to parse, which is definitely not true of grub2 😦
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.
It's basically what /etc/grub.d/00_header is right
Yeah, looks like it. This definitely can be improved further by Atomic project or whoever else decides that they need it first :)
I guess this is where things are a bit nicer with the state we have with syslinux where the ostree-syslinux code edits just the entries in there, otherwise admins can edit it by hand.
I want to achieve similar funcionality in the u-boot backend by this patch:
5ee4977
Where admin can edit /uEnv.txt, deploy the edited version. Where during the deploy process OSTree prepends its env (loader/uEnv.txt) on top of the /uEnv.txt.
I am planing to revisit that change soon and add an auto tests that demonstrates the use case.
At a high level I'm inclined to take this patch with just some small cleanups - we don't need to rearchitect things to have a config file etc. initially...anyone who wants a general purpose bootloader can just use |
Cool, I will clean up the remaining parts tomorrow then :) |
e5378f2
to
7c308a9
Compare
@@ -282,10 +296,13 @@ EOF | |||
|
|||
case $bootmode in | |||
"syslinux") | |||
setup_os_boot_syslinux | |||
setup_os_boot_syslinux | |||
;; |
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.
Does OSTree repository has policy regarding spaces vs tabs? When I see tabs around lines that I am touching I feel like I have to convert everything to spaces :)
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.
C code is GNU style with no tabs, but we don't have a policy for shell yet. I think it's mostly just been whatever Emacs does by default which is 4 spaces?
I'd say no tabs, and try match what exists, and maybe we'll revisit consistent indentation for shell later?
Ok, if I am not missing anything, then this patch can be considered complete. Unless you find something more than needs to be fixed up. |
bot, retest this please |
@cgwalters-bot try |
ostree-grub-generator can be used to generate an easy customizable grub.cfg file. Compile time decision ostree-grub-generator vs grub2-mkconfig can be overwritten with the OSTREE_GRUB2_EXEC envvar - useful for auto tests and OS installers. Why this alternative approach: 1) The current approach is less flexible than using a custom 'ostree-grub-generator' script. Each system can adjust this script for its needs, instead of using the hardcoded values from ostree-bootloader-grub2.c. 2) Too much overhead on embedded to generate grub.cfg via /etc/grub.d/ configuration files. It is still possible to do so, even with this patch applied. No need to install grub2 package on a target device. 3) The grub2-mkconfig code path has other issues: https://bugzilla.gnome.org/show_bug.cgi?id=761180 Task: https://bugzilla.gnome.org/show_bug.cgi?id=762220 Closes: #228 Approved by: <try>
I think the PR tester has been failing since you based on a commit before we got it all working. Can you rebase again? But let's see what happens with a "try" merge. |
☀️ Test successful - travis |
Actually, the logs say Searching for "FAIL:" shows that only one test failed:
|
Right, I tested with "make check", then it succeeds. Probably need to install ostree-grub-generator in usr/libexec/installed-tests/ostree/ for it to pass. |
aa0582e
to
9abb020
Compare
The tests are passing here on my laptop (both In the meantime reviewing this patch more, I found it made a lot more sense to me if the configure option was If you agree can you cherry-pick gatispaeglis#1 into your PR branch? (Yep, I made a PR for your PR, it works 😄 ) In the big picture I am a bit sad that it's unlikely we can use this for Project Atomic yet, as I would really like to just ditch the grub2 binaries. But it'd need a config file and other bits. I'm also a bit uncertain about the long term maintenance of carrying this special case, and am wondering if we should redirect people to extlinux. Was there a reason you chose grub2 over extlinux? |
I fixed the grub2 test after the last comment from jlebon so everything should be fine now.
Patch seems fine to me, I can do the cherry-pick on monday.
Several reasons actually. I have been experimenting with Intel NUC board where grub2 (with UEFI firmware) is what Intel provides by default in http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel so I didn't even consider other boot loader. |
ostree-grub-generator can be used to customize the generated grub.cfg file. Compile time decision ostree-grub-generator vs grub2-mkconfig can be overwritten with the OSTREE_GRUB2_EXEC envvar - useful for auto tests and OS installers. Why this alternative approach: 1) The current approach is less flexible than using a custom 'ostree-grub-generator' script. Each system can adjust this script for its needs, instead of using the hardcoded values from ostree-bootloader-grub2.c. 2) Too much overhead on embedded to generate grub.cfg via /etc/grub.d/ configuration files. It is still possible to do so, even with this patch applied. No need to install grub2 package on a target device. 3) The grub2-mkconfig code path has other issues: https://bugzilla.gnome.org/show_bug.cgi?id=761180 Task: https://bugzilla.gnome.org/show_bug.cgi?id=762220
3b234ad
to
29c088e
Compare
Oh right, I think we talked about the UEFI issue. OK, let's go with this then. At some point though I do want to revisit #228 (comment) - I didn't quite understand you reply there. The GRUB2 builtin BLS loader wouldn't have any on-target dependencies either, but it would need some changes to be possibly more flexible/configurable? @cgwalters-bot r+ 92c088e |
🙀 |
ostree-grub-generator can be used to generate
an easy customizable grub.cfg file. Compile time
decision ostree-grub-generator vs grub2-mkconfig
can be overwritten with the OSTREE_GRUB2_EXEC
envvar - useful for auto tests and OS installers.
Why this alternative approach:
The current approach is less flexible than using a
custom 'ostree-grub-generator' script. Each system can
adjust this script for its needs, instead of using the
hardcoded values from ostree-bootloader-grub2.c.
Too much overhead on embedded to generate grub.cfg
via /etc/grub.d/ configuration files. It is still
possible to do so, even with this patch applied.
No need to install grub2 package on a target device.
The grub2-mkconfig code path has other issues:
https://bugzilla.gnome.org/show_bug.cgi?id=761180
Task: https://bugzilla.gnome.org/show_bug.cgi?id=762220