]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure nspawn doesn't try to start a container in nspawn_knows_arg() 1176/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 8 Sep 2022 08:24:04 +0000 (10:24 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 8 Sep 2022 08:30:22 +0000 (10:30 +0200)
mkosi/backend.py

index b1debc2d28a205c63d8d3649d2d43ff3c9c5b4fe..d5c31b347cefa3f6292e89b840bd0e4584e2ba26 100644 (file)
@@ -654,8 +654,12 @@ def var_tmp(root: Path) -> Path:
 
 
 def nspawn_knows_arg(arg: str) -> bool:
-    return "unrecognized option" not in run([nspawn_executable(), arg], stdout=subprocess.DEVNULL,
-                                            stderr=subprocess.PIPE, check=False, text=True).stderr
+    # Specify some extra incompatible options so nspawn doesn't try to boot a container in the current
+    # directory if it has a compatible layout.
+    return "unrecognized option" not in run([nspawn_executable(), arg,
+                                            "--directory", "/dev/null", "--image", "/dev/null"],
+                                            stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False,
+                                            text=True).stderr
 
 
 def format_rlimit(rlimit: int) -> str: