CPack/RPM prevent component attributes leakage

Fixes mantis bug report with id 15169. Some
component specific attributes were leaking
to next component. Leakage handling was
implemented in different locations but there
were still attributes that leaked. Patch
encapsulates generator into function so all
current leaks are fixed and no future leaks
can occur.
This commit is contained in:
Domen Vrankar 2015-03-16 22:17:17 +01:00
parent ffc1b94510
commit be089724e9

View File

@ -494,6 +494,7 @@ if(NOT UNIX)
message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
endif() endif()
function(cpack_rpm_generate_package)
# rpmbuild is the basic command for building RPM package # rpmbuild is the basic command for building RPM package
# it may be a simple (symbolic) link to rpm command. # it may be a simple (symbolic) link to rpm command.
find_program(RPMBUILD_EXECUTABLE rpmbuild) find_program(RPMBUILD_EXECUTABLE rpmbuild)
@ -576,14 +577,6 @@ set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACK
# CPACK_RPM_PACKAGE_SUMMARY (mandatory) # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
# CPACK_RPM_PACKAGE_SUMMARY_ is used only locally so that it can be unset each time before use otherwise
# component packaging could leak variable content between components
unset(CPACK_RPM_PACKAGE_SUMMARY_)
if(CPACK_RPM_PACKAGE_SUMMARY)
set(CPACK_RPM_PACKAGE_SUMMARY_ ${CPACK_RPM_PACKAGE_SUMMARY})
unset(CPACK_RPM_PACKAGE_SUMMARY)
endif()
#Check for component summary first. #Check for component summary first.
#If not set, it will use regular package summary logic. #If not set, it will use regular package summary logic.
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
@ -593,9 +586,7 @@ if(CPACK_RPM_PACKAGE_COMPONENT)
endif() endif()
if(NOT CPACK_RPM_PACKAGE_SUMMARY) if(NOT CPACK_RPM_PACKAGE_SUMMARY)
if(CPACK_RPM_PACKAGE_SUMMARY_) if(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_PACKAGE_SUMMARY_})
elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
else() else()
# if neither var is defined lets use the name as summary # if neither var is defined lets use the name as summary
@ -691,14 +682,6 @@ endif()
# - set to a default value # - set to a default value
# #
# CPACK_RPM_PACKAGE_DESCRIPTION_ is used only locally so that it can be unset each time before use otherwise
# component packaging could leak variable content between components
unset(CPACK_RPM_PACKAGE_DESCRIPTION_)
if(CPACK_RPM_PACKAGE_DESCRIPTION)
set(CPACK_RPM_PACKAGE_DESCRIPTION_ ${CPACK_RPM_PACKAGE_DESCRIPTION})
unset(CPACK_RPM_PACKAGE_DESCRIPTION)
endif()
#Check for a component description first. #Check for a component description first.
#If not set, it will use regular package description logic. #If not set, it will use regular package description logic.
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
@ -710,9 +693,7 @@ if(CPACK_RPM_PACKAGE_COMPONENT)
endif() endif()
if(NOT CPACK_RPM_PACKAGE_DESCRIPTION) if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
if(CPACK_RPM_PACKAGE_DESCRIPTION_) if(CPACK_PACKAGE_DESCRIPTION_FILE)
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION_})
elseif(CPACK_PACKAGE_DESCRIPTION_FILE)
file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION) file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
else () else ()
set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available") set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available")
@ -745,8 +726,6 @@ if(CPACK_PACKAGE_RELOCATABLE)
set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)
endif() endif()
if(CPACK_RPM_PACKAGE_RELOCATABLE) if(CPACK_RPM_PACKAGE_RELOCATABLE)
unset(TMP_RPM_PREFIXES)
if(CPACK_RPM_PACKAGE_DEBUG) if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: Trying to build a relocatable package") message("CPackRPM:Debug: Trying to build a relocatable package")
endif() endif()
@ -790,8 +769,6 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC
endif() endif()
endif() endif()
# Do not forget to unset previously set header (from previous component)
unset(TMP_RPM_${_RPM_SPEC_HEADER})
# Treat the RPM Spec keyword iff it has been properly defined # Treat the RPM Spec keyword iff it has been properly defined
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
# Transform NAME --> Name e.g. PROVIDES --> Provides # Transform NAME --> Name e.g. PROVIDES --> Provides
@ -1148,6 +1125,7 @@ else()
set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
endif() endif()
# Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir # Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir
# This is necessary to avoid duplicate files since rpmbuild do # This is necessary to avoid duplicate files since rpmbuild do
# recursion on its own when encountering a pathname which is a directory # recursion on its own when encountering a pathname which is a directory
@ -1319,15 +1297,6 @@ else()
message(FATAL_ERROR "RPM packaging through alien not done (yet)") message(FATAL_ERROR "RPM packaging through alien not done (yet)")
endif() endif()
endif() endif()
endfunction()
# reset variables from temporary variables cpack_rpm_generate_package()
if(CPACK_RPM_PACKAGE_SUMMARY_)
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_PACKAGE_SUMMARY_})
else()
unset(CPACK_RPM_PACKAGE_SUMMARY)
endif()
if(CPACK_RPM_PACKAGE_DESCRIPTION_)
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION_})
else()
unset(CPACK_RPM_PACKAGE_DESCRIPTION)
endif()