From 48313bf31d92cfff175452101c787705e08c6560 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Tue, 1 Feb 2022 14:01:32 +0000 Subject: 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 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 --- kde-modules/KDEPackageAppTemplates.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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} -- cgit v1.2.1