2015-06-05 22:03:26 +03:00
|
|
|
set(ALL_FILES_GLOB "*.deb")
|
|
|
|
|
|
|
|
function(getPackageContent FILE RESULT_VAR)
|
2016-05-10 16:40:48 +03:00
|
|
|
execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}"
|
2015-06-05 22:03:26 +03:00
|
|
|
OUTPUT_VARIABLE package_content_
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
2015-07-13 23:23:22 +03:00
|
|
|
|
2016-05-10 16:40:48 +03:00
|
|
|
function(getMissingShlibsErrorExtra FILE RESULT_VAR)
|
|
|
|
execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX}
|
|
|
|
ERROR_VARIABLE err_)
|
|
|
|
|
|
|
|
if(err_)
|
|
|
|
set(error_extra " Extra: Could not unpack package content: '${err}'")
|
|
|
|
else()
|
|
|
|
cmake_policy(PUSH)
|
|
|
|
# Tell file(GLOB_RECURSE) not to follow directory symlinks
|
|
|
|
# even if the project does not set this policy to NEW.
|
|
|
|
cmake_policy(SET CMP0009 NEW)
|
|
|
|
file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*")
|
|
|
|
cmake_policy(POP)
|
|
|
|
|
|
|
|
# get file info so that we can determine if file is executable or not
|
|
|
|
foreach(FILE_ IN LISTS FILE_PATHS_)
|
|
|
|
execute_process(COMMAND file "${FILE_}"
|
|
|
|
WORKING_DIRECTORY "${WDIR}"
|
|
|
|
OUTPUT_VARIABLE INSTALL_FILE_
|
|
|
|
ERROR_VARIABLE err_)
|
|
|
|
|
|
|
|
if(NOT err_)
|
|
|
|
list(APPEND deb_install_files "${INSTALL_FILE_}")
|
|
|
|
else()
|
|
|
|
list(APPEND deb_install_files_errors "'${FILE_}': '${err_}'\n")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(error_extra " Extra: install files '${deb_install_files}'")
|
|
|
|
|
|
|
|
if(deb_install_files_errors)
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND error_extra "; errors \"${deb_install_files_errors}\"")
|
2016-05-10 16:40:48 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_program(READELF_EXECUTABLE NAMES readelf)
|
|
|
|
|
|
|
|
if(READELF_EXECUTABLE)
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND error_extra "; readelf \"\n")
|
2016-05-10 16:40:48 +03:00
|
|
|
|
|
|
|
# Only dynamically linked ELF files are included
|
|
|
|
# Extract only file name infront of ":"
|
|
|
|
foreach(_FILE IN LISTS deb_install_files)
|
|
|
|
if(_FILE MATCHES "ELF.*shared object")
|
|
|
|
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
|
|
|
|
|
|
|
|
execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}"
|
|
|
|
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
OUTPUT_VARIABLE output
|
|
|
|
ERROR_VARIABLE err_
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND error_extra " name '${CMAKE_MATCH_1}'\n result '${result}'\n output '${output}'\n error '${err_}'\n")
|
2016-05-10 16:40:48 +03:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND error_extra "\"")
|
2016-05-10 16:40:48 +03:00
|
|
|
else()
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND error_extra "; error readelf missing")
|
2016-05-10 16:40:48 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${RESULT_VAR} "${error_extra}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2015-07-13 23:23:22 +03:00
|
|
|
function(verifyDebControl FILE PREFIX VERIFY_FILES)
|
2016-05-10 16:40:48 +03:00
|
|
|
execute_process(COMMAND ${DPKG_EXECUTABLE} --control "${FILE}" control_${PREFIX}
|
2015-07-13 23:23:22 +03:00
|
|
|
ERROR_VARIABLE err_)
|
|
|
|
|
|
|
|
if(err_)
|
2015-09-11 18:31:01 +03:00
|
|
|
message(FATAL_ERROR "Debian control verification failed for file: "
|
2015-07-13 23:23:22 +03:00
|
|
|
"'${FILE}'; error output: '${err_}'")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(FILE_ IN LISTS VERIFY_FILES)
|
2016-05-10 16:40:48 +03:00
|
|
|
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}")
|
|
|
|
if(FILE_ STREQUAL "shlibs")
|
|
|
|
getMissingShlibsErrorExtra("${FILE}" error_extra)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(FATAL_ERROR "Expected Debian control file does not exist: '${FILE_}'${error_extra}")
|
|
|
|
endif()
|
|
|
|
|
2015-07-13 23:23:22 +03:00
|
|
|
file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_)
|
|
|
|
if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}")
|
|
|
|
message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!"
|
|
|
|
" Content: '${content_}'")
|
|
|
|
endif()
|
2015-09-14 23:44:00 +03:00
|
|
|
|
|
|
|
execute_process(COMMAND ls -l "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}"
|
|
|
|
OUTPUT_VARIABLE package_permissions_
|
|
|
|
ERROR_VARIABLE package_permissions_error_
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
if(NOT package_permissions_error_)
|
|
|
|
if(NOT package_permissions_ MATCHES "${${PREFIX}_${FILE_}_permissions_regex}")
|
|
|
|
message(FATAL_ERROR "Unexpected file permissions for ${PREFIX}_${FILE_}: '${package_permissions_}'!")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Listing file permissions failed (${package_permissions_error_})!")
|
|
|
|
endif()
|
2015-07-13 23:23:22 +03:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|
2015-07-30 00:34:17 +03:00
|
|
|
|
|
|
|
function(getPackageInfo FILE RESULT_VAR)
|
|
|
|
execute_process(COMMAND ${DPKG_EXECUTABLE} -I ${FILE}
|
|
|
|
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
|
|
|
|
OUTPUT_VARIABLE package_info_
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
set(${RESULT_VAR} "${package_info_}" PARENT_SCOPE)
|
|
|
|
endfunction()
|