if path.is_dir():
bases += [path]
elif path.suffix == ".tar":
- extract_tar(path, d, tools=context.config.tools(), sandbox=context.sandbox)
+ extract_tar(path, d, sandbox=context.sandbox)
bases += [d]
elif path.suffix == ".raw":
run(["systemd-dissect", "-M", path, d])
if src.is_dir() or (src.is_file() and target):
copy()
elif src.suffix == ".tar":
- extract_tar(src, t, tools=config.tools(), sandbox=config.sandbox)
+ extract_tar(src, t, sandbox=config.sandbox)
elif src.suffix == ".raw":
run(
["systemd-dissect", "--copy-from", src, "/", t],
for p in intel.iterdir():
f.write(p.read_bytes())
- make_cpio(root, microcode, tools=context.config.tools(), sandbox=context.sandbox)
+ make_cpio(root, microcode, sandbox=context.sandbox)
return microcode
host=context.config.kernel_modules_initrd_include_host,
sandbox=context.sandbox,
),
- tools=context.config.tools(),
sandbox=context.sandbox,
)
def make_uki(context: Context, stub: Path, kver: str, kimg: Path, microcode: Optional[Path], output: Path) -> None:
- make_cpio(context.root, context.workspace / "initrd", tools=context.config.tools(), sandbox=context.sandbox)
+ make_cpio(context.root, context.workspace / "initrd", sandbox=context.sandbox)
maybe_compress(context, context.config.compress_output, context.workspace / "initrd", context.workspace / "initrd")
initrds = [microcode] if microcode else []
copy_initrd(context)
if context.config.output_format == OutputFormat.tar:
- make_tar(
- context.root, context.staging / context.config.output_with_format,
- tools=context.config.tools(),
- sandbox=context.sandbox,
- )
+ make_tar(context.root, context.staging / context.config.output_with_format, sandbox=context.sandbox)
elif context.config.output_format == OutputFormat.oci:
- make_tar(
- context.root, context.staging / "rootfs.layer",
- tools=context.config.tools(),
- sandbox=context.sandbox,
- )
+ make_tar(context.root, context.staging / "rootfs.layer", sandbox=context.sandbox)
make_oci(
context,
context.staging / "rootfs.layer",
context.staging / context.config.output_with_format,
)
elif context.config.output_format == OutputFormat.cpio:
- make_cpio(
- context.root, context.staging / context.config.output_with_format,
- tools=context.config.tools(),
- sandbox=context.sandbox,
- )
+ make_cpio(context.root, context.staging / context.config.output_with_format, sandbox=context.sandbox)
elif context.config.output_format == OutputFormat.uki:
assert stub and kver and kimg
make_uki(context, stub, kver, kimg, microcode, context.staging / context.config.output_with_format)
from typing import Optional
from mkosi.log import log_step
-from mkosi.run import find_binary, run
+from mkosi.run import run
from mkosi.sandbox import Mount, SandboxProtocol, finalize_passwd_mounts, nosandbox
from mkosi.util import umask
-def tar_binary(*, tools: Path = Path("/")) -> str:
- # Some distros (Mandriva) install BSD tar as "tar", hence prefer
- # "gtar" if it exists, which should be GNU tar wherever it exists.
- # We are interested in exposing same behaviour everywhere hence
- # it's preferable to use the same implementation of tar
- # everywhere. In particular given the limited/different SELinux
- # support in BSD tar and the different command line syntax
- # compared to GNU tar.
- return "gtar" if find_binary("gtar", root=tools) else "tar"
-
-
-def cpio_binary(*, tools: Path = Path("/")) -> str:
- return "gcpio" if find_binary("gcpio", root=tools) else "cpio"
-
-
def tar_exclude_apivfs_tmp() -> list[str]:
return [
"--exclude", "./dev/*",
]
-def make_tar(src: Path, dst: Path, *, tools: Path = Path("/"), sandbox: SandboxProtocol = nosandbox) -> None:
+def make_tar(src: Path, dst: Path, *, sandbox: SandboxProtocol = nosandbox) -> None:
log_step(f"Creating tar archive {dst}…")
with dst.open("wb") as f:
run(
[
- tar_binary(tools=tools),
+ "tar",
"--create",
"--file", "-",
"--directory", src,
dst: Path,
*,
log: bool = True,
- tools: Path = Path("/"),
sandbox: SandboxProtocol = nosandbox,
) -> None:
if log:
with src.open("rb") as f:
run(
[
- tar_binary(tools=tools),
+ "tar",
"--extract",
"--file", "-",
"--directory", dst,
dst: Path,
*,
files: Optional[Iterable[Path]] = None,
- tools: Path = Path("/"),
sandbox: SandboxProtocol = nosandbox,
) -> None:
if not files:
with dst.open("wb") as f:
run(
[
- cpio_binary(tools=tools),
+ "cpio",
"--create",
"--reproducible",
"--null",
with open(path, "rb") as i, tempfile.NamedTemporaryFile() as o:
run(["dpkg-deb", "--fsys-tarfile", "/dev/stdin"], stdin=i, stdout=o, sandbox=context.sandbox())
- extract_tar(
- Path(o.name), context.root,
- log=False,
- tools=context.config.tools(),
- sandbox=context.sandbox,
- )
+ extract_tar(Path(o.name), context.root, log=False, sandbox=context.sandbox)
# Finally, run apt to properly install packages in the chroot without having to worry that maintainer
# scripts won't find basic tools that they depend on.