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):
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 []
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(
"--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]