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

Modules and firmware includes #3312

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hundeboll
Copy link
Contributor

In order to include out-of-tree modules (and their required firmware) installed in an updates subfolder, a special case is added when a file is found below that folder.

Furthermore, a firmware file required by a module might be a symbolic link to the real firmware file. Add handling of this case too.

mkosi/kmod.py Outdated Show resolved Hide resolved
mkosi/kmod.py Outdated Show resolved Hide resolved
mkosi/kmod.py Outdated Show resolved Hide resolved
@hundeboll hundeboll force-pushed the modules-and-firmware-includes branch 2 times, most recently from 5e6af61 to 0177fd9 Compare January 3, 2025 09:43
Copy link
Contributor

@DaanDeMeyer DaanDeMeyer left a comment

Choose a reason for hiding this comment

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

This seems unnecessarily complicated, why not loop over required, calls resolve() on each entry and add all resolved paths to required as well?

The kernel module include/exclude logic matches against paths below any
folder in /usr/lib/modules/$(uname -r)/*/, and not just the `kernel`
folder. Mention other common folder such as `extra` and `updates` in
the documentation too, to avoid confused users.
@hundeboll hundeboll force-pushed the modules-and-firmware-includes branch from 0177fd9 to aadac1d Compare January 3, 2025 11:10
@hundeboll
Copy link
Contributor Author

This seems unnecessarily complicated, why not loop over required, calls resolve() on each entry and add all resolved paths to required as well?

Okay, spent some time to get to know gen_required_kernel_modules(). Better?

@hundeboll
Copy link
Contributor Author

Also removed the unconditional include of modules / firmwares below an updates folder, as the include / exlcude logic already handles those two. I've updated the documentation instead.

mkosi/kmod.py Outdated Show resolved Hide resolved
mkosi/kmod.py Outdated Show resolved Hide resolved
mkosi/kmod.py Outdated Show resolved Hide resolved
mkosi/kmod.py Outdated Show resolved Hide resolved
@hundeboll hundeboll force-pushed the modules-and-firmware-includes branch from aadac1d to 623881c Compare January 3, 2025 12:24
mkosi/kmod.py Outdated Show resolved Hide resolved
@hundeboll hundeboll force-pushed the modules-and-firmware-includes branch from 623881c to 6cc4454 Compare January 3, 2025 12:55
mkosi/kmod.py Outdated Show resolved Hide resolved
Some modules reference a firmware file that is just a link to a "real"
file. Make sure those files are also included when needed by resolving
those referenced symlinks and including their target files in the set of
required firmware files.
@hundeboll hundeboll force-pushed the modules-and-firmware-includes branch from 6cc4454 to 21b9a1a Compare January 3, 2025 13:01
Comment on lines +1019 to +1020
relative to the `/usr/lib/modules/<kver>/kernel` directory (note that they match against modules in the
`updates` and `extra` sibling directories too). mkosi checks for a match anywhere in the module path (e.g.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be clearer:

Suggested change
relative to the `/usr/lib/modules/<kver>/kernel` directory (note that they match against modules in the
`updates` and `extra` sibling directories too). mkosi checks for a match anywhere in the module path (e.g.
relative to the `/usr/lib/modules/<kver>` directory. mkosi checks for a match anywhere in the module path (e.g.

mentioning the updates and extra directories explicitly only obscures that, we look relative to that.

# results in dangling symlinks in the final image.
for fw in firmware.copy():
if (root / fw).is_symlink():
target = Path(chase(root, fw))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
target = Path(chase(root, fw))
target = Path(chase(os.fspath(root), os.fspath(fw)))

is needed here to appease mypy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants