| 1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
# file LICENSE.rst or https://cmake.org/licensing for details. |
| 3 |
|
| 4 |
# Author: Eric Noulard with the help of Alexander Neundorf. |
| 5 |
|
| 6 |
function(set_spec_script_if_enabled TYPE PACKAGE_NAME VAR) |
| 7 |
if(NOT "${VAR}" STREQUAL "" AND NOT "${VAR}" STREQUAL "\n") |
| 8 |
if(PACKAGE_NAME) |
| 9 |
set(PACKAGE_NAME " -n ${PACKAGE_NAME}") |
| 10 |
endif() |
| 11 |
set(${TYPE}_ "%${TYPE}${PACKAGE_NAME}\n${VAR}\n" PARENT_SCOPE) |
| 12 |
else() |
| 13 |
set(${TYPE} "" PARENT_SCOPE) |
| 14 |
endif() |
| 15 |
endfunction() |
| 16 |
|
| 17 |
macro(set_spec_scripts PACKAGE_NAME) |
| 18 |
# we should only set scripts that were provided |
| 19 |
# as script announcement without content inside |
| 20 |
# spec file will generate unneeded dependency |
| 21 |
# on shell |
| 22 |
|
| 23 |
set_spec_script_if_enabled( |
| 24 |
"post" |
| 25 |
"${PACKAGE_NAME}" |
| 26 |
"${RPM_SYMLINK_POSTINSTALL}\n${CPACK_RPM_SPEC_POSTINSTALL}") |
| 27 |
|
| 28 |
set_spec_script_if_enabled( |
| 29 |
"posttrans" |
| 30 |
"${PACKAGE_NAME}" |
| 31 |
"${CPACK_RPM_SPEC_POSTTRANS}") |
| 32 |
|
| 33 |
set_spec_script_if_enabled( |
| 34 |
"postun" |
| 35 |
"${PACKAGE_NAME}" |
| 36 |
"${CPACK_RPM_SPEC_POSTUNINSTALL}") |
| 37 |
|
| 38 |
set_spec_script_if_enabled( |
| 39 |
"pre" |
| 40 |
"${PACKAGE_NAME}" |
| 41 |
"${CPACK_RPM_SPEC_PREINSTALL}") |
| 42 |
|
| 43 |
set_spec_script_if_enabled( |
| 44 |
"pretrans" |
| 45 |
"${PACKAGE_NAME}" |
| 46 |
"${CPACK_RPM_SPEC_PRETRANS}") |
| 47 |
|
| 48 |
set_spec_script_if_enabled( |
| 49 |
"preun" |
| 50 |
"${PACKAGE_NAME}" |
| 51 |
"${CPACK_RPM_SPEC_PREUNINSTALL}") |
| 52 |
endmacro() |
| 53 |
|
| 54 |
function(make_rpm_spec_path var path) |
| 55 |
# RPM supports either whitespace with quoting or globbing without quoting. |
| 56 |
if(path MATCHES "[ \t]") |
| 57 |
set("${var}" "\"${path}\"" PARENT_SCOPE) |
| 58 |
else() |
| 59 |
set("${var}" "${path}" PARENT_SCOPE) |
| 60 |
endif() |
| 61 |
endfunction() |
| 62 |
|
| 63 |
function(get_file_permissions FILE RETURN_VAR) |
| 64 |
execute_process(COMMAND ls -l ${FILE} |
| 65 |
OUTPUT_VARIABLE permissions_ |
| 66 |
ERROR_QUIET |
| 67 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 68 |
|
| 69 |
string(REPLACE " " ";" permissions_ "${permissions_}") |
| 70 |
list(GET permissions_ 0 permissions_) |
| 71 |
|
| 72 |
unset(text_notation_) |
| 73 |
set(any_chars_ ".") |
| 74 |
foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD") |
| 75 |
if(permissions_ MATCHES "${any_chars_}r.*") |
| 76 |
list(APPEND text_notation_ "${PERMISSION_TYPE}_READ") |
| 77 |
endif() |
| 78 |
string(APPEND any_chars_ ".") |
| 79 |
if(permissions_ MATCHES "${any_chars_}w.*") |
| 80 |
list(APPEND text_notation_ "${PERMISSION_TYPE}_WRITE") |
| 81 |
endif() |
| 82 |
string(APPEND any_chars_ ".") |
| 83 |
if(permissions_ MATCHES "${any_chars_}x.*") |
| 84 |
list(APPEND text_notation_ "${PERMISSION_TYPE}_EXECUTE") |
| 85 |
endif() |
| 86 |
endforeach() |
| 87 |
|
| 88 |
set(${RETURN_VAR} "${text_notation_}" PARENT_SCOPE) |
| 89 |
endfunction() |
| 90 |
|
| 91 |
function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR) |
| 92 |
set(PERMISSIONS ${${PERMISSIONS_VAR}}) |
| 93 |
list(LENGTH PERMISSIONS PERM_LEN_PRE) |
| 94 |
list(REMOVE_DUPLICATES PERMISSIONS) |
| 95 |
list(LENGTH PERMISSIONS PERM_LEN_POST) |
| 96 |
|
| 97 |
if(NOT ${PERM_LEN_PRE} EQUAL ${PERM_LEN_POST}) |
| 98 |
message(FATAL_ERROR "${PERMISSIONS_VAR} contains duplicate values.") |
| 99 |
endif() |
| 100 |
|
| 101 |
foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD") |
| 102 |
set(${PERMISSION_TYPE}_PERMISSIONS 0) |
| 103 |
|
| 104 |
foreach(PERMISSION ${PERMISSIONS}) |
| 105 |
if("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_READ") |
| 106 |
math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 4") |
| 107 |
elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_WRITE") |
| 108 |
math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 2") |
| 109 |
elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_EXECUTE") |
| 110 |
math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 1") |
| 111 |
elseif(PERMISSION MATCHES "${PERMISSION_TYPE}.*") |
| 112 |
message(FATAL_ERROR "${PERMISSIONS_VAR} contains invalid values.") |
| 113 |
endif() |
| 114 |
endforeach() |
| 115 |
endforeach() |
| 116 |
|
| 117 |
set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE) |
| 118 |
endfunction() |
| 119 |
|
| 120 |
function(cpack_rpm_exact_regex regex_var string) |
| 121 |
string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${string}") |
| 122 |
set("${regex_var}" "${regex}" PARENT_SCOPE) |
| 123 |
endfunction() |
| 124 |
|
| 125 |
function(cpack_rpm_prepare_relocation_paths) |
| 126 |
# set appropriate prefix, remove possible trailing slash and convert backslashes to slashes |
| 127 |
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX) |
| 128 |
file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX) |
| 129 |
elseif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX) |
| 130 |
file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX) |
| 131 |
else() |
| 132 |
file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX) |
| 133 |
endif() |
| 134 |
|
| 135 |
set(RPM_RELOCATION_PATHS "${CPACK_RPM_RELOCATION_PATHS}") |
| 136 |
list(REMOVE_DUPLICATES RPM_RELOCATION_PATHS) |
| 137 |
|
| 138 |
# set base path prefix |
| 139 |
if(EXISTS "${WDIR}/${PATH_PREFIX}") |
| 140 |
if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND |
| 141 |
NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND |
| 142 |
NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION) |
| 143 |
string(APPEND TMP_RPM_PREFIXES "Prefix: ${PATH_PREFIX}\n") |
| 144 |
list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}") |
| 145 |
|
| 146 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 147 |
message("CPackRPM:Debug: removing '${PATH_PREFIX}' from relocation paths") |
| 148 |
endif() |
| 149 |
endif() |
| 150 |
endif() |
| 151 |
|
| 152 |
# set other path prefixes |
| 153 |
foreach(RELOCATION_PATH ${RPM_RELOCATION_PATHS}) |
| 154 |
if(IS_ABSOLUTE "${RELOCATION_PATH}") |
| 155 |
set(PREPARED_RELOCATION_PATH "${RELOCATION_PATH}") |
| 156 |
elseif(PATH_PREFIX STREQUAL "/") |
| 157 |
# don't prefix path with a second slash as "//" is treated as network path |
| 158 |
# by get_filename_component() so it remains in path even inside rpm |
| 159 |
# package where it may cause problems with relocation |
| 160 |
set(PREPARED_RELOCATION_PATH "/${RELOCATION_PATH}") |
| 161 |
else() |
| 162 |
set(PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}") |
| 163 |
endif() |
| 164 |
|
| 165 |
# handle cases where path contains extra slashes (e.g. /a//b/ instead of |
| 166 |
# /a/b) |
| 167 |
get_filename_component(PREPARED_RELOCATION_PATH |
| 168 |
"${PREPARED_RELOCATION_PATH}" ABSOLUTE) |
| 169 |
|
| 170 |
if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}") |
| 171 |
string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n") |
| 172 |
list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}") |
| 173 |
endif() |
| 174 |
endforeach() |
| 175 |
|
| 176 |
# warn about all the paths that are not relocatable |
| 177 |
file(GLOB_RECURSE FILE_PATHS_ "${WDIR}/*") |
| 178 |
foreach(TMP_PATH ${FILE_PATHS_}) |
| 179 |
string(LENGTH "${WDIR}" WDIR_LEN) |
| 180 |
string(SUBSTRING "${TMP_PATH}" ${WDIR_LEN} -1 TMP_PATH) |
| 181 |
unset(TMP_PATH_FOUND_) |
| 182 |
|
| 183 |
foreach(RELOCATION_PATH ${RPM_USED_PACKAGE_PREFIXES}) |
| 184 |
file(RELATIVE_PATH REL_PATH_ "${RELOCATION_PATH}" "${TMP_PATH}") |
| 185 |
string(SUBSTRING "${REL_PATH_}" 0 2 PREFIX_) |
| 186 |
|
| 187 |
if(NOT "${PREFIX_}" STREQUAL "..") |
| 188 |
set(TMP_PATH_FOUND_ TRUE) |
| 189 |
break() |
| 190 |
endif() |
| 191 |
endforeach() |
| 192 |
|
| 193 |
if(NOT TMP_PATH_FOUND_) |
| 194 |
message(AUTHOR_WARNING "CPackRPM:Warning: Path ${TMP_PATH} is not on one of the relocatable paths! Package will be partially relocatable.") |
| 195 |
endif() |
| 196 |
endforeach() |
| 197 |
|
| 198 |
set(RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}" PARENT_SCOPE) |
| 199 |
set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE) |
| 200 |
endfunction() |
| 201 |
|
| 202 |
function(cpack_rpm_prepare_content_list) |
| 203 |
# get files list |
| 204 |
file(GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*") |
| 205 |
set(CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}") |
| 206 |
string(REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}") |
| 207 |
|
| 208 |
# if we are creating a relocatable package, omit parent directories of |
| 209 |
# CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" |
| 210 |
# which is passed to the find command that generates the content-list |
| 211 |
if(CPACK_RPM_PACKAGE_RELOCATABLE) |
| 212 |
# get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are |
| 213 |
# destinct parent paths of other relocation paths and remove the |
| 214 |
# final element (so the install-prefix dir itself is not omitted |
| 215 |
# from the RPM's content-list) |
| 216 |
list(SORT RPM_USED_PACKAGE_PREFIXES) |
| 217 |
set(_DISTINCT_PATH "NOT_SET") |
| 218 |
foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES}) |
| 219 |
if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*") |
| 220 |
set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}") |
| 221 |
|
| 222 |
string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}") |
| 223 |
list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1) |
| 224 |
unset(_TMP_LIST) |
| 225 |
# Now generate all of the parent dirs of the relocation path |
| 226 |
foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS}) |
| 227 |
list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}") |
| 228 |
string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}") |
| 229 |
separate_arguments(_OMIT_DIR) |
| 230 |
list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR}) |
| 231 |
endforeach() |
| 232 |
endif() |
| 233 |
endforeach() |
| 234 |
endif() |
| 235 |
|
| 236 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 237 |
message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") |
| 238 |
endif() |
| 239 |
|
| 240 |
if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) |
| 241 |
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/bin |
| 242 |
/usr/include /usr/lib /usr/libx32 /usr/lib64 |
| 243 |
/usr/share /usr/share/aclocal /usr/share/doc ) |
| 244 |
if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) |
| 245 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 246 |
message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") |
| 247 |
endif() |
| 248 |
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}") |
| 249 |
endif() |
| 250 |
endif() |
| 251 |
|
| 252 |
if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) |
| 253 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 254 |
message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}") |
| 255 |
endif() |
| 256 |
list(APPEND _RPM_DIRS_TO_OMIT ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}) |
| 257 |
endif() |
| 258 |
|
| 259 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 260 |
message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") |
| 261 |
endif() |
| 262 |
|
| 263 |
list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${_RPM_DIRS_TO_OMIT}) |
| 264 |
|
| 265 |
# add man paths that will be compressed |
| 266 |
# (copied from /usr/lib/rpm/brp-compress - script that does the actual |
| 267 |
# compressing) |
| 268 |
list(APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*" |
| 269 |
"/usr/share/man/man.*" "/usr/share/man/.*/man.*" "/usr/share/info.*" |
| 270 |
"/usr/kerberos/man.*" "/usr/X11R6/man/man.*" "/usr/lib/perl5/man/man.*" |
| 271 |
"/usr/share/doc/.*/man/man.*" "/usr/lib/.*/man/man.*") |
| 272 |
|
| 273 |
if(CPACK_RPM_ADDITIONAL_MAN_DIRS) |
| 274 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 275 |
message("CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}") |
| 276 |
endif() |
| 277 |
list(APPEND MAN_LOCATIONS ${CPACK_RPM_ADDITIONAL_MAN_DIRS}) |
| 278 |
endif() |
| 279 |
|
| 280 |
foreach(PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES) |
| 281 |
foreach(MAN_LOCATION IN LISTS MAN_LOCATIONS) |
| 282 |
# man pages are files inside a certain location |
| 283 |
if(PACK_LOCATION MATCHES "${MAN_LOCATION}/" |
| 284 |
AND NOT IS_DIRECTORY "${WDIR}${PACK_LOCATION}" |
| 285 |
AND NOT IS_SYMLINK "${WDIR}${PACK_LOCATION}") |
| 286 |
list(FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX) |
| 287 |
# insert file location that covers compressed man pages |
| 288 |
# even if using a wildcard causes duplicates as those are |
| 289 |
# handled by RPM and we still keep the same file list |
| 290 |
# in spec file - wildcard only represents file type (e.g. .gz) |
| 291 |
list(INSERT CPACK_RPM_INSTALL_FILES ${INDEX} "${PACK_LOCATION}*") |
| 292 |
# remove file location that doesn't cover compressed man pages |
| 293 |
math(EXPR INDEX ${INDEX}+1) |
| 294 |
list(REMOVE_AT CPACK_RPM_INSTALL_FILES ${INDEX}) |
| 295 |
|
| 296 |
break() |
| 297 |
endif() |
| 298 |
endforeach() |
| 299 |
endforeach() |
| 300 |
|
| 301 |
set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE) |
| 302 |
endfunction() |
| 303 |
|
| 304 |
function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE) |
| 305 |
foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES) |
| 306 |
string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}") |
| 307 |
if(FOUND_) |
| 308 |
list(APPEND TMP_PREFIXES "${PKG_PREFIX}") |
| 309 |
endif() |
| 310 |
endforeach() |
| 311 |
|
| 312 |
set(${RETURN_VARIABLE} "${TMP_PREFIXES}" PARENT_SCOPE) |
| 313 |
endfunction() |
| 314 |
|
| 315 |
function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) |
| 316 |
list(LENGTH PACKAGE_PREFIXES LAST_INDEX) |
| 317 |
set(SORTED_PACKAGE_PREFIXES "${PACKAGE_PREFIXES}") |
| 318 |
list(SORT SORTED_PACKAGE_PREFIXES) |
| 319 |
list(REVERSE SORTED_PACKAGE_PREFIXES) |
| 320 |
math(EXPR LAST_INDEX ${LAST_INDEX}-1) |
| 321 |
|
| 322 |
foreach(SYMLINK_INDEX RANGE ${LAST_INDEX}) |
| 323 |
list(GET SORTED_PACKAGE_PREFIXES ${SYMLINK_INDEX} SRC_PATH) |
| 324 |
list(FIND PACKAGE_PREFIXES "${SRC_PATH}" SYMLINK_INDEX) # reverse magic |
| 325 |
string(LENGTH "${SRC_PATH}" SRC_PATH_LEN) |
| 326 |
|
| 327 |
set(PARTS_CNT 0) |
| 328 |
set(SCRIPT_PART "if [ \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}\" != \"${SRC_PATH}\" ]; then\n") |
| 329 |
|
| 330 |
# both paths relocated |
| 331 |
foreach(POINT_INDEX RANGE ${LAST_INDEX}) |
| 332 |
list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH) |
| 333 |
list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic |
| 334 |
string(LENGTH "${POINT_PATH}" POINT_PATH_LEN) |
| 335 |
|
| 336 |
if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}) |
| 337 |
if("${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}") |
| 338 |
set(INDENT "") |
| 339 |
else() |
| 340 |
string(APPEND SCRIPT_PART " if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") |
| 341 |
set(INDENT " ") |
| 342 |
endif() |
| 343 |
|
| 344 |
foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}) |
| 345 |
math(EXPR PARTS_CNT ${PARTS_CNT}+1) |
| 346 |
|
| 347 |
math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) |
| 348 |
list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) |
| 349 |
string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) |
| 350 |
|
| 351 |
math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN}) |
| 352 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_) |
| 353 |
|
| 354 |
math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN}) |
| 355 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) |
| 356 |
|
| 357 |
string(APPEND SCRIPT_PART " ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") |
| 358 |
string(APPEND SCRIPT_PART " ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") |
| 359 |
string(APPEND SCRIPT_PART " ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") |
| 360 |
string(APPEND SCRIPT_PART " ${INDENT}fi\n") |
| 361 |
endforeach() |
| 362 |
|
| 363 |
if(NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}") |
| 364 |
string(APPEND SCRIPT_PART " fi\n") |
| 365 |
endif() |
| 366 |
endif() |
| 367 |
endforeach() |
| 368 |
|
| 369 |
# source path relocated |
| 370 |
if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X) |
| 371 |
foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X) |
| 372 |
math(EXPR PARTS_CNT ${PARTS_CNT}+1) |
| 373 |
|
| 374 |
math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) |
| 375 |
list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) |
| 376 |
string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) |
| 377 |
|
| 378 |
math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN}) |
| 379 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_) |
| 380 |
|
| 381 |
math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1) |
| 382 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) |
| 383 |
|
| 384 |
string(APPEND SCRIPT_PART " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") |
| 385 |
string(APPEND SCRIPT_PART " ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") |
| 386 |
string(APPEND SCRIPT_PART " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") |
| 387 |
string(APPEND SCRIPT_PART " fi\n") |
| 388 |
endforeach() |
| 389 |
endif() |
| 390 |
|
| 391 |
if(PARTS_CNT) |
| 392 |
set(SCRIPT "${SCRIPT_PART}") |
| 393 |
string(APPEND SCRIPT "fi\n") |
| 394 |
endif() |
| 395 |
endforeach() |
| 396 |
|
| 397 |
# point path relocated |
| 398 |
foreach(POINT_INDEX RANGE ${LAST_INDEX}) |
| 399 |
list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH) |
| 400 |
list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic |
| 401 |
string(LENGTH "${POINT_PATH}" POINT_PATH_LEN) |
| 402 |
|
| 403 |
if(_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}) |
| 404 |
string(APPEND SCRIPT "if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") |
| 405 |
|
| 406 |
foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}) |
| 407 |
math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) |
| 408 |
list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) |
| 409 |
string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) |
| 410 |
|
| 411 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_) |
| 412 |
|
| 413 |
math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN}) |
| 414 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) |
| 415 |
|
| 416 |
string(APPEND SCRIPT " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") |
| 417 |
string(APPEND SCRIPT " ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n") |
| 418 |
string(APPEND SCRIPT " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") |
| 419 |
string(APPEND SCRIPT " fi\n") |
| 420 |
endforeach() |
| 421 |
|
| 422 |
string(APPEND SCRIPT "fi\n") |
| 423 |
endif() |
| 424 |
endforeach() |
| 425 |
|
| 426 |
# no path relocated |
| 427 |
if(_RPM_RELOCATION_SCRIPT_X_X) |
| 428 |
foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_X) |
| 429 |
math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) |
| 430 |
list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) |
| 431 |
string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) |
| 432 |
|
| 433 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_) |
| 434 |
|
| 435 |
math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1) |
| 436 |
string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) |
| 437 |
|
| 438 |
string(APPEND SCRIPT "if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") |
| 439 |
string(APPEND SCRIPT " ln -s \"${POINT_}\" \"${SYMLINK_}\"\n") |
| 440 |
string(APPEND SCRIPT "fi\n") |
| 441 |
endforeach() |
| 442 |
endif() |
| 443 |
|
| 444 |
set(RPM_SYMLINK_POSTINSTALL "${SCRIPT}" PARENT_SCOPE) |
| 445 |
endfunction() |
| 446 |
|
| 447 |
function(cpack_rpm_symlink_add_for_relocation_script PACKAGE_PREFIXES SYMLINK SYMLINK_RELOCATION_PATHS POINT POINT_RELOCATION_PATHS) |
| 448 |
list(LENGTH SYMLINK_RELOCATION_PATHS SYMLINK_PATHS_COUNT) |
| 449 |
list(LENGTH POINT_RELOCATION_PATHS POINT_PATHS_COUNT) |
| 450 |
|
| 451 |
list(APPEND _RPM_RELOCATION_SCRIPT_PAIRS "${SYMLINK}:${POINT}") |
| 452 |
list(LENGTH _RPM_RELOCATION_SCRIPT_PAIRS PAIR_NO) |
| 453 |
|
| 454 |
if(SYMLINK_PATHS_COUNT) |
| 455 |
foreach(SYMLINK_RELOC_PATH IN LISTS SYMLINK_RELOCATION_PATHS) |
| 456 |
list(FIND PACKAGE_PREFIXES "${SYMLINK_RELOC_PATH}" SYMLINK_INDEX) |
| 457 |
|
| 458 |
# source path relocated |
| 459 |
list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X "${PAIR_NO}") |
| 460 |
list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X") |
| 461 |
|
| 462 |
foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS) |
| 463 |
list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX) |
| 464 |
|
| 465 |
# both paths relocated |
| 466 |
list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX} "${PAIR_NO}") |
| 467 |
list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}") |
| 468 |
|
| 469 |
# point path relocated |
| 470 |
list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}") |
| 471 |
list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}") |
| 472 |
endforeach() |
| 473 |
endforeach() |
| 474 |
elseif(POINT_PATHS_COUNT) |
| 475 |
foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS) |
| 476 |
list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX) |
| 477 |
|
| 478 |
# point path relocated |
| 479 |
list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}") |
| 480 |
list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}") |
| 481 |
endforeach() |
| 482 |
endif() |
| 483 |
|
| 484 |
# no path relocated |
| 485 |
list(APPEND _RPM_RELOCATION_SCRIPT_X_X "${PAIR_NO}") |
| 486 |
list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_X") |
| 487 |
|
| 488 |
# place variables into parent scope |
| 489 |
foreach(VAR IN LISTS RELOCATION_VARS) |
| 490 |
set(${VAR} "${${VAR}}" PARENT_SCOPE) |
| 491 |
endforeach() |
| 492 |
set(_RPM_RELOCATION_SCRIPT_PAIRS "${_RPM_RELOCATION_SCRIPT_PAIRS}" PARENT_SCOPE) |
| 493 |
set(REQUIRES_SYMLINK_RELOCATION_SCRIPT "true" PARENT_SCOPE) |
| 494 |
set(DIRECTIVE "%ghost " PARENT_SCOPE) |
| 495 |
endfunction() |
| 496 |
|
| 497 |
function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXES IS_RELOCATABLE) |
| 498 |
# Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir |
| 499 |
# This is necessary to avoid duplicate files since rpmbuild does |
| 500 |
# recursion on its own when encountering a pathname which is a directory |
| 501 |
# which is not flagged as %dir |
| 502 |
string(STRIP "${INSTALL_FILES_LIST}" INSTALL_FILES_LIST) |
| 503 |
string(REPLACE "\n" ";" INSTALL_FILES_LIST |
| 504 |
"${INSTALL_FILES_LIST}") |
| 505 |
string(REPLACE "\"" "" INSTALL_FILES_LIST |
| 506 |
"${INSTALL_FILES_LIST}") |
| 507 |
string(LENGTH "${WDIR}" WDR_LEN_) |
| 508 |
|
| 509 |
list(SORT INSTALL_FILES_LIST) # make file order consistent on all platforms |
| 510 |
|
| 511 |
foreach(F IN LISTS INSTALL_FILES_LIST) |
| 512 |
unset(DIRECTIVE) |
| 513 |
|
| 514 |
if(IS_SYMLINK "${WDIR}/${F}") |
| 515 |
if(IS_RELOCATABLE) |
| 516 |
# check that symlink has relocatable format |
| 517 |
get_filename_component(SYMLINK_LOCATION_ "${WDIR}/${F}" DIRECTORY) |
| 518 |
execute_process(COMMAND ls -la "${WDIR}/${F}" |
| 519 |
WORKING_DIRECTORY "${WDIR}" |
| 520 |
OUTPUT_VARIABLE SYMLINK_POINT_ |
| 521 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 522 |
|
| 523 |
string(FIND "${SYMLINK_POINT_}" "->" SYMLINK_POINT_INDEX_ REVERSE) |
| 524 |
math(EXPR SYMLINK_POINT_INDEX_ ${SYMLINK_POINT_INDEX_}+3) |
| 525 |
string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_) |
| 526 |
|
| 527 |
# get destination path |
| 528 |
string(SUBSTRING "${SYMLINK_POINT_}" ${SYMLINK_POINT_INDEX_} ${SYMLINK_POINT_LENGTH_} SYMLINK_POINT_) |
| 529 |
|
| 530 |
# check if path is relative or absolute |
| 531 |
string(SUBSTRING "${SYMLINK_POINT_}" 0 1 SYMLINK_IS_ABSOLUTE_) |
| 532 |
|
| 533 |
if(${SYMLINK_IS_ABSOLUTE_} STREQUAL "/") |
| 534 |
# prevent absolute paths from having /../ or /./ section inside of them |
| 535 |
get_filename_component(SYMLINK_POINT_ "${SYMLINK_POINT_}" ABSOLUTE) |
| 536 |
else() |
| 537 |
# handle relative path |
| 538 |
get_filename_component(SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE) |
| 539 |
endif() |
| 540 |
|
| 541 |
# recalculate path length after conversion to canonical form |
| 542 |
string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_) |
| 543 |
|
| 544 |
cpack_rpm_exact_regex(IN_SYMLINK_POINT_REGEX "${WDIR}") |
| 545 |
string(APPEND IN_SYMLINK_POINT_REGEX "/.*") |
| 546 |
if(SYMLINK_POINT_ MATCHES "${IN_SYMLINK_POINT_REGEX}") |
| 547 |
# only symlinks that are pointing inside the packaging structure should be checked for relocation |
| 548 |
string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_) |
| 549 |
cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS") |
| 550 |
cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS") |
| 551 |
|
| 552 |
list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT) |
| 553 |
list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT) |
| 554 |
else() |
| 555 |
# location pointed to is outside WDR so it should be treated as a permanent symlink |
| 556 |
set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}") |
| 557 |
|
| 558 |
unset(SYMLINK_RELOCATIONS) |
| 559 |
unset(POINT_RELOCATIONS) |
| 560 |
unset(SYMLINK_RELOCATIONS_COUNT) |
| 561 |
unset(POINT_RELOCATIONS_COUNT) |
| 562 |
|
| 563 |
message(AUTHOR_WARNING "CPackRPM:Warning: Symbolic link '${F}' points to location that is outside packaging path! Link will possibly not be relocatable.") |
| 564 |
endif() |
| 565 |
|
| 566 |
if(SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT) |
| 567 |
# find matching |
| 568 |
foreach(SYMLINK_RELOCATION_PREFIX IN LISTS SYMLINK_RELOCATIONS) |
| 569 |
list(FIND POINT_RELOCATIONS "${SYMLINK_RELOCATION_PREFIX}" FOUND_INDEX) |
| 570 |
if(NOT ${FOUND_INDEX} EQUAL -1) |
| 571 |
break() |
| 572 |
endif() |
| 573 |
endforeach() |
| 574 |
|
| 575 |
if(NOT ${FOUND_INDEX} EQUAL -1) |
| 576 |
# symlinks have the same subpath |
| 577 |
if(${SYMLINK_RELOCATIONS_COUNT} EQUAL 1 AND ${POINT_RELOCATIONS_COUNT} EQUAL 1) |
| 578 |
# permanent symlink |
| 579 |
get_filename_component(SYMLINK_LOCATION_ "${F}" DIRECTORY) |
| 580 |
file(RELATIVE_PATH FINAL_PATH_ ${SYMLINK_LOCATION_} ${SYMLINK_POINT_WD_}) |
| 581 |
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}") |
| 582 |
else() |
| 583 |
# relocation subpaths |
| 584 |
cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}" |
| 585 |
"${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}") |
| 586 |
endif() |
| 587 |
else() |
| 588 |
# not on the same relocation path |
| 589 |
cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}" |
| 590 |
"${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}") |
| 591 |
endif() |
| 592 |
elseif(POINT_RELOCATIONS_COUNT) |
| 593 |
# point is relocatable |
| 594 |
cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}" |
| 595 |
"${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}") |
| 596 |
else() |
| 597 |
# is not relocatable or points to non relocatable path - permanent symlink |
| 598 |
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}") |
| 599 |
endif() |
| 600 |
endif() |
| 601 |
elseif(IS_DIRECTORY "${WDIR}/${F}") |
| 602 |
set(DIRECTIVE "%dir ") |
| 603 |
endif() |
| 604 |
|
| 605 |
make_rpm_spec_path(F_SPEC "${F}") |
| 606 |
string(APPEND INSTALL_FILES "${DIRECTIVE}${F_SPEC}\n") |
| 607 |
endforeach() |
| 608 |
|
| 609 |
if(REQUIRES_SYMLINK_RELOCATION_SCRIPT) |
| 610 |
cpack_rpm_symlink_create_relocation_script("${PACKAGE_PREFIXES}") |
| 611 |
endif() |
| 612 |
|
| 613 |
set(RPM_SYMLINK_POSTINSTALL "${RPM_SYMLINK_POSTINSTALL}" PARENT_SCOPE) |
| 614 |
set(CPACK_RPM_INSTALL_FILES "${INSTALL_FILES}" PARENT_SCOPE) |
| 615 |
endfunction() |
| 616 |
|
| 617 |
if(CMAKE_BINARY_DIR) |
| 618 |
message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.") |
| 619 |
endif() |
| 620 |
|
| 621 |
if(NOT UNIX) |
| 622 |
message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") |
| 623 |
endif() |
| 624 |
|
| 625 |
# We need to check if the binaries were compiled with debug symbols |
| 626 |
# because without them the package will be useless |
| 627 |
function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) |
| 628 |
if(NOT CPACK_BUILD_SOURCE_DIRS) |
| 629 |
message(FATAL_ERROR "CPackRPM: CPACK_BUILD_SOURCE_DIRS variable is not set!" |
| 630 |
" Required for debuginfo packaging. See documentation of" |
| 631 |
" CPACK_RPM_DEBUGINFO_PACKAGE variable for details.") |
| 632 |
endif() |
| 633 |
|
| 634 |
# With objdump we should check the debug symbols |
| 635 |
find_program(CPACK_OBJDUMP_EXECUTABLE objdump) |
| 636 |
if(NOT CPACK_OBJDUMP_EXECUTABLE) |
| 637 |
message(FATAL_ERROR "CPackRPM: objdump binary could not be found!" |
| 638 |
" Required for debuginfo packaging. See documentation of" |
| 639 |
" CPACK_RPM_DEBUGINFO_PACKAGE variable for details.") |
| 640 |
endif() |
| 641 |
|
| 642 |
# With debugedit we prepare source files list |
| 643 |
find_program(DEBUGEDIT_EXECUTABLE debugedit "/usr/lib/rpm/") |
| 644 |
if(NOT DEBUGEDIT_EXECUTABLE) |
| 645 |
message(FATAL_ERROR "CPackRPM: debugedit binary could not be found!" |
| 646 |
" Required for debuginfo packaging. See documentation of" |
| 647 |
" CPACK_RPM_DEBUGINFO_PACKAGE variable for details.") |
| 648 |
endif() |
| 649 |
|
| 650 |
unset(mkdir_list_) |
| 651 |
unset(cp_list_) |
| 652 |
unset(additional_sources_) |
| 653 |
|
| 654 |
foreach(F IN LISTS INSTALL_FILES) |
| 655 |
if(IS_DIRECTORY "${WORKING_DIR}/${F}" OR IS_SYMLINK "${WORKING_DIR}/${F}") |
| 656 |
continue() |
| 657 |
endif() |
| 658 |
|
| 659 |
execute_process(COMMAND "${CPACK_OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F} |
| 660 |
WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}" |
| 661 |
RESULT_VARIABLE OBJDUMP_EXEC_RESULT |
| 662 |
OUTPUT_VARIABLE OBJDUMP_OUT |
| 663 |
ERROR_QUIET) |
| 664 |
# Check if the given file is an executable or not |
| 665 |
if(NOT OBJDUMP_EXEC_RESULT) |
| 666 |
string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT) |
| 667 |
if(FIND_RESULT GREATER -1) |
| 668 |
set(index_ 0) |
| 669 |
foreach(source_dir_ IN LISTS CPACK_BUILD_SOURCE_DIRS) |
| 670 |
string(LENGTH "${source_dir_}" source_dir_len_) |
| 671 |
string(LENGTH "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" debuginfo_dir_len) |
| 672 |
if(source_dir_len_ LESS debuginfo_dir_len) |
| 673 |
message(FATAL_ERROR "CPackRPM: source dir path '${source_dir_}' is" |
| 674 |
" shorter than debuginfo sources dir path '${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}'!" |
| 675 |
" Source dir path must be longer than debuginfo sources dir path." |
| 676 |
" Set CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX variable to a shorter value" |
| 677 |
" or make source dir path longer." |
| 678 |
" Required for debuginfo packaging. See documentation of" |
| 679 |
" CPACK_RPM_DEBUGINFO_PACKAGE variable for details.") |
| 680 |
endif() |
| 681 |
|
| 682 |
file(REMOVE "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list") |
| 683 |
execute_process(COMMAND "${DEBUGEDIT_EXECUTABLE}" -b "${source_dir_}" -d "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" -i -l "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" "${WORKING_DIR}/${F}" |
| 684 |
RESULT_VARIABLE res_ |
| 685 |
OUTPUT_VARIABLE opt_ |
| 686 |
ERROR_VARIABLE err_ |
| 687 |
) |
| 688 |
|
| 689 |
file(STRINGS |
| 690 |
"${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" |
| 691 |
sources_) |
| 692 |
list(REMOVE_DUPLICATES sources_) |
| 693 |
|
| 694 |
foreach(source_ IN LISTS sources_) |
| 695 |
if(EXISTS "${source_dir_}/${source_}" AND NOT IS_DIRECTORY "${source_dir_}/${source_}") |
| 696 |
get_filename_component(path_part_ "${source_}" DIRECTORY) |
| 697 |
list(APPEND mkdir_list_ "%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}") |
| 698 |
list(APPEND cp_list_ "cp \"${source_dir_}/${source_}\" \"%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}\"") |
| 699 |
|
| 700 |
list(APPEND additional_sources_ "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${source_}") |
| 701 |
endif() |
| 702 |
endforeach() |
| 703 |
|
| 704 |
math(EXPR index_ "${index_} + 1") |
| 705 |
endforeach() |
| 706 |
else() |
| 707 |
message(WARNING "CPackRPM: File: ${F} does not contain debug symbols. They will possibly be missing from debuginfo package!") |
| 708 |
endif() |
| 709 |
|
| 710 |
get_file_permissions("${WORKING_DIR}/${F}" permissions_) |
| 711 |
if(NOT "OWNER_EXECUTE" IN_LIST permissions_ AND |
| 712 |
NOT "GROUP_EXECUTE" IN_LIST permissions_ AND |
| 713 |
NOT "WORLD_EXECUTE" IN_LIST permissions_) |
| 714 |
if(CPACK_RPM_INSTALL_WITH_EXEC) |
| 715 |
execute_process(COMMAND chmod a+x ${WORKING_DIR}/${F} |
| 716 |
RESULT_VARIABLE res_ |
| 717 |
ERROR_VARIABLE err_ |
| 718 |
OUTPUT_QUIET) |
| 719 |
|
| 720 |
if(res_) |
| 721 |
message(FATAL_ERROR "CPackRPM: could not apply execute permissions " |
| 722 |
"requested by CPACK_RPM_INSTALL_WITH_EXEC variable on " |
| 723 |
"'${WORKING_DIR}/${F}'! Reason: '${err_}'") |
| 724 |
endif() |
| 725 |
else() |
| 726 |
message(AUTHOR_WARNING "CPackRPM: File: ${WORKING_DIR}/${F} does not " |
| 727 |
"have execute permissions. Debuginfo symbols will not be extracted" |
| 728 |
"! Missing debuginfo may cause packaging failure. Consider setting " |
| 729 |
"execute permissions or setting 'CPACK_RPM_INSTALL_WITH_EXEC' " |
| 730 |
"variable.") |
| 731 |
endif() |
| 732 |
endif() |
| 733 |
endif() |
| 734 |
endforeach() |
| 735 |
|
| 736 |
list(LENGTH mkdir_list_ len_) |
| 737 |
if(len_) |
| 738 |
list(REMOVE_DUPLICATES mkdir_list_) |
| 739 |
unset(TMP_RPM_DEBUGINFO_INSTALL) |
| 740 |
foreach(part_ IN LISTS mkdir_list_) |
| 741 |
string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n") |
| 742 |
endforeach() |
| 743 |
endif() |
| 744 |
|
| 745 |
list(LENGTH cp_list_ len_) |
| 746 |
if(len_) |
| 747 |
list(REMOVE_DUPLICATES cp_list_) |
| 748 |
foreach(part_ IN LISTS cp_list_) |
| 749 |
string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n") |
| 750 |
endforeach() |
| 751 |
endif() |
| 752 |
|
| 753 |
if(NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS) |
| 754 |
set(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug) |
| 755 |
if(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION) |
| 756 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 757 |
message("CPackRPM:Debug: Adding ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION} to builtin omit list.") |
| 758 |
endif() |
| 759 |
list(APPEND CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS "${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION}") |
| 760 |
endif() |
| 761 |
endif() |
| 762 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 763 |
message("CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}") |
| 764 |
endif() |
| 765 |
|
| 766 |
list(LENGTH additional_sources_ len_) |
| 767 |
if(len_) |
| 768 |
list(REMOVE_DUPLICATES additional_sources_) |
| 769 |
unset(additional_sources_all_) |
| 770 |
foreach(source_ IN LISTS additional_sources_) |
| 771 |
string(REPLACE "/" ";" split_source_ " ${source_}") |
| 772 |
list(REMOVE_AT split_source_ 0) |
| 773 |
unset(tmp_path_) |
| 774 |
# Now generate all segments of the path |
| 775 |
foreach(segment_ IN LISTS split_source_) |
| 776 |
string(APPEND tmp_path_ "/${segment_}") |
| 777 |
list(APPEND additional_sources_all_ "${tmp_path_}") |
| 778 |
endforeach() |
| 779 |
endforeach() |
| 780 |
|
| 781 |
list(REMOVE_DUPLICATES additional_sources_all_) |
| 782 |
list(REMOVE_ITEM additional_sources_all_ |
| 783 |
${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}) |
| 784 |
|
| 785 |
unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES) |
| 786 |
foreach(source_ IN LISTS additional_sources_all_) |
| 787 |
string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n") |
| 788 |
endforeach() |
| 789 |
endif() |
| 790 |
|
| 791 |
set(TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE) |
| 792 |
set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}" |
| 793 |
PARENT_SCOPE) |
| 794 |
endfunction() |
| 795 |
|
| 796 |
function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME) |
| 797 |
set(FALLBACK_VAR_NAMES ${ARGN}) |
| 798 |
|
| 799 |
foreach(variable_name IN LISTS FALLBACK_VAR_NAMES) |
| 800 |
if(DEFINED ${variable_name}) |
| 801 |
set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE) |
| 802 |
break() |
| 803 |
endif() |
| 804 |
endforeach() |
| 805 |
endfunction() |
| 806 |
|
| 807 |
function(cpack_rpm_generate_package) |
| 808 |
# rpmbuild is the basic command for building RPM package |
| 809 |
# it may be a simple (symbolic) link to rpm command. |
| 810 |
find_program(RPMBUILD_EXECUTABLE rpmbuild) |
| 811 |
if(NOT RPMBUILD_EXECUTABLE) |
| 812 |
message(FATAL_ERROR "RPM package requires rpmbuild executable") |
| 813 |
endif() |
| 814 |
|
| 815 |
# rpm is used for fallback queries in some older versions, |
| 816 |
# but is not required in general. |
| 817 |
find_program(RPM_EXECUTABLE rpm) |
| 818 |
|
| 819 |
# Check version of the rpmbuild tool this would be easier to |
| 820 |
# track bugs with users and CPackRPM debug mode. |
| 821 |
# We may use RPM version in order to check for available version dependent features |
| 822 |
execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version |
| 823 |
OUTPUT_VARIABLE _TMP_VERSION |
| 824 |
ERROR_QUIET |
| 825 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 826 |
string(REGEX REPLACE "^.* " "" |
| 827 |
RPMBUILD_EXECUTABLE_VERSION |
| 828 |
${_TMP_VERSION}) |
| 829 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 830 |
message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") |
| 831 |
endif() |
| 832 |
|
| 833 |
# Display lsb_release output if DEBUG mode enable |
| 834 |
# This will help to diagnose problem with CPackRPM |
| 835 |
# because we will know on which kind of Linux we are |
| 836 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 837 |
find_program(LSB_RELEASE_EXECUTABLE lsb_release) |
| 838 |
if(LSB_RELEASE_EXECUTABLE) |
| 839 |
execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a |
| 840 |
OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT |
| 841 |
ERROR_QUIET |
| 842 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 843 |
string(REGEX REPLACE "\n" ", " |
| 844 |
LSB_RELEASE_OUTPUT |
| 845 |
${_TMP_LSB_RELEASE_OUTPUT}) |
| 846 |
else () |
| 847 |
set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!") |
| 848 |
endif() |
| 849 |
message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}") |
| 850 |
endif() |
| 851 |
|
| 852 |
# We may use RPM version in the future in order |
| 853 |
# to shut down warning about space in buildtree |
| 854 |
# some recent RPM version should support space in different places. |
| 855 |
# not checked [yet]. |
| 856 |
if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") |
| 857 |
message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") |
| 858 |
endif() |
| 859 |
|
| 860 |
# Are we packaging components ? |
| 861 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 862 |
string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER) |
| 863 |
endif() |
| 864 |
|
| 865 |
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") |
| 866 |
|
| 867 |
# |
| 868 |
# Use user-defined RPM specific variables value |
| 869 |
# or generate reasonable default value from |
| 870 |
# CPACK_xxx generic values. |
| 871 |
# The variables comes from the needed (mandatory or not) |
| 872 |
# values found in the RPM specification file aka ".spec" file. |
| 873 |
# The variables which may/should be defined are: |
| 874 |
# |
| 875 |
|
| 876 |
# CPACK_RPM_PACKAGE_SUMMARY (mandatory) |
| 877 |
|
| 878 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 879 |
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY" |
| 880 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY" |
| 881 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY") |
| 882 |
endif() |
| 883 |
|
| 884 |
if(NOT CPACK_RPM_PACKAGE_SUMMARY) |
| 885 |
if(CPACK_PACKAGE_DESCRIPTION_SUMMARY) |
| 886 |
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) |
| 887 |
else() |
| 888 |
# if neither var is defined lets use the name as summary |
| 889 |
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) |
| 890 |
endif() |
| 891 |
endif() |
| 892 |
|
| 893 |
if(NOT CPACK_RPM_PACKAGE_URL AND CPACK_PACKAGE_HOMEPAGE_URL) |
| 894 |
set(CPACK_RPM_PACKAGE_URL "${CPACK_PACKAGE_HOMEPAGE_URL}") |
| 895 |
endif() |
| 896 |
|
| 897 |
# CPACK_RPM_PACKAGE_NAME (mandatory) |
| 898 |
if(NOT CPACK_RPM_PACKAGE_NAME) |
| 899 |
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) |
| 900 |
endif() |
| 901 |
|
| 902 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 903 |
string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}" |
| 904 |
CPACK_RPM_MAIN_COMPONENT_UPPER) |
| 905 |
|
| 906 |
if(NOT CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER) |
| 907 |
string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}") |
| 908 |
|
| 909 |
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME" |
| 910 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME" |
| 911 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME") |
| 912 |
endif() |
| 913 |
endif() |
| 914 |
|
| 915 |
# CPACK_RPM_PACKAGE_VERSION (mandatory) |
| 916 |
if(NOT CPACK_RPM_PACKAGE_VERSION) |
| 917 |
if(NOT CPACK_PACKAGE_VERSION) |
| 918 |
message(FATAL_ERROR "RPM package requires a package version") |
| 919 |
endif() |
| 920 |
set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) |
| 921 |
endif() |
| 922 |
# Replace '-' in version with '_' |
| 923 |
# '-' character is an Illegal RPM version character |
| 924 |
# it is illegal because it is used to separate |
| 925 |
# RPM "Version" from RPM "Release" |
| 926 |
string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) |
| 927 |
|
| 928 |
# CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory) |
| 929 |
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE) |
| 930 |
execute_process(COMMAND uname "-m" |
| 931 |
OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE |
| 932 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 933 |
else() |
| 934 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 935 |
message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") |
| 936 |
endif() |
| 937 |
endif() |
| 938 |
|
| 939 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 940 |
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE" |
| 941 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE" |
| 942 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE") |
| 943 |
|
| 944 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 945 |
message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") |
| 946 |
endif() |
| 947 |
endif() |
| 948 |
|
| 949 |
if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch") |
| 950 |
set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}") |
| 951 |
else() |
| 952 |
set(TMP_RPM_BUILDARCH "") |
| 953 |
endif() |
| 954 |
|
| 955 |
# CPACK_RPM_PACKAGE_RELEASE |
| 956 |
# The RPM release is the numbering of the RPM package ITSELF |
| 957 |
# this is the version of the PACKAGING and NOT the version |
| 958 |
# of the CONTENT of the package. |
| 959 |
# You may well need to generate a new RPM package release |
| 960 |
# without changing the version of the packaged software. |
| 961 |
# This is the case when the packaging is buggy (not) the software :=) |
| 962 |
# If not set, 1 is a good candidate |
| 963 |
if(NOT CPACK_RPM_PACKAGE_RELEASE) |
| 964 |
set(CPACK_RPM_PACKAGE_RELEASE "1") |
| 965 |
endif() |
| 966 |
|
| 967 |
if(CPACK_RPM_PACKAGE_RELEASE_DIST) |
| 968 |
string(APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}") |
| 969 |
endif() |
| 970 |
|
| 971 |
# CPACK_RPM_PACKAGE_LICENSE |
| 972 |
if(NOT CPACK_RPM_PACKAGE_LICENSE) |
| 973 |
set(CPACK_RPM_PACKAGE_LICENSE "unknown") |
| 974 |
endif() |
| 975 |
|
| 976 |
# CPACK_RPM_PACKAGE_GROUP |
| 977 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 978 |
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP" |
| 979 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP" |
| 980 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP") |
| 981 |
endif() |
| 982 |
|
| 983 |
if(NOT CPACK_RPM_PACKAGE_GROUP) |
| 984 |
set(CPACK_RPM_PACKAGE_GROUP "unknown") |
| 985 |
endif() |
| 986 |
|
| 987 |
# CPACK_RPM_PACKAGE_VENDOR |
| 988 |
if(NOT CPACK_RPM_PACKAGE_VENDOR) |
| 989 |
if(CPACK_PACKAGE_VENDOR) |
| 990 |
set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") |
| 991 |
else() |
| 992 |
set(CPACK_RPM_PACKAGE_VENDOR "unknown") |
| 993 |
endif() |
| 994 |
endif() |
| 995 |
|
| 996 |
# CPACK_RPM_PACKAGE_SOURCE |
| 997 |
# The name of the source tarball in case we generate a source RPM |
| 998 |
|
| 999 |
# CPACK_RPM_PACKAGE_DESCRIPTION |
| 1000 |
# The variable content may be either |
| 1001 |
# - explicitly given by the user or |
| 1002 |
# - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE |
| 1003 |
# if it is defined |
| 1004 |
# - set to a default value |
| 1005 |
# |
| 1006 |
|
| 1007 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1008 |
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION" |
| 1009 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION" |
| 1010 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION" |
| 1011 |
"CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION") |
| 1012 |
endif() |
| 1013 |
|
| 1014 |
if(NOT CPACK_RPM_PACKAGE_DESCRIPTION) |
| 1015 |
if(CPACK_PACKAGE_DESCRIPTION_FILE) |
| 1016 |
file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION) |
| 1017 |
else () |
| 1018 |
set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available") |
| 1019 |
endif () |
| 1020 |
endif () |
| 1021 |
|
| 1022 |
# CPACK_RPM_COMPRESSION_TYPE |
| 1023 |
# |
| 1024 |
if (CPACK_RPM_COMPRESSION_TYPE) |
| 1025 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1026 |
message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") |
| 1027 |
endif() |
| 1028 |
if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") |
| 1029 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") |
| 1030 |
elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") |
| 1031 |
if(CPACK_THREADS GREATER "0") |
| 1032 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7T${CPACK_THREADS}.xzdio") |
| 1033 |
else() |
| 1034 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7T.xzdio") |
| 1035 |
endif() |
| 1036 |
elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") |
| 1037 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") |
| 1038 |
elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") |
| 1039 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") |
| 1040 |
elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "zstd") |
| 1041 |
if(CPACK_THREADS GREATER "0") |
| 1042 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w19T${CPACK_THREADS}.zstdio") |
| 1043 |
else() |
| 1044 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w19T0.zstdio") |
| 1045 |
endif() |
| 1046 |
else() |
| 1047 |
message(FATAL_ERROR "Specified CPACK_RPM_COMPRESSION_TYPE value is not supported: ${CPACK_RPM_COMPRESSION_TYPE}") |
| 1048 |
endif() |
| 1049 |
else() |
| 1050 |
set(CPACK_RPM_COMPRESSION_TYPE_TMP "") |
| 1051 |
endif() |
| 1052 |
|
| 1053 |
if(NOT CPACK_RPM_PACKAGE_SOURCES) |
| 1054 |
if(CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE) |
| 1055 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1056 |
message("CPackRPM:Debug: Trying to build a relocatable package") |
| 1057 |
endif() |
| 1058 |
if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) |
| 1059 |
message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") |
| 1060 |
set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) |
| 1061 |
else() |
| 1062 |
set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files) |
| 1063 |
cpack_rpm_prepare_relocation_paths() |
| 1064 |
set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) |
| 1065 |
endif() |
| 1066 |
endif() |
| 1067 |
else() |
| 1068 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1069 |
message(FATAL_ERROR "CPACK_RPM_PACKAGE_SOURCES parameter can not be used" |
| 1070 |
" in combination with CPACK_RPM_PACKAGE_COMPONENT parameter!") |
| 1071 |
endif() |
| 1072 |
|
| 1073 |
set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) # disable relocatable option if building source RPM |
| 1074 |
endif() |
| 1075 |
|
| 1076 |
execute_process( |
| 1077 |
COMMAND "${RPMBUILD_EXECUTABLE}" --querytags |
| 1078 |
OUTPUT_VARIABLE RPMBUILD_TAG_LIST |
| 1079 |
RESULT_VARIABLE RPMBUILD_QUERYTAGS_SUCCESS |
| 1080 |
ERROR_QUIET |
| 1081 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 1082 |
# In some versions of RPM, rpmbuild does not understand --querytags parameter, |
| 1083 |
# but rpm does. |
| 1084 |
if(NOT RPMBUILD_QUERYTAGS_SUCCESS EQUAL 0 AND RPM_EXECUTABLE) |
| 1085 |
execute_process( |
| 1086 |
COMMAND "${RPM_EXECUTABLE}" --querytags |
| 1087 |
OUTPUT_VARIABLE RPMBUILD_TAG_LIST |
| 1088 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 1089 |
endif() |
| 1090 |
string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}") |
| 1091 |
|
| 1092 |
# In some versions of RPM, weak dependency tags are present in the --querytags |
| 1093 |
# list, but unsupported by rpmbuild. A different method must be used to check |
| 1094 |
# if they are supported. |
| 1095 |
if(RPM_EXECUTABLE) |
| 1096 |
execute_process( |
| 1097 |
COMMAND "${RPM_EXECUTABLE}" --suggests |
| 1098 |
ERROR_QUIET |
| 1099 |
RESULT_VARIABLE RPM_SUGGESTS_RESULT) |
| 1100 |
if(NOT RPM_SUGGESTS_RESULT EQUAL 0) |
| 1101 |
foreach(_WEAK_DEP SUGGESTS RECOMMENDS SUPPLEMENTS ENHANCES) |
| 1102 |
list(REMOVE_ITEM RPMBUILD_TAG_LIST ${_WEAK_DEP}) |
| 1103 |
endforeach() |
| 1104 |
endif() |
| 1105 |
endif() |
| 1106 |
|
| 1107 |
if(CPACK_RPM_PACKAGE_EPOCH) |
| 1108 |
set(TMP_RPM_EPOCH "Epoch: ${CPACK_RPM_PACKAGE_EPOCH}") |
| 1109 |
endif() |
| 1110 |
|
| 1111 |
# Check if additional fields for RPM spec header are given |
| 1112 |
# There may be some COMPONENT specific variables as well |
| 1113 |
# If component specific var is not provided we use the global one |
| 1114 |
# for each component |
| 1115 |
foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS RECOMMENDS SUPPLEMENTS ENHANCES PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) |
| 1116 |
|
| 1117 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1118 |
message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") |
| 1119 |
endif() |
| 1120 |
|
| 1121 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1122 |
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}" |
| 1123 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}" |
| 1124 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}") |
| 1125 |
endif() |
| 1126 |
|
| 1127 |
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) |
| 1128 |
# Prefix can be replaced by Prefixes but the old version still works so we'll ignore it for now |
| 1129 |
# Requires* is a special case because it gets transformed to Requires(pre/post/preun/postun) |
| 1130 |
# Auto* is a special case because the tags can not be queried by querytags rpmbuild flag |
| 1131 |
set(special_case_tags_ PREFIX REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN AUTOPROV AUTOREQ AUTOREQPROV) |
| 1132 |
if(NOT _RPM_SPEC_HEADER IN_LIST RPMBUILD_TAG_LIST AND NOT _RPM_SPEC_HEADER IN_LIST special_case_tags_) |
| 1133 |
message(AUTHOR_WARNING "CPackRPM:Warning: ${_RPM_SPEC_HEADER} not " |
| 1134 |
"supported in provided rpmbuild. Tag will not be used.") |
| 1135 |
continue() |
| 1136 |
endif() |
| 1137 |
|
| 1138 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1139 |
message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") |
| 1140 |
endif() |
| 1141 |
|
| 1142 |
set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) |
| 1143 |
endif() |
| 1144 |
|
| 1145 |
# Treat the RPM Spec keyword iff it has been properly defined |
| 1146 |
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) |
| 1147 |
# Transform NAME --> Name e.g. PROVIDES --> Provides |
| 1148 |
# The Upper-case first letter and lowercase tail is the |
| 1149 |
# appropriate value required in the final RPM spec file. |
| 1150 |
string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL) |
| 1151 |
string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) |
| 1152 |
string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) |
| 1153 |
string(APPEND _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_TAIL}") |
| 1154 |
# The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file. |
| 1155 |
set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) |
| 1156 |
list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND) |
| 1157 |
if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1) |
| 1158 |
string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}") |
| 1159 |
string(APPEND _PACKAGE_HEADER_NAME ")") |
| 1160 |
endif() |
| 1161 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1162 |
message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") |
| 1163 |
endif() |
| 1164 |
set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") |
| 1165 |
unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) |
| 1166 |
endif() |
| 1167 |
endforeach() |
| 1168 |
|
| 1169 |
# CPACK_RPM_SPEC_INSTALL_POST |
| 1170 |
# May be used to define a RPM post installation script |
| 1171 |
# for example setting it to "/bin/true" may prevent |
| 1172 |
# rpmbuild from stripping binaries. |
| 1173 |
if(CPACK_RPM_SPEC_INSTALL_POST) |
| 1174 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1175 |
message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}") |
| 1176 |
endif() |
| 1177 |
set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") |
| 1178 |
endif() |
| 1179 |
|
| 1180 |
# CPACK_RPM_REQUIRES_EXCLUDE_FROM |
| 1181 |
# May be defined to keep the dependency generator from |
| 1182 |
# scanning specific files or directories for deps. |
| 1183 |
if(CPACK_RPM_REQUIRES_EXCLUDE_FROM) |
| 1184 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1185 |
message("CPackRPM:Debug: User defined CPACK_RPM_REQUIRES_EXCLUDE_FROM = ${CPACK_RPM_REQUIRES_EXCLUDE_FROM}") |
| 1186 |
endif() |
| 1187 |
set(TMP_RPM_REQUIRES_EXCLUDE_FROM "%global __requires_exclude_from ${CPACK_RPM_REQUIRES_EXCLUDE_FROM}") |
| 1188 |
endif() |
| 1189 |
|
| 1190 |
# CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE) |
| 1191 |
# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE) |
| 1192 |
# CPACK_RPM_POST_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE) |
| 1193 |
# May be used to embed a post installation/uninstallation/transaction script in the spec file. |
| 1194 |
# The referred script file(s) will be read and directly |
| 1195 |
# put after the %post or %postun or %posttrans section |
| 1196 |
# ---------------------------------------------------------------- |
| 1197 |
# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE) |
| 1198 |
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE) |
| 1199 |
# CPACK_RPM_PRE_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_TRANS_SCRIPT_FILE) |
| 1200 |
# May be used to embed a pre installation/uninstallation/transaction script in the spec file. |
| 1201 |
# The referred script file(s) will be read and directly |
| 1202 |
# put after the %pre or %preun or %pretrans section |
| 1203 |
foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL" "TRANS") |
| 1204 |
foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST") |
| 1205 |
set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE" |
| 1206 |
"${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}") |
| 1207 |
|
| 1208 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1209 |
cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE" |
| 1210 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE" |
| 1211 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE") |
| 1212 |
endif() |
| 1213 |
|
| 1214 |
# Handle file if it has been specified |
| 1215 |
if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE) |
| 1216 |
if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}) |
| 1217 |
file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE} |
| 1218 |
"CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}") |
| 1219 |
else() |
| 1220 |
message("CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exist - ignoring") |
| 1221 |
endif() |
| 1222 |
else() |
| 1223 |
# reset SPEC var value if no file has been specified |
| 1224 |
# (either globally or component-wise) |
| 1225 |
set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "") |
| 1226 |
endif() |
| 1227 |
endforeach() |
| 1228 |
endforeach() |
| 1229 |
|
| 1230 |
# CPACK_RPM_CHANGELOG_FILE |
| 1231 |
# May be used to embed a changelog in the spec file. |
| 1232 |
# The referred file will be read and directly put after the %changelog section |
| 1233 |
if(CPACK_RPM_CHANGELOG_FILE) |
| 1234 |
if(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) |
| 1235 |
file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG) |
| 1236 |
else() |
| 1237 |
message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exist - ignoring") |
| 1238 |
endif() |
| 1239 |
else() |
| 1240 |
set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <[email protected]> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)") |
| 1241 |
endif() |
| 1242 |
|
| 1243 |
# CPACK_RPM_SPEC_MORE_DEFINE |
| 1244 |
# This is a generated spec rpm file spaceholder |
| 1245 |
if(CPACK_RPM_SPEC_MORE_DEFINE) |
| 1246 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1247 |
message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}") |
| 1248 |
endif() |
| 1249 |
endif() |
| 1250 |
|
| 1251 |
# Now we may create the RPM build tree structure |
| 1252 |
set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") |
| 1253 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1254 |
message("CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") |
| 1255 |
endif() |
| 1256 |
# Prepare RPM build tree |
| 1257 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}) |
| 1258 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp) |
| 1259 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD) |
| 1260 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS) |
| 1261 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES) |
| 1262 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS) |
| 1263 |
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS) |
| 1264 |
|
| 1265 |
# it seems rpmbuild can't handle spaces in the path |
| 1266 |
# neither escaping (as below) nor putting quotes around the path seem to help |
| 1267 |
#string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") |
| 1268 |
set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") |
| 1269 |
|
| 1270 |
cpack_rpm_prepare_content_list() |
| 1271 |
|
| 1272 |
# In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT> |
| 1273 |
# into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL |
| 1274 |
# otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES |
| 1275 |
# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling |
| 1276 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1277 |
if(CPACK_ABSOLUTE_DESTINATION_FILES) |
| 1278 |
cpack_rpm_variable_fallback("COMPONENT_FILES_TAG" |
| 1279 |
"CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}" |
| 1280 |
"CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}") |
| 1281 |
set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") |
| 1282 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1283 |
message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") |
| 1284 |
message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") |
| 1285 |
endif() |
| 1286 |
endif() |
| 1287 |
else() |
| 1288 |
if(CPACK_ABSOLUTE_DESTINATION_FILES) |
| 1289 |
set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}") |
| 1290 |
endif() |
| 1291 |
endif() |
| 1292 |
|
| 1293 |
# In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST. |
| 1294 |
set(CPACK_RPM_USER_FILELIST_INTERNAL "") |
| 1295 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1296 |
cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL" |
| 1297 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST" |
| 1298 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST") |
| 1299 |
|
| 1300 |
if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL) |
| 1301 |
message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") |
| 1302 |
message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") |
| 1303 |
endif() |
| 1304 |
elseif(CPACK_RPM_USER_FILELIST) |
| 1305 |
set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}") |
| 1306 |
endif() |
| 1307 |
|
| 1308 |
# Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL |
| 1309 |
# Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL |
| 1310 |
# or CPACK_RPM_INSTALL_FILES, |
| 1311 |
# hence it must be done before these auto-generated lists are processed. |
| 1312 |
if(CPACK_RPM_USER_FILELIST_INTERNAL) |
| 1313 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1314 |
message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") |
| 1315 |
endif() |
| 1316 |
|
| 1317 |
# Create CMake list from CPACK_RPM_INSTALL_FILES |
| 1318 |
string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) |
| 1319 |
string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST |
| 1320 |
"${CPACK_RPM_INSTALL_FILES_LIST}") |
| 1321 |
string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST |
| 1322 |
"${CPACK_RPM_INSTALL_FILES_LIST}") |
| 1323 |
|
| 1324 |
set(CPACK_RPM_USER_INSTALL_FILES "") |
| 1325 |
foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL) |
| 1326 |
string(REGEX REPLACE "%[A-Za-z]+(\\([^()]*\\))? " "" F_PATH ${F}) |
| 1327 |
string(REGEX MATCH "(%[A-Za-z]+(\\([^()]*\\))? )*" F_PREFIX ${F}) |
| 1328 |
string(STRIP ${F_PREFIX} F_PREFIX) |
| 1329 |
|
| 1330 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1331 |
message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>") |
| 1332 |
endif() |
| 1333 |
if(F_PREFIX) |
| 1334 |
string(APPEND F_PREFIX " ") |
| 1335 |
endif() |
| 1336 |
# Rebuild the user list file |
| 1337 |
make_rpm_spec_path(F_SPEC "${F_PATH}") |
| 1338 |
string(APPEND CPACK_RPM_USER_INSTALL_FILES "${F_PREFIX}${F_SPEC}\n") |
| 1339 |
|
| 1340 |
# Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL |
| 1341 |
list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH}) |
| 1342 |
# ABSOLUTE destination files list may not exists at all |
| 1343 |
if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) |
| 1344 |
list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) |
| 1345 |
endif() |
| 1346 |
endforeach() |
| 1347 |
|
| 1348 |
# Rebuild CPACK_RPM_INSTALL_FILES |
| 1349 |
set(CPACK_RPM_INSTALL_FILES "") |
| 1350 |
foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) |
| 1351 |
make_rpm_spec_path(F_SPEC "${F}") |
| 1352 |
string(APPEND CPACK_RPM_INSTALL_FILES "${F_SPEC}\n") |
| 1353 |
endforeach() |
| 1354 |
else() |
| 1355 |
set(CPACK_RPM_USER_INSTALL_FILES "") |
| 1356 |
endif() |
| 1357 |
|
| 1358 |
if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) |
| 1359 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1360 |
message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}") |
| 1361 |
endif() |
| 1362 |
# Remove trailing space |
| 1363 |
string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) |
| 1364 |
# Transform endline separated - string into CMake List |
| 1365 |
string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") |
| 1366 |
# Remove unnecessary quotes |
| 1367 |
string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") |
| 1368 |
# Remove ABSOLUTE install file from INSTALL FILE LIST |
| 1369 |
list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}) |
| 1370 |
# Rebuild INSTALL_FILES |
| 1371 |
set(CPACK_RPM_INSTALL_FILES "") |
| 1372 |
foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) |
| 1373 |
make_rpm_spec_path(F_SPEC "${F}") |
| 1374 |
string(APPEND CPACK_RPM_INSTALL_FILES "${F_SPEC}\n") |
| 1375 |
endforeach() |
| 1376 |
# Build ABSOLUTE_INSTALL_FILES |
| 1377 |
set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") |
| 1378 |
foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) |
| 1379 |
make_rpm_spec_path(F_SPEC "${F}") |
| 1380 |
string(APPEND CPACK_RPM_ABSOLUTE_INSTALL_FILES "%config ${F_SPEC}\n") |
| 1381 |
endforeach() |
| 1382 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1383 |
message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}") |
| 1384 |
message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}") |
| 1385 |
endif() |
| 1386 |
else() |
| 1387 |
# reset vars in order to avoid leakage of value(s) from one component to another |
| 1388 |
set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") |
| 1389 |
endif() |
| 1390 |
|
| 1391 |
cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_PACKAGE" |
| 1392 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_PACKAGE" |
| 1393 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_PACKAGE" |
| 1394 |
"CPACK_RPM_DEBUGINFO_PACKAGE") |
| 1395 |
if(CPACK_RPM_DEBUGINFO_PACKAGE OR (CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND NOT GENERATE_SPEC_PARTS)) |
| 1396 |
cpack_rpm_variable_fallback("CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX" |
| 1397 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_BUILD_SOURCE_DIRS_PREFIX" |
| 1398 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_BUILD_SOURCE_DIRS_PREFIX" |
| 1399 |
"CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX") |
| 1400 |
if(NOT CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX) |
| 1401 |
set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") |
| 1402 |
endif() |
| 1403 |
|
| 1404 |
# handle cases where path contains extra slashes (e.g. /a//b/ instead of |
| 1405 |
# /a/b) |
| 1406 |
get_filename_component(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX |
| 1407 |
"${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}" ABSOLUTE) |
| 1408 |
|
| 1409 |
if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS) |
| 1410 |
file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files" |
| 1411 |
"${CPACK_RPM_INSTALL_FILES}") |
| 1412 |
else() |
| 1413 |
if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND CPACK_RPM_PACKAGE_COMPONENT) |
| 1414 |
# this part is only required by components packaging - with monolithic |
| 1415 |
# packages we can be certain that there are no other components present |
| 1416 |
# so CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is a noop |
| 1417 |
if(CPACK_RPM_DEBUGINFO_PACKAGE) |
| 1418 |
# only add current package files to debuginfo list if debuginfo |
| 1419 |
# generation is enabled for current package |
| 1420 |
string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_) |
| 1421 |
string(REPLACE "\n" ";" install_files_ "${install_files_}") |
| 1422 |
string(REPLACE "\"" "" install_files_ "${install_files_}") |
| 1423 |
else() |
| 1424 |
unset(install_files_) |
| 1425 |
endif() |
| 1426 |
|
| 1427 |
file(GLOB files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.files") |
| 1428 |
|
| 1429 |
foreach(f_ IN LISTS files_) |
| 1430 |
file(READ "${f_}" tmp_) |
| 1431 |
string(APPEND install_files_ ";${tmp_}") |
| 1432 |
endforeach() |
| 1433 |
|
| 1434 |
# if there were other components/groups so we need to move files from them |
| 1435 |
# to current component otherwise those files won't be found |
| 1436 |
file(GLOB components_ LIST_DIRECTORIES true RELATIVE |
| 1437 |
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" |
| 1438 |
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/*") |
| 1439 |
foreach(component_ IN LISTS components_) |
| 1440 |
string(TOUPPER "${component_}" component_dir_upper_) |
| 1441 |
if(component_dir_upper_ STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER) |
| 1442 |
# skip current component |
| 1443 |
continue() |
| 1444 |
endif() |
| 1445 |
|
| 1446 |
file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES true RELATIVE |
| 1447 |
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}" |
| 1448 |
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*") |
| 1449 |
|
| 1450 |
foreach(f_ IN LISTS files_for_move_) |
| 1451 |
set(src_file_ |
| 1452 |
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}") |
| 1453 |
|
| 1454 |
if(IS_DIRECTORY "${src_file_}") |
| 1455 |
file(MAKE_DIRECTORY "${WDIR}/${f_}") |
| 1456 |
continue() |
| 1457 |
endif() |
| 1458 |
|
| 1459 |
get_filename_component(dir_path_ "${f_}" DIRECTORY) |
| 1460 |
|
| 1461 |
# check that we are not overriding an existing file that doesn't |
| 1462 |
# match the file that we want to copy |
| 1463 |
if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}") |
| 1464 |
execute_process( |
| 1465 |
COMMAND ${CMAKE_COMMAND} -E compare_files "${src_file_}" "${WDIR}/${f_}" |
| 1466 |
RESULT_VARIABLE res_ |
| 1467 |
) |
| 1468 |
if(res_) |
| 1469 |
message(FATAL_ERROR "CPackRPM:Error: File on path '${WDIR}/${f_}'" |
| 1470 |
" already exists but is a different than the one in component" |
| 1471 |
" '${component_}'! Packages will not be generated.") |
| 1472 |
endif() |
| 1473 |
endif() |
| 1474 |
|
| 1475 |
file(MAKE_DIRECTORY "${WDIR}/${dir_path_}") |
| 1476 |
file(RENAME "${src_file_}" |
| 1477 |
"${WDIR}/${f_}") |
| 1478 |
endforeach() |
| 1479 |
endforeach() |
| 1480 |
|
| 1481 |
cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}") |
| 1482 |
else() |
| 1483 |
string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_) |
| 1484 |
string(REPLACE "\n" ";" install_files_ "${install_files_}") |
| 1485 |
string(REPLACE "\"" "" install_files_ "${install_files_}") |
| 1486 |
|
| 1487 |
cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}") |
| 1488 |
endif() |
| 1489 |
|
| 1490 |
if(TMP_DEBUGINFO_ADDITIONAL_SOURCES) |
| 1491 |
set(TMP_RPM_DEBUGINFO " |
| 1492 |
# Modified version of %%debug_package macro |
| 1493 |
# defined in /usr/lib/rpm/macros as that one |
| 1494 |
# can't handle injection of extra source files. |
| 1495 |
%ifnarch noarch |
| 1496 |
%global __debug_package 1 |
| 1497 |
%package debuginfo |
| 1498 |
Summary: Debug information for package %{name} |
| 1499 |
Group: Development/Debug |
| 1500 |
AutoReqProv: 0 |
| 1501 |
%description debuginfo |
| 1502 |
This package provides debug information for package %{name}. |
| 1503 |
Debug information is useful when developing applications that use this |
| 1504 |
package or when debugging this package. |
| 1505 |
%files debuginfo -f debugfiles.list |
| 1506 |
%defattr(-,root,root) |
| 1507 |
${TMP_DEBUGINFO_ADDITIONAL_SOURCES} |
| 1508 |
%endif |
| 1509 |
") |
| 1510 |
elseif(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE) |
| 1511 |
message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested" |
| 1512 |
" but will not be generated as no source files were found!") |
| 1513 |
else() |
| 1514 |
message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested" |
| 1515 |
" but will not be generated as no source files were found! Component: '" |
| 1516 |
"${CPACK_RPM_PACKAGE_COMPONENT}'.") |
| 1517 |
endif() |
| 1518 |
endif() |
| 1519 |
endif() |
| 1520 |
|
| 1521 |
# Prepare install files |
| 1522 |
cpack_rpm_prepare_install_files( |
| 1523 |
"${CPACK_RPM_INSTALL_FILES}" |
| 1524 |
"${WDIR}" |
| 1525 |
"${RPM_USED_PACKAGE_PREFIXES}" |
| 1526 |
"${CPACK_RPM_PACKAGE_RELOCATABLE}" |
| 1527 |
) |
| 1528 |
|
| 1529 |
# set default user and group |
| 1530 |
foreach(_PERM_TYPE "USER" "GROUP") |
| 1531 |
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}) |
| 1532 |
set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}}") |
| 1533 |
elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE}) |
| 1534 |
set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_DEFAULT_${_PERM_TYPE}}") |
| 1535 |
else() |
| 1536 |
set(TMP_DEFAULT_${_PERM_TYPE} "root") |
| 1537 |
endif() |
| 1538 |
endforeach() |
| 1539 |
|
| 1540 |
# set default file and dir permissions |
| 1541 |
foreach(_PERM_TYPE "FILE" "DIR") |
| 1542 |
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS) |
| 1543 |
get_unix_permissions_octal_notation("CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS") |
| 1544 |
set(_PERMISSIONS_VAR "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS") |
| 1545 |
elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS) |
| 1546 |
get_unix_permissions_octal_notation("CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS") |
| 1547 |
set(_PERMISSIONS_VAR "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS") |
| 1548 |
else() |
| 1549 |
set(TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS "-") |
| 1550 |
endif() |
| 1551 |
endforeach() |
| 1552 |
|
| 1553 |
# The name of the final spec file to be used by rpmbuild |
| 1554 |
set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec") |
| 1555 |
|
| 1556 |
# Print out some debug information if we were asked for that |
| 1557 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1558 |
message("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") |
| 1559 |
message("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") |
| 1560 |
message("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") |
| 1561 |
message("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") |
| 1562 |
message("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") |
| 1563 |
message("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") |
| 1564 |
message("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") |
| 1565 |
message("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") |
| 1566 |
message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") |
| 1567 |
endif() |
| 1568 |
|
| 1569 |
# |
| 1570 |
# USER generated/provided spec file handling. |
| 1571 |
# |
| 1572 |
|
| 1573 |
# We can have a component specific spec file. |
| 1574 |
if(CPACK_RPM_PACKAGE_COMPONENT) |
| 1575 |
cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE" |
| 1576 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE" |
| 1577 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE") |
| 1578 |
endif() |
| 1579 |
|
| 1580 |
cpack_rpm_variable_fallback("CPACK_RPM_FILE_NAME" |
| 1581 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_FILE_NAME" |
| 1582 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_FILE_NAME" |
| 1583 |
"CPACK_RPM_FILE_NAME") |
| 1584 |
if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") |
| 1585 |
if(CPACK_RPM_FILE_NAME) |
| 1586 |
if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm") |
| 1587 |
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}.rpm") |
| 1588 |
endif() |
| 1589 |
else() |
| 1590 |
# old file name format for back compatibility |
| 1591 |
string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}" |
| 1592 |
CPACK_RPM_MAIN_COMPONENT_UPPER) |
| 1593 |
|
| 1594 |
if(CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER) |
| 1595 |
# this is the main component so ignore the component filename part |
| 1596 |
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.rpm") |
| 1597 |
else() |
| 1598 |
set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") |
| 1599 |
endif() |
| 1600 |
endif() |
| 1601 |
# else example: |
| 1602 |
#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") |
| 1603 |
|
| 1604 |
if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS) |
| 1605 |
string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" expected_filename_) |
| 1606 |
|
| 1607 |
file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.rpm_name" |
| 1608 |
"${expected_filename_};${CPACK_RPM_FILE_NAME}") |
| 1609 |
elseif(NOT CPACK_RPM_DEBUGINFO_PACKAGE) |
| 1610 |
set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}") |
| 1611 |
endif() |
| 1612 |
endif() |
| 1613 |
|
| 1614 |
if(CPACK_RPM_PACKAGE_SOURCES) # source rpm |
| 1615 |
set(archive_name_ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}") |
| 1616 |
|
| 1617 |
execute_process( |
| 1618 |
COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${CPACK_RPM_DIRECTORY}/SOURCES/${archive_name_}.tar.gz" "${CPACK_PACKAGE_FILE_NAME}" |
| 1619 |
WORKING_DIRECTORY ${CPACK_RPM_DIRECTORY} |
| 1620 |
) |
| 1621 |
set(TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz") |
| 1622 |
|
| 1623 |
if(CPACK_RPM_BUILDREQUIRES) |
| 1624 |
set(TMP_RPM_BUILD_REQUIRES "BuildRequires: ${CPACK_RPM_BUILDREQUIRES}") |
| 1625 |
endif() |
| 1626 |
|
| 1627 |
# Disable debuginfo packages - srpm generates invalid packages due to |
| 1628 |
# releasing control to cpack to generate binary packages. |
| 1629 |
# Note however that this doesn't prevent cpack to generate debuginfo |
| 1630 |
# packages when run from srpm with --rebuild. |
| 1631 |
set(TMP_RPM_DISABLE_DEBUGINFO "%define debug_package %{nil}") |
| 1632 |
|
| 1633 |
if(NOT CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX) |
| 1634 |
set(CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/") |
| 1635 |
endif() |
| 1636 |
|
| 1637 |
set(TMP_RPM_BUILD |
| 1638 |
" |
| 1639 |
%build |
| 1640 |
mkdir cpack_rpm_build_dir |
| 1641 |
cd cpack_rpm_build_dir |
| 1642 |
'${CMAKE_COMMAND}' ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME} |
| 1643 |
make %{?_smp_mflags}" # %{?_smp_mflags} -> -j option |
| 1644 |
) |
| 1645 |
set(TMP_RPM_INSTALL |
| 1646 |
" |
| 1647 |
cd cpack_rpm_build_dir |
| 1648 |
cpack -G RPM |
| 1649 |
mv *.rpm %_rpmdir" |
| 1650 |
) |
| 1651 |
set(TMP_RPM_PREP "%setup -c") |
| 1652 |
|
| 1653 |
set(RPMBUILD_FLAGS "-bs") |
| 1654 |
|
| 1655 |
file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in |
| 1656 |
"# Restore old style debuginfo creation for rpm >= 4.14. |
| 1657 |
%undefine _debugsource_packages |
| 1658 |
%undefine _debuginfo_subpackages |
| 1659 |
|
| 1660 |
# -*- rpm-spec -*- |
| 1661 |
BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@ |
| 1662 |
Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ |
| 1663 |
Name: \@CPACK_RPM_PACKAGE_NAME\@ |
| 1664 |
Version: \@CPACK_RPM_PACKAGE_VERSION\@ |
| 1665 |
Release: \@CPACK_RPM_PACKAGE_RELEASE\@ |
| 1666 |
License: \@CPACK_RPM_PACKAGE_LICENSE\@ |
| 1667 |
Group: \@CPACK_RPM_PACKAGE_GROUP\@ |
| 1668 |
Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ |
| 1669 |
|
| 1670 |
\@TMP_RPM_SOURCE\@ |
| 1671 |
\@TMP_RPM_BUILD_REQUIRES\@ |
| 1672 |
\@TMP_RPM_BUILDARCH\@ |
| 1673 |
\@TMP_RPM_PREFIXES\@ |
| 1674 |
|
| 1675 |
\@TMP_RPM_DISABLE_DEBUGINFO\@ |
| 1676 |
|
| 1677 |
%define _rpmdir %_topdir/RPMS |
| 1678 |
%define _srcrpmdir %_topdir/SRPMS |
| 1679 |
\@FILE_NAME_DEFINE\@ |
| 1680 |
%define _unpackaged_files_terminate_build 0 |
| 1681 |
\@TMP_RPM_SPEC_INSTALL_POST\@ |
| 1682 |
\@TMP_RPM_REQUIRES_EXCLUDE_FROM\@ |
| 1683 |
\@CPACK_RPM_SPEC_MORE_DEFINE\@ |
| 1684 |
\@CPACK_RPM_COMPRESSION_TYPE_TMP\@ |
| 1685 |
|
| 1686 |
%description |
| 1687 |
\@CPACK_RPM_PACKAGE_DESCRIPTION\@ |
| 1688 |
|
| 1689 |
# This is a shortcutted spec file generated by CMake RPM generator |
| 1690 |
# we skip _install step because CPack does that for us. |
| 1691 |
# We do only save CPack installed tree in _prepr |
| 1692 |
# and then restore it in build. |
| 1693 |
%prep |
| 1694 |
\@TMP_RPM_PREP\@ |
| 1695 |
|
| 1696 |
\@TMP_RPM_BUILD\@ |
| 1697 |
|
| 1698 |
#p build |
| 1699 |
|
| 1700 |
%install |
| 1701 |
\@TMP_RPM_INSTALL\@ |
| 1702 |
|
| 1703 |
%clean |
| 1704 |
|
| 1705 |
%changelog |
| 1706 |
\@CPACK_RPM_SPEC_CHANGELOG\@ |
| 1707 |
" |
| 1708 |
) |
| 1709 |
|
| 1710 |
elseif(GENERATE_SPEC_PARTS) # binary rpm with single debuginfo package |
| 1711 |
|
| 1712 |
set_spec_scripts("${CPACK_RPM_PACKAGE_NAME}") |
| 1713 |
|
| 1714 |
file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in |
| 1715 |
"# -*- rpm-spec -*- |
| 1716 |
%package -n \@CPACK_RPM_PACKAGE_NAME\@ |
| 1717 |
Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ |
| 1718 |
Version: \@CPACK_RPM_PACKAGE_VERSION\@ |
| 1719 |
Release: \@CPACK_RPM_PACKAGE_RELEASE\@ |
| 1720 |
License: \@CPACK_RPM_PACKAGE_LICENSE\@ |
| 1721 |
Group: \@CPACK_RPM_PACKAGE_GROUP\@ |
| 1722 |
Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ |
| 1723 |
|
| 1724 |
\@TMP_RPM_URL\@ |
| 1725 |
\@TMP_RPM_REQUIRES\@ |
| 1726 |
\@TMP_RPM_REQUIRES_PRE\@ |
| 1727 |
\@TMP_RPM_REQUIRES_POST\@ |
| 1728 |
\@TMP_RPM_REQUIRES_PREUN\@ |
| 1729 |
\@TMP_RPM_REQUIRES_POSTUN\@ |
| 1730 |
\@TMP_RPM_PROVIDES\@ |
| 1731 |
\@TMP_RPM_OBSOLETES\@ |
| 1732 |
\@TMP_RPM_CONFLICTS\@ |
| 1733 |
\@TMP_RPM_RECOMMENDS\@ |
| 1734 |
\@TMP_RPM_SUGGESTS\@ |
| 1735 |
\@TMP_RPM_SUPPLEMENTS\@ |
| 1736 |
\@TMP_RPM_ENHANCES\@ |
| 1737 |
\@TMP_RPM_AUTOPROV\@ |
| 1738 |
\@TMP_RPM_AUTOREQ\@ |
| 1739 |
\@TMP_RPM_AUTOREQPROV\@ |
| 1740 |
\@TMP_RPM_BUILDARCH\@ |
| 1741 |
\@TMP_RPM_PREFIXES\@ |
| 1742 |
\@TMP_RPM_EPOCH\@ |
| 1743 |
|
| 1744 |
%description -n \@CPACK_RPM_PACKAGE_NAME\@ |
| 1745 |
\@CPACK_RPM_PACKAGE_DESCRIPTION\@ |
| 1746 |
|
| 1747 |
\@post_\@ |
| 1748 |
\@posttrans_\@ |
| 1749 |
\@postun_\@ |
| 1750 |
\@pre_\@ |
| 1751 |
\@pretrans_\@ |
| 1752 |
\@preun_\@ |
| 1753 |
|
| 1754 |
%files -n \@CPACK_RPM_PACKAGE_NAME\@ |
| 1755 |
%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@) |
| 1756 |
\@CPACK_RPM_INSTALL_FILES\@ |
| 1757 |
\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@ |
| 1758 |
\@CPACK_RPM_USER_INSTALL_FILES\@ |
| 1759 |
" |
| 1760 |
) |
| 1761 |
|
| 1762 |
else() # binary rpm |
| 1763 |
if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE) |
| 1764 |
# find generated spec file and take its name |
| 1765 |
file(GLOB spec_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.spec") |
| 1766 |
|
| 1767 |
foreach(f_ IN LISTS spec_files_) |
| 1768 |
file(READ "${f_}" tmp_) |
| 1769 |
string(APPEND TMP_OTHER_COMPONENTS "\n${tmp_}\n") |
| 1770 |
endforeach() |
| 1771 |
endif() |
| 1772 |
|
| 1773 |
# We should generate a USER spec file template: |
| 1774 |
# - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE |
| 1775 |
# - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE |
| 1776 |
set(RPMBUILD_FLAGS "-bb") |
| 1777 |
if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) |
| 1778 |
|
| 1779 |
set_spec_scripts("") |
| 1780 |
|
| 1781 |
file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in |
| 1782 |
"# Restore old style debuginfo creation for rpm >= 4.14. |
| 1783 |
%undefine _debugsource_packages |
| 1784 |
%undefine _debuginfo_subpackages |
| 1785 |
|
| 1786 |
# -*- rpm-spec -*- |
| 1787 |
BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ |
| 1788 |
Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ |
| 1789 |
Name: \@CPACK_RPM_PACKAGE_NAME\@ |
| 1790 |
Version: \@CPACK_RPM_PACKAGE_VERSION\@ |
| 1791 |
Release: \@CPACK_RPM_PACKAGE_RELEASE\@ |
| 1792 |
License: \@CPACK_RPM_PACKAGE_LICENSE\@ |
| 1793 |
Group: \@CPACK_RPM_PACKAGE_GROUP\@ |
| 1794 |
Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ |
| 1795 |
|
| 1796 |
\@TMP_RPM_URL\@ |
| 1797 |
\@TMP_RPM_REQUIRES\@ |
| 1798 |
\@TMP_RPM_REQUIRES_PRE\@ |
| 1799 |
\@TMP_RPM_REQUIRES_POST\@ |
| 1800 |
\@TMP_RPM_REQUIRES_PREUN\@ |
| 1801 |
\@TMP_RPM_REQUIRES_POSTUN\@ |
| 1802 |
\@TMP_RPM_PROVIDES\@ |
| 1803 |
\@TMP_RPM_OBSOLETES\@ |
| 1804 |
\@TMP_RPM_CONFLICTS\@ |
| 1805 |
\@TMP_RPM_RECOMMENDS\@ |
| 1806 |
\@TMP_RPM_SUGGESTS\@ |
| 1807 |
\@TMP_RPM_SUPPLEMENTS\@ |
| 1808 |
\@TMP_RPM_ENHANCES\@ |
| 1809 |
\@TMP_RPM_AUTOPROV\@ |
| 1810 |
\@TMP_RPM_AUTOREQ\@ |
| 1811 |
\@TMP_RPM_AUTOREQPROV\@ |
| 1812 |
\@TMP_RPM_BUILDARCH\@ |
| 1813 |
\@TMP_RPM_PREFIXES\@ |
| 1814 |
\@TMP_RPM_EPOCH\@ |
| 1815 |
|
| 1816 |
\@TMP_RPM_DEBUGINFO\@ |
| 1817 |
|
| 1818 |
%define _rpmdir %_topdir/RPMS |
| 1819 |
%define _srcrpmdir %_topdir/SRPMS |
| 1820 |
\@FILE_NAME_DEFINE\@ |
| 1821 |
%define _unpackaged_files_terminate_build 0 |
| 1822 |
\@TMP_RPM_SPEC_INSTALL_POST\@ |
| 1823 |
\@TMP_RPM_REQUIRES_EXCLUDE_FROM\@ |
| 1824 |
\@CPACK_RPM_SPEC_MORE_DEFINE\@ |
| 1825 |
\@CPACK_RPM_COMPRESSION_TYPE_TMP\@ |
| 1826 |
|
| 1827 |
%description |
| 1828 |
\@CPACK_RPM_PACKAGE_DESCRIPTION\@ |
| 1829 |
|
| 1830 |
# This is a shortcutted spec file generated by CMake RPM generator |
| 1831 |
# we skip _install step because CPack does that for us. |
| 1832 |
# We do only save CPack installed tree in _prepr |
| 1833 |
# and then restore it in build. |
| 1834 |
%prep |
| 1835 |
mv $RPM_BUILD_ROOT %_topdir/tmpBBroot |
| 1836 |
|
| 1837 |
%install |
| 1838 |
if [ -e $RPM_BUILD_ROOT ]; |
| 1839 |
then |
| 1840 |
rm -rf $RPM_BUILD_ROOT |
| 1841 |
fi |
| 1842 |
mv %_topdir/tmpBBroot $RPM_BUILD_ROOT |
| 1843 |
|
| 1844 |
\@TMP_RPM_DEBUGINFO_INSTALL\@ |
| 1845 |
|
| 1846 |
%clean |
| 1847 |
|
| 1848 |
\@post_\@ |
| 1849 |
\@posttrans_\@ |
| 1850 |
\@postun_\@ |
| 1851 |
\@pre_\@ |
| 1852 |
\@pretrans_\@ |
| 1853 |
\@preun_\@ |
| 1854 |
|
| 1855 |
%files |
| 1856 |
%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@) |
| 1857 |
\@CPACK_RPM_INSTALL_FILES\@ |
| 1858 |
\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@ |
| 1859 |
\@CPACK_RPM_USER_INSTALL_FILES\@ |
| 1860 |
|
| 1861 |
%changelog |
| 1862 |
\@CPACK_RPM_SPEC_CHANGELOG\@ |
| 1863 |
|
| 1864 |
\@TMP_OTHER_COMPONENTS\@ |
| 1865 |
" |
| 1866 |
) |
| 1867 |
endif() |
| 1868 |
|
| 1869 |
# Stop here if we were asked to only generate a template USER spec file |
| 1870 |
# The generated file may then be used as a template by user who wants |
| 1871 |
# to customize their own spec file. |
| 1872 |
if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) |
| 1873 |
message(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file template is: ${CPACK_RPM_BINARY_SPECFILE}.in") |
| 1874 |
endif() |
| 1875 |
endif() |
| 1876 |
|
| 1877 |
# After that we may either use a user provided spec file |
| 1878 |
# or generate one using appropriate variables value. |
| 1879 |
if(CPACK_RPM_USER_BINARY_SPECFILE) |
| 1880 |
# User may have specified SPECFILE just use it |
| 1881 |
message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") |
| 1882 |
# The user provided file is processed for @var replacement |
| 1883 |
configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) |
| 1884 |
else() |
| 1885 |
# No User specified spec file, will use the generated spec file |
| 1886 |
message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") |
| 1887 |
# Note the just created file is processed for @var replacement |
| 1888 |
configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) |
| 1889 |
endif() |
| 1890 |
|
| 1891 |
if(NOT GENERATE_SPEC_PARTS) # generate package |
| 1892 |
# Now call rpmbuild using the SPECFILE |
| 1893 |
execute_process( |
| 1894 |
COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS} |
| 1895 |
--define "_topdir ${CPACK_RPM_DIRECTORY}" |
| 1896 |
--buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" |
| 1897 |
--target "${CPACK_RPM_PACKAGE_ARCHITECTURE}" |
| 1898 |
"${CPACK_RPM_BINARY_SPECFILE}" |
| 1899 |
WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" |
| 1900 |
RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT |
| 1901 |
ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err" |
| 1902 |
OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out") |
| 1903 |
if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) |
| 1904 |
file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR) |
| 1905 |
file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT) |
| 1906 |
message("CPackRPM:Debug: You may consult rpmbuild logs in: ") |
| 1907 |
message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err") |
| 1908 |
message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") |
| 1909 |
message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out") |
| 1910 |
message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***") |
| 1911 |
endif() |
| 1912 |
|
| 1913 |
# find generated rpm files and take their names |
| 1914 |
file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm" |
| 1915 |
"${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm") |
| 1916 |
|
| 1917 |
if(NOT GENERATED_FILES) |
| 1918 |
message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}") |
| 1919 |
endif() |
| 1920 |
|
| 1921 |
unset(expected_filenames_) |
| 1922 |
unset(filenames_) |
| 1923 |
if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") |
| 1924 |
list(APPEND expected_filenames_ |
| 1925 |
"${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm") |
| 1926 |
list(APPEND filenames_ "${CPACK_RPM_FILE_NAME}") |
| 1927 |
endif() |
| 1928 |
|
| 1929 |
if(CPACK_RPM_DEBUGINFO_PACKAGE) |
| 1930 |
cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_FILE_NAME" |
| 1931 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_FILE_NAME" |
| 1932 |
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_FILE_NAME" |
| 1933 |
"CPACK_RPM_DEBUGINFO_FILE_NAME") |
| 1934 |
|
| 1935 |
if(CPACK_RPM_DEBUGINFO_FILE_NAME AND |
| 1936 |
NOT CPACK_RPM_DEBUGINFO_FILE_NAME STREQUAL "RPM-DEFAULT") |
| 1937 |
list(APPEND expected_filenames_ |
| 1938 |
"${CPACK_RPM_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}.*\\.rpm") |
| 1939 |
string(REPLACE "@cpack_component@" "${CPACK_RPM_PACKAGE_COMPONENT}" |
| 1940 |
CPACK_RPM_DEBUGINFO_FILE_NAME "${CPACK_RPM_DEBUGINFO_FILE_NAME}") |
| 1941 |
list(APPEND filenames_ "${CPACK_RPM_DEBUGINFO_FILE_NAME}") |
| 1942 |
endif() |
| 1943 |
endif() |
| 1944 |
|
| 1945 |
# check if other files have to be renamed |
| 1946 |
file(GLOB rename_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.rpm_name") |
| 1947 |
if(rename_files_) |
| 1948 |
foreach(f_ IN LISTS rename_files_) |
| 1949 |
file(READ "${f_}" tmp_) |
| 1950 |
list(GET tmp_ 0 efn_) |
| 1951 |
list(APPEND expected_filenames_ "${efn_}") |
| 1952 |
list(GET tmp_ 1 fn_) |
| 1953 |
list(APPEND filenames_ "${fn_}") |
| 1954 |
endforeach() |
| 1955 |
endif() |
| 1956 |
|
| 1957 |
if(expected_filenames_) |
| 1958 |
foreach(F IN LISTS GENERATED_FILES) |
| 1959 |
unset(matched_) |
| 1960 |
foreach(expected_ IN LISTS expected_filenames_) |
| 1961 |
if(F MATCHES ".*/${expected_}") |
| 1962 |
list(FIND expected_filenames_ "${expected_}" idx_) |
| 1963 |
list(GET filenames_ ${idx_} filename_) |
| 1964 |
get_filename_component(FILE_PATH "${F}" DIRECTORY) |
| 1965 |
file(RENAME "${F}" "${FILE_PATH}/${filename_}") |
| 1966 |
list(APPEND new_files_list_ "${FILE_PATH}/${filename_}") |
| 1967 |
set(matched_ "YES") |
| 1968 |
|
| 1969 |
break() |
| 1970 |
endif() |
| 1971 |
endforeach() |
| 1972 |
|
| 1973 |
if(NOT matched_) |
| 1974 |
list(APPEND new_files_list_ "${F}") |
| 1975 |
endif() |
| 1976 |
endforeach() |
| 1977 |
|
| 1978 |
set(GENERATED_FILES "${new_files_list_}") |
| 1979 |
endif() |
| 1980 |
endif() |
| 1981 |
|
| 1982 |
set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE) |
| 1983 |
|
| 1984 |
if(CPACK_RPM_PACKAGE_DEBUG) |
| 1985 |
message("CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}") |
| 1986 |
endif() |
| 1987 |
endfunction() |
| 1988 |
|
| 1989 |
cpack_rpm_generate_package() |