]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Include linked firmware files 3312/head
authorMartin Hundebøll <martin@geanix.com>
Fri, 3 Jan 2025 11:00:31 +0000 (12:00 +0100)
committerMartin Hundebøll <martin@geanix.com>
Mon, 6 Jan 2025 09:24:22 +0000 (10:24 +0100)
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.

mkosi/kmod.py
tests/test_initrd.py

index 91368f5f06b226eb028e29f7f842ee7549397466..92caa4bf1fd06d98869f0971fcdcd996703f8a8a 100644 (file)
@@ -10,6 +10,7 @@ from pathlib import Path
 
 from mkosi.log import complete_step, log_step
 from mkosi.run import chroot_cmd, run
+from mkosi.sandbox import chase
 from mkosi.util import chdir, parents_below
 
 
@@ -180,6 +181,15 @@ def gen_required_kernel_modules(
             mods = set(modulesd.rglob("*.ko*"))
         firmware = set()
 
+    # Some firmware dependencies are symbolic links, so the targets for those must be included in the list
+    # of required firmware files too. Intermediate symlinks are not included, and so links pointing to links
+    # results in dangling symlinks in the final image.
+    for fw in firmware.copy():
+        if (root / fw).is_symlink():
+            target = Path(chase(os.fspath(root), os.fspath(fw)))
+            if target.exists():
+                firmware.add(target.relative_to(root))
+
     yield from sorted(
         itertools.chain(
             {
index 4e6a513d3d0608b75185a0d716887ac42b5db33c..ed449d20b0b1fbf9a84b52c2c712179bfb2a09be 100644 (file)
@@ -225,9 +225,9 @@ def test_initrd_size(config: ImageConfig) -> None:
         maxsize = 1024**2 * {
             Distribution.fedora: 63,
             Distribution.debian: 62,
-            Distribution.ubuntu: 56,
+            Distribution.ubuntu: 57,
             Distribution.arch: 83,
             Distribution.opensuse: 64,
-        }.get(config.distribution, 57)
+        }.get(config.distribution, 58)
 
         assert (Path(image.output_dir) / "image.initrd").stat().st_size <= maxsize