From: Daan De Meyer Date: Tue, 12 Mar 2024 19:41:47 +0000 (+0000) Subject: Use sandbox for cp --version X-Git-Tag: v22~12^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25a8d9beac974efaad276e78cabfd4407b6b5e4b;p=thirdparty%2Fmkosi.git Use sandbox for cp --version So that we detect the correct version. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 8458866ad..a1933866e 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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): diff --git a/mkosi/sandbox.py b/mkosi/sandbox.py index 62932e3e7..79c8e9485 100644 --- a/mkosi/sandbox.py +++ b/mkosi/sandbox.py @@ -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 [] diff --git a/mkosi/tree.py b/mkosi/tree.py index e805fbdd3..0673421a6 100644 --- a/mkosi/tree.py +++ b/mkosi/tree.py @@ -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]