]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Prefer gcpio over cpio
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 9 Aug 2023 08:01:46 +0000 (10:01 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 9 Aug 2023 10:15:05 +0000 (11:15 +0100)
Fixes #1201

mkosi/archive.py
mkosi/util.py

index ca26e776815558f202ec511d1c7d94efdb600dff..07e9634eecdd6a81d5452a77b492a84224cb4da4 100644 (file)
@@ -1,13 +1,28 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
 import os
+import shutil
 from collections.abc import Iterable
 from pathlib import Path
 from typing import Optional
 
 from mkosi.log import log_step
 from mkosi.run import bwrap, finalize_passwd_mounts
-from mkosi.util import tar_binary
+
+
+def tar_binary() -> 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 shutil.which("gtar") else "tar"
+
+
+def cpio_binary() -> str:
+    return "gcpio" if shutil.which("gcpio") else "cpio"
 
 
 def tar_exclude_apivfs_tmp() -> list[str]:
@@ -74,7 +89,7 @@ def make_cpio(src: Path, dst: Path, files: Optional[Iterable[Path]] = None) -> N
     log_step(f"Creating cpio archive {dst}…")
     bwrap(
         [
-            "cpio",
+            cpio_binary(),
             "--create",
             "--reproducible",
             "--null",
index 4ebfed8475b8403713a982d3b2794c72b128bcd6..88a329f824ae493d26dd782d428da75c8e1005c3 100644 (file)
@@ -14,7 +14,6 @@ import os
 import pwd
 import re
 import resource
-import shutil
 import stat
 import sys
 import tempfile
@@ -223,17 +222,6 @@ class StrEnum(enum.Enum):
         return list(map(str, cls))
 
 
-def tar_binary() -> 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 shutil.which("gtar") else "tar"
-
-
 def one_zero(b: bool) -> str:
     return "1" if b else "0"