]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use sandbox for cp --version
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 12 Mar 2024 19:41:47 +0000 (19:41 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 13 Mar 2024 10:11:29 +0000 (11:11 +0100)
So that we detect the correct version.

mkosi/__init__.py
mkosi/sandbox.py
mkosi/tree.py

index 8458866ad736ed54fe4c492ee0b4bf628c934e8d..a1933866ecfdc7e2ada632658847d8bd85f9435b 100644 (file)
@@ -3241,7 +3241,7 @@ def copy_repository_metadata(context: Context) -> None:
             with umask(~0o755):
                 dst.mkdir(parents=True, exist_ok=True)
 
-            def sandbox(*, options: Sequence[PathString]) -> list[PathString]:
+            def sandbox(*, options: Sequence[PathString] = ()) -> list[PathString]:
                 return context.sandbox(options=[*options, *exclude])
 
             with flock(src):
index 62932e3e77d455dd4513fe8d481141c4210c29dc..79c8e9485766c0f74209d65605898e305d44823a 100644 (file)
@@ -13,10 +13,10 @@ from mkosi.util import flatten, one_zero, startswith
 
 
 class SandboxProtocol(Protocol):
-    def __call__(self, *, options: Sequence[PathString]) -> list[PathString]: ...
+    def __call__(self, *, options: Sequence[PathString] = ()) -> list[PathString]: ...
 
 
-def nosandbox(*, options: Sequence[PathString]) -> list[PathString]:
+def nosandbox(*, options: Sequence[PathString] = ()) -> list[PathString]:
     return []
 
 
index e805fbdd3df9e1901d1254f384a6814715fd9fc2..0673421a6c98e896d903460ecb86b39644f96427 100644 (file)
@@ -26,8 +26,10 @@ def is_subvolume(path: Path, *, sandbox: SandboxProtocol = nosandbox) -> bool:
     return path.is_dir() and statfs(path, sandbox=sandbox) == "btrfs" and path.stat().st_ino == 256
 
 
-def cp_version() -> GenericVersion:
-    return GenericVersion(run(["cp", "--version"], stdout=subprocess.PIPE).stdout.splitlines()[0].split()[3])
+def cp_version(*, sandbox: SandboxProtocol = nosandbox) -> GenericVersion:
+    return GenericVersion(
+        run(["cp", "--version"], sandbox=sandbox(), stdout=subprocess.PIPE).stdout.splitlines()[0].split()[3]
+    )
 
 
 def make_tree(
@@ -100,7 +102,7 @@ def copy_tree(
         "--copy-contents",
         src, dst,
     ]
-    if cp_version() >= "9.5":
+    if cp_version(sandbox=sandbox) >= "9.5":
         copy += ["--keep-directory-symlink"]
 
     options: list[PathString] = ["--ro-bind", src, src, "--bind", dst.parent, dst.parent]