Skip to content
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

feat(hwdb): install hwdb on demand when module is needed #2443

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions modules.d/95hwdb/module-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later

check() {
return 255
}

# called by dracut
install() {
local hwdb_bin

# systemd-hwdb ships the file in /etc, with /usr/lib as an alternative.
# The alternative location is preferred, as we can consider it being user
# configuration.
hwdb_bin="${udevdir}"/hwdb.bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${udevdir}/hwdb.bin is already unconditionally installed by 01systemd-udevd, so it can be ignored here.

Copy link
Contributor Author

@pvalena pvalena Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I was rather thinking on systemd-udevd depending on this module, which might handle hwdb in more complex way; also not install multiple ones unnecessarily. Please also note that the install is not optional (-o) intentionally; and this module is not enabled by default. Does that make sense?

There's also an additional benefit of this module working correctly without systemd-udevd :) in case that's ever needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also an additional benefit of this module working correctly without systemd-udevd :) in case that's ever needed.

This makes sense to me. This situation is very similar to udev rules - they are installed both by systemd-udevd and udev-rules .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also an additional benefit of this module working correctly without systemd-udevd :)

That's a benefit without any value. ATM, HWDB is configuration for systemd-udevd, just like .rules files. It could be used for other things, but it's not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also an additional benefit of this module working correctly without systemd-udevd :) in case that's ever needed.

This makes sense to me. This situation is very similar to udev rules - they are installed both by systemd-udevd and udev-rules .

Uff. Does udev-rules even work on modern systems? The list of .rules files seem to be rather short. (OTOH, it contains stuff that makes no sense in initrd, like 70-uaccess.rules or 71-seat.rules.)

Copy link
Collaborator

@LaszloGombos LaszloGombos Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uff. Does udev-rules even work on modern systems?

We have a Gentoo container (with openrc and musl) where most Dracut tests pass - https://github.com/dracutdevs/dracut/blob/master/test/container/Dockerfile-Gentoo .

If Fedora wishes, it simply can just not package Dracut modules that is not needed for a systemd based initramfs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(OTOH, it contains stuff that makes no sense in initrd, like 70-uaccess.rules or 71-seat.rules.)

FWIW - both udev-rules and systemd Drauct modules seem to include these rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say if it's not breaking anything, let's keep it (and this also verifies hwdb.bin is present / installed, as udevd module simply runs opt-install).


if [[ ! -r "${hwdb_bin}" ]]; then
hwdb_bin="${udevconfdir}"/hwdb.bin
fi

if [[ $hostonly ]]; then
inst_multiple -H "${hwdb_bin}"
else
inst_multiple "${hwdb_bin}"
fi
}
Loading