MDEV-32686 Use Red Hat package notes in compilation

This tests the compile using a spec file. This spec
file is defined by environment variables.

If the spec file doesn't exist (SLES/OpenSUSE),
isn't supported (e.g. clang), or has incorrect environment
variables the linker flag won't be used.

Stripping output avoid gcc ICE bug
https://bugzilla.redhat.com/show_bug.cgi?id=2336272

Launcher used to make env variables show up in the
build step rather than just the configure step.
This commit is contained in:
Daniel Black 2024-12-18 15:25:10 +11:00
commit e55fe2c2e3

View file

@ -2,6 +2,8 @@ IF(RPM)
MESSAGE(STATUS "CPackRPM building with RPM configuration: ${RPM}") MESSAGE(STATUS "CPackRPM building with RPM configuration: ${RPM}")
INCLUDE(check_linker_flag)
SET(CPACK_GENERATOR "RPM") SET(CPACK_GENERATOR "RPM")
SET(CPACK_RPM_PACKAGE_DEBUG 1) SET(CPACK_RPM_PACKAGE_DEBUG 1)
SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
@ -52,6 +54,19 @@ SET(CPACK_PACKAGE_RELOCATABLE FALSE)
SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases") SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases")
SET(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_URL}) SET(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_URL})
# The spec file depends on environment variables
SET(ENV{RPM_PACKAGE_NAME} ${CPACK_RPM_PACKAGE_NAME})
EXECUTE_PROCESS(COMMAND rpm --eval ${CPACK_RPM_PACKAGE_RELEASE} OUTPUT_VARIABLE RPM_PACKAGE_RELEASE_EXPANDED)
STRING(STRIP "${RPM_PACKAGE_RELEASE_EXPANDED}" RPM_PACKAGE_RELEASE_EXPANDED)
SET(ENV{RPM_PACKAGE_RELEASE} ${RPM_PACKAGE_RELEASE_EXPANDED})
SET(ENV{RPM_ARCH} ${CMAKE_SYSTEM_PROCESSOR})
SET(ENV{RPM_PACKAGE_VERSION} ${SERVER_VERSION})
MY_CHECK_AND_SET_LINKER_FLAG("-specs=/usr/lib/rpm/redhat/redhat-package-notes")
IF(HAVE_LINK_FLAG__specs_/usr/lib/rpm/redhat/redhat_package_notes)
SET(CMAKE_CXX_LINKER_LAUNCHER "env;RPM_PACKAGE_NAME=$ENV{RPM_PACKAGE_NAME};RPM_ARCH=$ENV{RPM_ARCH};RPM_PACKAGE_VERSION=$ENV{RPM_PACKAGE_VERSION};RPM_PACKAGE_RELEASE=$ENV{RPM_PACKAGE_RELEASE}")
SET(CMAKE_C_LINKER_LAUNCHER ${CMAKE_CXX_LINKER_LAUNCHER})
ENDIF()
SET(CPACK_RPM_shared_PACKAGE_VENDOR "MariaDB Corporation Ab") SET(CPACK_RPM_shared_PACKAGE_VENDOR "MariaDB Corporation Ab")
SET(CPACK_RPM_shared_PACKAGE_LICENSE "LGPLv2.1") SET(CPACK_RPM_shared_PACKAGE_LICENSE "LGPLv2.1")