]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
compressor_command: Use gzip -n for reproducible output 4091/head
authorRobert Sturla <rsturla@redhat.com>
Thu, 25 Dec 2025 18:02:13 +0000 (18:02 +0000)
committerRobert Sturla <rsturla@redhat.com>
Thu, 25 Dec 2025 18:55:37 +0000 (18:55 +0000)
The gzip format includes an MTIME field in its header that stores the
modification time of the original file. This causes compressed archives
to differ between builds even when the uncompressed content is identical.

Add the --no-name flag to gzip which suppresses storing the original
filename and timestamp, making gzip output reproducible.

Signed-off-by: Robert Sturla <rsturla@redhat.com>
mkosi/__init__.py

index 976fb399e918acd616dd102bd79c0686d6c32408..deac0ef333f02f110a34d7b675c66b61f1f2b7cf 100644 (file)
@@ -2349,7 +2349,7 @@ def compressor_command(context: Context, compression: Compression) -> list[PathS
     """Returns a command suitable for compressing archives."""
 
     if compression == Compression.gz:
-        return [gzip_binary(context), f"-{context.config.compress_level}", "--stdout", "-"]
+        return [gzip_binary(context), "--no-name", f"-{context.config.compress_level}", "--stdout", "-"]
     elif compression == Compression.xz:
         return ["xz", "--check=crc32", f"-{context.config.compress_level}", "-T0", "--stdout", "-"]
     elif compression == Compression.zstd: