]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Chroot for depmod and modinfo 2699/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 10 May 2024 10:55:23 +0000 (12:55 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 10 May 2024 11:33:10 +0000 (13:33 +0200)
modinfo cannot always work with output from newer or different depmod.

Specifically, this fixes the case where modinfo sch_fq_codel fails with
"module not found" on CentOS Stream 9 images built from Fedora 40. When
depmod from Fedora 40 is used, modinfo in the image fails with "module
not found". When depmod from inside the image is used, modinfo succeeds
as expected.

We'd rather not do this but in this case there's no other option.

mkosi/__init__.py
mkosi/kmod.py
mkosi/sandbox.py

index 32fcf2321d71a1ef5411d57ee5448d4d771d026d..724158d927ddc142b3a388e438a99a56e793c08f 100644 (file)
@@ -2890,8 +2890,14 @@ def run_depmod(context: Context, *, cache: bool = False) -> None:
             )
 
         with complete_step(f"Running depmod for {kver}"):
-            run(["depmod", "--all", "--basedir", "/buildroot", kver],
-                sandbox=context.sandbox(binary="depmod", mounts=[Mount(context.root, "/buildroot")]))
+            run(
+                ["depmod", "--all", kver],
+                sandbox=context.sandbox(
+                    binary=None,
+                    mounts=[Mount(context.root, "/buildroot")],
+                    extra=chroot_cmd(),
+                )
+            )
 
 
 def run_sysusers(context: Context) -> None:
index dae94e0c316c5f8b5e5cc2c4f4ef7489ffc36d7c..fa623367ebe22a90b5e2f46c597b88337c8b96a5 100644 (file)
@@ -10,7 +10,7 @@ from pathlib import Path
 
 from mkosi.log import complete_step, log_step
 from mkosi.run import run
-from mkosi.sandbox import Mount, SandboxProtocol, nosandbox
+from mkosi.sandbox import Mount, SandboxProtocol, chroot_cmd, nosandbox
 from mkosi.util import parents_below
 
 
@@ -94,9 +94,9 @@ def resolve_module_dependencies(
     for i in range(0, len(nametofile.keys()), 8500):
         chunk = list(nametofile.keys())[i:i+8500]
         info += run(
-            ["modinfo", "--basedir", "/buildroot", "--set-version", kver, "--null", *chunk],
+            ["modinfo", "--set-version", kver, "--null", *chunk],
             stdout=subprocess.PIPE,
-            sandbox=sandbox(binary="modinfo", mounts=[Mount(root, "/buildroot", ro=True)]),
+            sandbox=sandbox(binary="modinfo", mounts=[Mount(root, "/buildroot", ro=True)], extra=chroot_cmd()),
         ).stdout.strip()
 
     log_step("Calculating required kernel modules and firmware")
index b8deabd156a257209cb9ae5d47afa0682c64015d..8b7241c223a52b78c8a0664030c911a373e267fa 100644 (file)
@@ -275,7 +275,7 @@ def apivfs_cmd() -> list[PathString]:
 
 
 def chroot_cmd(*, resolve: bool = False, work: bool = False) -> list[PathString]:
-    workdir = '/buildroot/work' if work else ''
+    workdir = "/buildroot/work" if work else ""
 
     return apivfs_cmd() + [
         "sh", "-c",