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>
"""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: