1set(ALL_FILES_GLOB "*.rpm") 2 3function(getPackageContent FILE RESULT_VAR) 4 execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${FILE} 5 OUTPUT_VARIABLE package_content_ 6 ERROR_QUIET 7 OUTPUT_STRIP_TRAILING_WHITESPACE) 8 9 set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) 10endfunction() 11 12function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) 13 if(COMPONENT) 14 set(COMPONENT "-${COMPONENT}") 15 endif() 16 17 if(DEFINED EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT) 18 set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT}") 19 elseif(DEFINED EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT) 20 set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT}") 21 else() 22 set(GENERATOR_SPECIFIC_FORMAT FALSE) 23 endif() 24 25 if(GENERATOR_SPECIFIC_FORMAT) 26 if(NOT REVISION) 27 set(REVISION "1") 28 endif() 29 set(${RESULT_VAR} "${NAME}${COMPONENT}-${VERSION}-${REVISION}.*.rpm" PARENT_SCOPE) 30 else() 31 set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.rpm" PARENT_SCOPE) 32 endif() 33endfunction() 34 35function(getPackageContentList FILE RESULT_VAR) 36 execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${FILE} 37 OUTPUT_VARIABLE package_content_ 38 ERROR_QUIET 39 OUTPUT_STRIP_TRAILING_WHITESPACE) 40 string(REGEX REPLACE "\n" ";" package_content_ "${package_content_}") 41 42 # never versions of rpmbuild (introduced in rpm 4.13.0.1) add build_id links 43 # to packages - tests should ignore them 44 list(FILTER package_content_ EXCLUDE REGEX ".*\.build-id.*") 45 46 set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) 47endfunction() 48 49function(toExpectedContentList FILE_NO CONTENT_VAR) 50 # add install prefix to expected paths 51 if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX) 52 set(EXPECTED_FILE_PACKAGING_PREFIX 53 "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}") 54 elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX) 55 # default CPackRPM packaging install prefix 56 set(EXPECTED_FILE_PACKAGING_PREFIX "/usr") 57 endif() 58 set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}") 59 foreach(part_ IN LISTS ${CONTENT_VAR}) 60 list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}") 61 endforeach() 62 63 # remove paths that are excluded from auto packaging 64 if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) 65 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST 66 /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib 67 /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal /usr/share/doc) 68 endif() 69 unset(filtered_) 70 foreach(part_ IN LISTS prepared_) 71 unset(dont_add_) 72 foreach(for_removal_ IN LISTS CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) 73 if(part_ STREQUAL for_removal_) 74 set(dont_add_ TRUE) 75 break() 76 endif() 77 endforeach() 78 79 if(NOT dont_add_) 80 list(APPEND filtered_ "${part_}") 81 endif() 82 endforeach() 83 84 set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) 85endfunction() 86 87function(getPackageInfo FILE RESULT_VAR) 88 execute_process(COMMAND ${RPM_EXECUTABLE} -pqi ${FILE} 89 OUTPUT_VARIABLE info_content 90 ERROR_QUIET 91 OUTPUT_STRIP_TRAILING_WHITESPACE) 92 93 set(${RESULT_VAR} "${info_content}" PARENT_SCOPE) 94endfunction() 95