Commit 25e78ffa authored by Aaron Puchert's avatar Aaron Puchert

Make tar archives reproducible by setting Pax headers

Summary:
When POSIXLY_CORRECT is set, GNU tar will add ctime, atime and the PID
of the tar process that created the archive, as pointed out in [1].
To circumvent this, we set the Pax headers manually as recommended, but
we only do this when SOURCE_DATE_EPOCH is set, i.e. reproducible builds
are desired.

[1] https://salsa.debian.org/reproducible-builds/reproducible-website/merge_requests/50/diffs

Test Plan:
Repeated builds produce the same files now. Changing the input files'
timestamps seems without effect.

Reviewers: kfunk, #kdevelop, kossebau

Reviewed By: #kdevelop, kossebau

Differential Revision: https://phabricator.kde.org/D25494
parent 381aec18
......@@ -66,7 +66,8 @@ macro(kdevplatform_create_template_archive _templateName)
set(extraArgs "")
if(DEFINED ENV{SOURCE_DATE_EPOCH})
# We assume there is tar > 1.28 if a reproducible build is wanted.
set(extraArgs --mtime="@$ENV{SOURCE_DATE_EPOCH}" --sort=name)
set(extraArgs --mtime="@$ENV{SOURCE_DATE_EPOCH}" --sort=name
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime)
endif()
add_custom_command(OUTPUT ${_template}
COMMAND tar ARGS -c -C ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment