Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 687486 - sys-kernel/genkernel's /etc/genkernel.conf should really mention the possibility of putting "grub2" in the BOOTLOADER option
Summary: sys-kernel/genkernel's /etc/genkernel.conf should really mention the possibil...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2019-06-05 22:55 UTC by Greg Turner
Modified: 2019-07-15 10:37 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Turner 2019-06-05 22:55:46 UTC
Genkernel unconditionally assumes the place to put grub configurations is called "grub.conf".  That is only true if the grub in question is sys-boot/grub:1.  If we are talking about sys-boot/grub:2, the correct filename is "grub.cfg".

It probably W4U because you have a symlink /boot/grub/grub.conf -> /boot/grub/grub.cfg.

However, if the user has (U)EFI and followed the handbook (and the best practice (standard(?)) for creating the EFI system partitions), their /boot is a fat32 partition, which does not support symlinks.

Hence, again following the handbook, they end up with both files, /boot/grub/grub.c{onf,fg}, likely with different contents, one ancient and crusty from back when they followed the handbook, and one regenerated automatically by genkernel each time a kernel is built, but grub always uses the ancient and crusty /boot/grub/grub.cfg.  Eventually this will lead to something unpleasant happening.

Something like:

  has_version sys-boot/grub:2 && \
    { sed -e 's/grub\.conf/grub.cfg/g' -i gen_bootloader.sh || die ; }

in src_prepare, while not a full solution*, might be better than nothing.

--
* All sorts of scenarios are possible, of course, which this wouldn't help with.  But to give a concrete example: user migrates from grub:1 to grub:2, only to discover that, now, their genkernel is acting wierd, until they happen to re-emerge it.  Point is, this behavior is less dumb for more people, even if it's still super dumb.  Betcha genkernel-next already has this fixed, in which case, borrowing their solution would presumedly be another option to fix this in a less gross way.
Comment 1 Brian Evans (RETIRED) gentoo-dev 2019-06-05 23:02:04 UTC
genkernel already does use grub.cfg when you set BOOTLOADER=grub2
Comment 2 Greg Turner 2019-06-05 23:32:50 UTC
Huh, it seems you are right, i.e.:

./usr/share/genkernel/gen_bootloader.sh:34:set_bootloader_grub2() {
./usr/share/genkernel/gen_bootloader.sh-35-     local GRUB_CONF
./usr/share/genkernel/gen_bootloader.sh-36-     for candidate in \
./usr/share/genkernel/gen_bootloader.sh-37-                     "${BOOTDIR}/grub/grub.cfg" \
./usr/share/genkernel/gen_bootloader.sh:38:                     "${BOOTDIR}/grub2/grub.cfg" \
./usr/share/genkernel/gen_bootloader.sh-39-                     ; do
./usr/share/genkernel/gen_bootloader.sh-40-             if [[ -e "${candidate}" ]]; then
./usr/share/genkernel/gen_bootloader.sh-41-                     GRUB_CONF=${candidate}

In that case the default /etc/genkernel.conf should really mention this.  Right now it just says:

  # Add new kernel to grub?
  #BOOTLOADER="grub"

And nothing else really seems to document this (it's sort-of casually mentioned in the Genkernel wiki page where they just changed the example to read:

  # Add new kernel to grub2?
  BOOTLOADER="grub2"

without explicitly mentioning the grub{,2} thing.  But nobody's going to notice that subtle clue--at least, I sure didn't.)