From 8a0a22d74f9b2a937ad1c91ec5927dd6a43af1e1 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 12 Dec 2024 08:51:11 +1100 Subject: [PATCH 1/2] MDEV-32686: Debian: include ELF package notes Providing build information compiled into the executable provides the ability of core file handlers to access information on the distro and source package version. This information can sometime be lost between the source and an upstream bug report. The Debian dh-package-notes includes the makefile included in debian/rules that sets linking flags to the right values. Add a small bit of safety that if the makefile isn't installed build anyway. ref: https://systemd.io/ELF_PACKAGE_METADATA/ --- debian/autobake-deb.sh | 12 ++++++++++++ debian/control | 1 + debian/rules | 3 +++ 3 files changed, 16 insertions(+) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 0a4a14624b5ce..85aa7f443a220 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -77,6 +77,12 @@ disable_libfmt() sed '/libfmt-dev/d' -i debian/control } +remove_package_notes() +{ + # binutils >=2.39 + disto makefile /usr/share/debhelper/dh_package_notes/package-notes.mk + sed -e '/package.notes/d' -i debian/rules debian/control +} + architecture=$(dpkg-architecture -q DEB_BUILD_ARCH) uname_machine=$(uname -m) @@ -114,6 +120,7 @@ in ;& "bullseye") add_lsb_base_depends + remove_package_notes ;& "bookworm") # mariadb-plugin-rocksdb in control is 4 arches covered by the distro rocksdb-tools @@ -131,6 +138,7 @@ in "focal") replace_uring_with_aio disable_libfmt + remove_package_notes ;& "jammy"|"kinetic") add_lsb_base_depends @@ -155,6 +163,10 @@ in exit 1 esac +if [ ! -f /usr/share/debhelper/dh_package_notes/package-notes.mk ]; then + remove_package_notes +fi + if [ -n "${AUTOBAKE_PREP_CONTROL_RULES_ONLY:-}" ] then exit 0 diff --git a/debian/control b/debian/control index 2a64b824f3632..9b2f8a0dbbbf0 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,7 @@ Build-Depends: bison, cracklib-runtime , debhelper (>= 11), dh-exec, + dh-package-notes, flex [amd64], gdb , libaio-dev [linux-any], diff --git a/debian/rules b/debian/rules index f8f260f741f6f..11ec0251ae60a 100644 --- a/debian/rules +++ b/debian/rules @@ -7,6 +7,9 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all DPKG_EXPORT_BUILDFLAGS = 1 # Include all defaults, including buildflags.mk include /usr/share/dpkg/default.mk +# Include package notes in built executables +include /usr/share/debhelper/dh_package_notes/package-notes.mk + # CPPFLAGS are nor read by CMake, so copy them to CXXFLAGS # See why at https://cmake.org/Bug/view.php?id=12928 # This is needed for e.g. all automatic Debian hardening flags to apply on all cmake builds. From 9651d5dbbd9eb3d1c7addafc72e97c7004486c04 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 18 Dec 2024 15:25:10 +1100 Subject: [PATCH 2/2] 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. --- cmake/cpack_rpm.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 5e8966ec7bbb3..1e09dee5806d5 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -2,6 +2,8 @@ IF(RPM) MESSAGE(STATUS "CPackRPM building with RPM configuration: ${RPM}") +INCLUDE(check_linker_flag) + SET(CPACK_GENERATOR "RPM") SET(CPACK_RPM_PACKAGE_DEBUG 1) SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -52,6 +54,14 @@ SET(CPACK_PACKAGE_RELOCATABLE FALSE) SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases") 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) +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") + SET(CPACK_RPM_shared_PACKAGE_VENDOR "MariaDB Corporation Ab") SET(CPACK_RPM_shared_PACKAGE_LICENSE "LGPLv2.1")