dracutdevs / dracut

dracut the event driven initramfs infrastructure
https://github.com/dracutdevs/dracut/wiki
GNU General Public License v2.0
604 stars 400 forks source link

fix(dracut.sh): correct path to UEFI stub on split-usr systems #2365

Closed floppym closed 1 year ago

floppym commented 1 year ago

systemd always installs the UEFI stub in ${prefix}/lib/systemd/boot/efi.

On split-usr systems, systemdutildir is ${rootprefix}/lib/systemd, which makes dracut look in the wrong place.

Instead, grab 'prefix' from systemd.pc and store it in 'systemd_prefix'.

Bug: https://bugs.gentoo.org/765208

floppym commented 1 year ago

The failing integration tests seem rather flaky. I don't think it's related to this PR.

LaszloGombos commented 1 year ago

The failing integration tests seem rather flaky. I don't think it's related to this PR.

Yes, indeed - those failures are out of scope for this PR (see https://github.com/dracutdevs/dracut/issues/2353#issuecomment-1565225190)

floppym commented 1 year ago

As the Gentoo maintainer of dracut, I assure you the patch is necessary.

The EFI stub is not installed in systemdutildir. Many other systemd components are installed there, however.

floppym commented 1 year ago

If systemdutildir contains the /usr prefix, all the systemd global variables that use systemdutildir would be incorrect, not just the EFI stub location.

My patch does not add /usr to systemdutildir, so I don't understand this comment.

aafeijoo-suse commented 1 year ago

If systemdutildir contains the /usr prefix, all the systemd global variables that use systemdutildir would be incorrect, not just the EFI stub location.

My patch does not add /usr to systemdutildir, so I don't understand this comment.

Quoting https://github.com/dracutdevs/dracut/pull/2365#pullrequestreview-1466934212 :

testing in Gentoo the current upstream code (before applying this patch)

I was trying to say that with the current code systemdutildir is equal to /lib/systemd, at least with my Gentoo test vm. In this case, if your patch does not add /usr to systemdutildir, isn't it doing the same thing?

-            uefi_stub="$dracutsysrootdir${systemdutildir}/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"
+            uefi_stub="$dracutsysrootdir${systemd_prefix}/lib/systemd/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"
floppym commented 1 year ago

Yes, systemdutildir is supposed to be equal to /lib/systemd.

The EFI stub is NOT installed in systemdutildir, however. It is installed in /usr/lib/systemd.

floppym commented 1 year ago

To elaborate: systemd installs many programs in systemdutildir (/lib/systemd): systemd-udevd, systemd-networkd, etc

The EFI stub is an exception: it is always installed in /usr/lib/systemd (assuming prefix is /usr), regardless of the value of systemdutildir.

aafeijoo-suse commented 1 year ago

Ok, sorry, after checking systemd's meson.build now I get this prefixdir vs rootprefixdir issue. Unfortunately, bootlibdir is not exposed in systemd.pc, because I'd prefer a fix similar to what was done for tmpfilesdir:

set_global_var "systemd" "bootlibdir" "/lib/systemd/boot/efi" "/usr/lib/systemd/boot/efi"

Anyway, I'd suggest a couple of changes:

floppym commented 1 year ago

Ok, sorry, after checking systemd's meson.build now I get this prefixdir vs rootprefixdir issue. Unfortunately, bootlibdir is not exposed in systemd.pc, because I'd prefer a fix similar to what was done for tmpfilesdir:

Agreed. Unfortunately, adding bootlibdir to systemd.pc just makes the required logic more complex at this point since we would still need a fallback for old systemd versions.

floppym commented 1 year ago

I force-pushed a new commit with the suggested changes. However, this github PR doesn't seem to be updating for some reason.