summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-01-19 17:50:43 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-01-28 16:34:01 +0100
commit4bce22ab4863b7035ec76e6757a70373cf3e9d04 (patch)
treea8e5ef6155870000b23e5b8070ffdf60e55b5b2f
parent30d86a1f293bcb6f9e260102a54f0f490b778ac7 (diff)
downloadtde-cmake-4bce22ab4863b7035ec76e6757a70373cf3e9d04.tar.gz
tde-cmake-4bce22ab4863b7035ec76e6757a70373cf3e9d04.zip
Update tde_create_tarball macro
+ Use external tar for ensure files owner in tarball. + Add an option to specify compression program. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit d9d9396324d27f70532ab4e9c878cb3c9e329385)
-rw-r--r--modules/TDEMacros.cmake44
1 files changed, 43 insertions, 1 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 77cf8f8..524b170 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -1593,6 +1593,7 @@ macro( tde_create_tarball )
unset( _files )
unset( _destination )
set( _sourcedir "${CMAKE_CURRENT_SOURCE_DIR}" )
+ set( _compression "gzip" )
set( _var _target )
foreach( _arg ${ARGN} )
@@ -1625,6 +1626,13 @@ macro( tde_create_tarball )
set( _directive 1 )
endif( )
+ # found directive "COMPRESSION"
+ if( "+${_arg}" STREQUAL "+COMPRESSION" )
+ unset( _compression )
+ set( _var _compression )
+ set( _directive 1 )
+ endif( )
+
# collect data
if( _directive )
unset( _directive )
@@ -1647,6 +1655,39 @@ macro( tde_create_tarball )
list( APPEND _files_deps "${_sourcedir}/${_file}" )
endforeach( )
+ if( NOT DEFINED TAR_EXECUTABLE )
+ find_program( TAR_EXECUTABLE NAMES tar )
+ if( "${TAR_EXECUTABLE}" STREQUAL "TAR_EXECUTABLE-NOTFOUND" )
+ tde_message_fatal( "tar executable is required but not found on your system" )
+ endif( )
+ endif( )
+
+ if( NOT DEFINED TAR_SETOWNER )
+ execute_process(
+ COMMAND ${TAR_EXECUTABLE} --version
+ OUTPUT_VARIABLE TAR_VERSION
+ )
+ string( REGEX REPLACE "^([^\n]*)\n.*" "\\1" TAR_VERSION "${TAR_VERSION}" )
+ if( "${TAR_VERSION}" MATCHES "GNU *tar" )
+ set( TAR_SETOWNER "--owner=root;--group=root" )
+ elseif( "${TAR_VERSION}" MATCHES "bsd *tar" )
+ set( TAR_SETOWNER "--uname=root;--gname=root" )
+ else( )
+ set( TAR_SETOWNER "" )
+ endif( )
+ endif( )
+
+ if( "${_compression}" STREQUAL "-" )
+ unset( _compression )
+ endif( )
+ if( _compression )
+ if( "${_compression}" STREQUAL "gzip" )
+ set( _compression "-z" )
+ else( )
+ set( _compression "--use-compress-program=\"${_compression}\"" )
+ endif( )
+ endif( )
+
get_filename_component( _target_path "${CMAKE_CURRENT_BINARY_DIR}/${_target}" ABSOLUTE )
file( RELATIVE_PATH _target_path "${CMAKE_BINARY_DIR}" "${_target_path}" )
string( REPLACE "/" "+" _target_name "${_target_path}" )
@@ -1654,7 +1695,8 @@ macro( tde_create_tarball )
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_target}" )
add_custom_command(
- COMMAND ${CMAKE_COMMAND} -E tar "cfz" "${CMAKE_CURRENT_BINARY_DIR}/${_target}" -- ${_files}
+ COMMAND ${TAR_EXECUTABLE} cf ${CMAKE_CURRENT_BINARY_DIR}/${_target}
+ ${_compression} ${TAR_SETOWNER} -- ${_files}
WORKING_DIRECTORY "${_sourcedir}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_target}"
DEPENDS ${_files_deps}