aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2022-02-01 14:01:32 +0000
committerEmil Velikov <emil.l.velikov@gmail.com>2022-02-01 18:29:08 +0000
commit48313bf31d92cfff175452101c787705e08c6560 (patch)
treedbc6c0493a7996ead2885b195eb6d3c04d3223b4
parent2ca1750158dbd2058680b7e315ac76746e30fd0f (diff)
downloadextra-cmake-modules-48313bf31d92cfff175452101c787705e08c6560.tar.gz
extra-cmake-modules-48313bf31d92cfff175452101c787705e08c6560.tar.bz2
kde_package_app_templates: drop atime,ctime, consistently set mtime
As outlined in https://reproducible-builds.org/docs/archives/ to ensure that tarballs are reproducible, one should honour SOURCE_DATE_EPOCH. In the case it's not, fallback to date +%s, set the mtime. Delete atime and ctime completely. No idea if this is better or worse. Based on the patch by: Brendan Tildesley <mail@brendan.scot> From: https://bugs.kde.org/show_bug.cgi?id=443532 v2: Emil - Split from larger patch - Fallback to date +%s v3: Emil - $ENV{...} to evaluate the variable Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--kde-modules/KDEPackageAppTemplates.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/kde-modules/KDEPackageAppTemplates.cmake b/kde-modules/KDEPackageAppTemplates.cmake
index 9f50c665..8deb1731 100644
--- a/kde-modules/KDEPackageAppTemplates.cmake
+++ b/kde-modules/KDEPackageAppTemplates.cmake
@@ -114,6 +114,16 @@ function(kde_package_app_templates)
add_custom_target(${_baseName} ALL DEPENDS ${_template})
if(GNU_TAR_FOUND)
+ # Honour SOURCE_DATE_EPOCH if set
+ if(DEFINED ENV{SOURCE_DATE_EPOCH})
+ set(TIMESTAMP $ENV{SOURCE_DATE_EPOCH})
+ else()
+ execute_process(
+ COMMAND "date" "+%s"
+ OUTPUT_VARIABLE TIMESTAMP
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+
# Make tar archive reproducible, the arguments are only available with GNU tar
add_custom_command(OUTPUT ${_template}
COMMAND ${_tar_executable} ARGS
@@ -121,7 +131,8 @@ function(kde_package_app_templates)
--sort=name
--mode=go=rX,u+rw,a-s
--numeric-owner --owner=0 --group=0
- --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0
+ --mtime="@${TIMESTAMP}"
+ --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
-c -j -v -f ${_template} .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}
DEPENDS ${_subdirs_entries}