From c1eb37b193600d22833714f84f8c74776d741a76 Mon Sep 17 00:00:00 2001 From: Scarlett Clark Date: Sun, 27 Sep 2020 19:29:31 +0200 Subject: Make KDEPackageAppTemplates to create reproducible tarball. By default tar glues files in a random order together, this makes the output non reproducible. In order to fix, produce a sorted output and uniquify user/group and chmod. --- kde-modules/KDEPackageAppTemplates.cmake | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'kde-modules/KDEPackageAppTemplates.cmake') diff --git a/kde-modules/KDEPackageAppTemplates.cmake b/kde-modules/KDEPackageAppTemplates.cmake index 54fb6fa6..7f9feeb5 100644 --- a/kde-modules/KDEPackageAppTemplates.cmake +++ b/kde-modules/KDEPackageAppTemplates.cmake @@ -107,11 +107,20 @@ function(kde_package_app_templates) add_custom_target(${_baseName} ALL DEPENDS ${_template}) - add_custom_command(OUTPUT ${_template} - COMMAND ${CMAKE_COMMAND} -E tar "cvfj" ${_template} . - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} - ) - + if(GNU_TAR_FOUND) + # Make tar archive reproducible, the arguments are only available on UNIX like systems + add_custom_command(OUTPUT ${_template} + COMMAND tar ARGS -c ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + --exclude .kdev_ignore --exclude .svn --sort=name --mode=go=rX,u+rw,a-s --owner=root + --group=root --numeric-owner -j -v -f ${_template} . + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + ) + else() + add_custom_command(OUTPUT ${_template} + COMMAND ${CMAKE_COMMAND} -E tar "cvfj" ${_template} . + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + ) + endif() install(FILES ${_template} DESTINATION ${ARG_INSTALL_DIR}) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_template}") -- cgit v1.2.1 From 120eba4ab5f1f84d5792eb77a3a754e8a88981c5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 1 Dec 2020 09:42:09 +0100 Subject: Reproducible tarballs with GNU tar only - Search for a suitable `tar` program - Check version output if it's GNU tar Since this function is typically run only once per repo, there's not much point in doing extra cache work or writing a separate find-module. --- kde-modules/KDEPackageAppTemplates.cmake | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'kde-modules/KDEPackageAppTemplates.cmake') diff --git a/kde-modules/KDEPackageAppTemplates.cmake b/kde-modules/KDEPackageAppTemplates.cmake index 7f9feeb5..7d2ddb3c 100644 --- a/kde-modules/KDEPackageAppTemplates.cmake +++ b/kde-modules/KDEPackageAppTemplates.cmake @@ -83,6 +83,23 @@ function(kde_package_app_templates) message(FATAL_ERROR "No INSTALL_DIR argument given to kde_package_app_templates") endif() + find_program(_tar_executable NAMES gtar tar) + if(_tar_executable) + execute_process( + COMMAND ${_tar_executable} --version + TIMEOUT 3 + RESULT_VARIABLE _tar_exit + OUTPUT_VARIABLE _tar_version + ) + if("${_tar_exit}" EQUAL 0 AND "${_tar_version}" MATCHES "GNU tar") + set(GNU_TAR_FOUND ON) + else() + set(GNU_TAR_FOUND OFF) + endif() + else() + set(GNU_TAR_FOUND OFF) + endif() + foreach(_templateName ${ARG_TEMPLATES}) get_filename_component(_tmp_file ${_templateName} ABSOLUTE) @@ -108,9 +125,9 @@ function(kde_package_app_templates) add_custom_target(${_baseName} ALL DEPENDS ${_template}) if(GNU_TAR_FOUND) - # Make tar archive reproducible, the arguments are only available on UNIX like systems + # Make tar archive reproducible, the arguments are only available with GNU tar add_custom_command(OUTPUT ${_template} - COMMAND tar ARGS -c ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + COMMAND ${_tar_executable} ARGS -c ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} --exclude .kdev_ignore --exclude .svn --sort=name --mode=go=rX,u+rw,a-s --owner=root --group=root --numeric-owner -j -v -f ${_template} . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} -- cgit v1.2.1