aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan de Groot <groot@kde.org>2020-12-01 09:42:09 +0100
committerSandro Knauß <sknauss@kde.org>2020-12-27 17:49:10 +0100
commit120eba4ab5f1f84d5792eb77a3a754e8a88981c5 (patch)
treef59582802ac2f291c10f45b06403a1e90d918f8c
parentc1eb37b193600d22833714f84f8c74776d741a76 (diff)
downloadextra-cmake-modules-120eba4ab5f1f84d5792eb77a3a754e8a88981c5.tar.gz
extra-cmake-modules-120eba4ab5f1f84d5792eb77a3a754e8a88981c5.tar.bz2
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.
-rw-r--r--kde-modules/KDEPackageAppTemplates.cmake21
1 files changed, 19 insertions, 2 deletions
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}