Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 794646 - virtual/dist-kernel: support installkernel-systemd-boot properly
Summary: virtual/dist-kernel: support installkernel-systemd-boot properly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Distribution Kernel Project
URL:
Whiteboard:
Keywords:
: 795033 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-06-06 22:47 UTC by Georgy Yakovlev
Modified: 2021-06-26 22:02 UTC (History)
3 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 Georgy Yakovlev archtester gentoo-dev 2021-06-06 22:47:29 UTC
installkernel-systemd-boot will not install kernel file to /boot, if /boot/${MACHINE_ID} directory is not present..

this is handled by /usr/lib/kernel/install.d/00-entry-directory.install

and it has a condition to just exit if the dir does not exist.


so I think whenever we call installkernel, we should check if installkernel-systemd-boot is used and create machineid specific boot directory before calling install.
Comment 1 Georgy Yakovlev archtester gentoo-dev 2021-06-06 22:50:05 UTC
also /boot/loader/entries is not created if /boot/${MACHINE_ID} is not present as result of ^
Comment 2 Georgy Yakovlev archtester gentoo-dev 2021-06-06 22:51:44 UTC
I think if /etc/machine-id is not present it may be even appropriate to error out, because only dracut will install initrd to classical /boot location, and kernel will remain in /usr/src/<ver>
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-06-08 11:37:39 UTC
installkernel implementations are really supposed to be stand-alone, so I think it'd be best to either make installkernel-systemd-boot a wrapper that takes care of this or handle this at ebuild level.

I think creating /boot/${MACHINE_ID} should be fine, given that the user probably choose installkernel-systemd-boot explicitly.  Not sure about generating machine-id though.
Comment 4 Georgy Yakovlev archtester gentoo-dev 2021-06-10 05:37:35 UTC
*** Bug 795033 has been marked as a duplicate of this bug. ***
Comment 5 Georgy Yakovlev archtester gentoo-dev 2021-06-10 05:55:04 UTC
reading https://www.freedesktop.org/software/systemd/man/machine-id.html

there are couple edge cases to handle,

in case installation is done in a chroot, 
 1) file exists and set to "uninitialized" - idk how to handle that, machine-id is unknown.
 2) file does not exist, or empty.
    should we defer to systemd to actually generate it? or we do it?

    systemd-machine-id-setup has --root option and can actually generate one, systemd does not have to be running to run that binary.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-06-10 06:57:45 UTC
Let's maybe start with the generic idea that any env that doesn't work results in fatal error.  Then consider what we can fix automatically.
Comment 7 Georgy Yakovlev archtester gentoo-dev 2021-06-11 04:00:36 UTC
here's how kernel-install solves it:

# Reuse directory created without a machine ID present if it exists.
if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then
    MACHINE_ID="Default"
elif [[ -f /etc/machine-id ]]; then
    read MACHINE_ID < /etc/machine-id
else
    MACHINE_ID="Default"
fi


pretty simple.
so we should create 'Default' if hostid is unknown and it will be picked up by bootloader, and not leave system unbootable.
Comment 8 Georgy Yakovlev archtester gentoo-dev 2021-06-11 04:42:51 UTC
PR here

https://github.com/gentoo/gentoo/pull/21195
Comment 9 Larry the Git Cow gentoo-dev 2021-06-26 22:02:44 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=41da652a218b9413cb24174f03c812d04b138c9e

commit 41da652a218b9413cb24174f03c812d04b138c9e
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2021-06-11 04:35:06 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2021-06-26 22:02:30 +0000

    sys-kernel/installkernel-systemd-boot: bump, create machine-id dir
    
    add a plugin to create proper directory for kernels.
    without it /usr/lib/kernel/install.d/00-entry-directory.install
    will silently exit and kernel will not be installed at all.
    
    Closes: https://github.com/gentoo/gentoo/pull/21195
    Closes: https://bugs.gentoo.org/794646
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 .../files/00-00machineid-directory.install         | 28 +++++++++++++++++++++
 .../installkernel-systemd-boot-1.ebuild            | 29 ++++++++++++++++++++++
 2 files changed, 57 insertions(+)