Biosias / uefi-mkconfig

grub-mkconfig inspired script for automatically managing uefi entries for booting linux kernel directly without bootloader
Apache License 2.0
7 stars 3 forks source link

Cross-distro support: avoid hardcoding "gentoo" #1

Closed AndrewAmmerlaan closed 4 months ago

AndrewAmmerlaan commented 5 months ago

We currently hardcode "gentoo" as a valid prefix for the kernel. If we read the value of ID from /etc/os-release or /usr/lib/os-release and use this instead we can avoid hardcoding the distribution name and therefore achieve support for arbitrary distributions.

Something else to consider is reading the contents of /etc/kernel/entry-token or /usr/lib/kernel/entry-token (if they exist) and uses these as valid prefix'es as well. The contents of these files are used by systemd's kernel-install to prefix UKI entries.

Biosias commented 5 months ago

Good idea, will investigate and integrate this

Biosias commented 5 months ago

I've implemented reading os-release for kernel prefix here https://github.com/Biosias/uefi-mkconfig/commit/385afb44f1066e18d3948286e9a5099da3542f30 .

If you are able to, could you please send me an example of how insides of /etc/kernel/entry-token looks like ? I have never seen it nor have I been able to find example online so far.

AndrewAmmerlaan commented 5 months ago

If you are able to, could you please send me an example of how insides of /etc/kernel/entry-token looks like ? I have never seen it nor have I been able to find example online so far.

It contains simple plain text, similar to /etc/kernel/cmdline. Here's mine as an example:

andrew@andrew-gentoo-laptop ~ % cat /etc/kernel/entry-token
linux
Biosias commented 4 months ago

Nice, thank you very much!

I've added sourcing prefixes from entry-token files in https://github.com/Biosias/uefi-mkconfig/commit/5e27582d464ce2464a7b60afc749e6985919768c

AndrewAmmerlaan commented 4 months ago

Great, Thanks! I'll close this issue then.

By the way, could you maybe do a quick double check of the logic we use to set the kernel command line for the boot entry? There was a user on the forum that seemed to be having difficulty setting the cmdline, but this may also just be a case of the firmware being weird: https://forums.gentoo.org/viewtopic-t-1168382-highlight-installkernel.html