]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
tar/cpio: fix compression options handling
authorLuca Boccassi <bluca@debian.org>
Wed, 24 Aug 2022 22:34:36 +0000 (23:34 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 25 Aug 2022 13:47:21 +0000 (15:47 +0200)
Let users build uncompressed tarballs. Also take into account the
usual algorithm to determine the compression type for cpio.
Defaults are unchanged.

NEWS.md
mkosi/__init__.py
mkosi/backend.py

diff --git a/NEWS.md b/NEWS.md
index dd2d2a4fd73b1f6978cb7a72cd7b5cda8ffb3020..03f0746439b3a5015f371459828adf39ef801d05 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -18,6 +18,7 @@ time.
 and mkosi.conf.d/ respectively. The old names (mkosi.default and mkosi.default.d) have
 been removed from the docs but are still supported for backwards compatibility.
 - `plain_squashfs` type images will now also be named with a `.raw` suffix.
+- `tar` type images will now respect the `--compress` option.
 
 ## v13
 
index 42e6940d400e23677aa0f31db7fabe13247681f9..c4d744bc035e15cf2d68476b9c9e5e766b0abafa 100644 (file)
@@ -6500,14 +6500,14 @@ def load_args(args: argparse.Namespace) -> MkosiArgs:
     if args.output is None:
         iid = args.image_id if args.image_id is not None else "image"
         prefix = f"{iid}_{args.image_version}" if args.image_version is not None else iid
+        compress = should_compress_output(args)
 
         if args.output_format.is_disk():
-            compress = should_compress_output(args)
             output = prefix + (".qcow2" if args.qcow2 else ".raw") + (f".{compress}" if compress else "")
         elif args.output_format == OutputFormat.tar:
-            output = f"{prefix}.tar.xz"
+            output = f"{prefix}.tar" + (f".{compress}" if compress else "")
         elif args.output_format == OutputFormat.cpio:
-            output = f"{prefix}.cpio" + (f".{args.compress}" if args.compress else "")
+            output = f"{prefix}.cpio" + (f".{compress}" if compress else "")
         elif args.output_format.is_squashfs():
             output = f"{prefix}.raw"
         else:
@@ -6545,8 +6545,6 @@ def load_args(args: argparse.Namespace) -> MkosiArgs:
 
     args.output = args.output.absolute()
 
-    if args.output_format == OutputFormat.tar:
-        args.compress_output = "xz"
     if not args.output_format.is_disk():
         args.split_artifacts = False
 
index 7c11734986c16ebf51cb7ad4a9b2aa7923c065c8..6ea3f8afac5144c3a4582c1ef9e3f22078bf7138 100644 (file)
@@ -611,6 +611,8 @@ def should_compress_output(args: Union[argparse.Namespace, MkosiArgs]) -> Union[
     c = args.compress_output
     if c is None and not args.output_format.has_fs_compression():
         c = args.compress
+    if c is None and args.output_format == OutputFormat.tar:
+        c = True
     if c is True:
         return "xz"  # default compression
     return False if c is None else c