Skip to content

Commit

Permalink
Merge pull request #1713
Browse files Browse the repository at this point in the history
build: Fix debugsource RPM package generation
  • Loading branch information
BareosBot committed Mar 7, 2024
2 parents 48271b5 + 241f5e9 commit 36e38f9
Show file tree
Hide file tree
Showing 32 changed files with 253 additions and 72 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- core: fix various data races (connection_pool/heartbeat_thread) [PR #1685]
- filed: skip stripped top level directories [PR #1686]
- jcr: fix some compiler warnings [PR #1648]
- build: Fix debugsource RPM package generation [PR #1713]

### Removed
- plugins: remove old deprecated postgres plugin [PR #1606]
Expand Down Expand Up @@ -103,4 +104,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[PR #1695]: https://github.com/bareos/bareos/pull/1695
[PR #1696]: https://github.com/bareos/bareos/pull/1696
[PR #1708]: https://github.com/bareos/bareos/pull/1708
[PR #1713]: https://github.com/bareos/bareos/pull/1713
[unreleased]: https://github.com/bareos/bareos/tree/master
4 changes: 3 additions & 1 deletion CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2023 Bareos GmbH & Co. KG
# Copyright (C) 2019-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -128,6 +128,8 @@ if(BUILD_BAREOS_BINARIES)
)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
include(BareosCcache)
include(PrefixMap)
add_subdirectory(third-party EXCLUDE_FROM_ALL)
add_subdirectory(core)
if(ENABLE_WEBUI)
Expand Down
28 changes: 28 additions & 0 deletions cmake/BareosCcache.cmake
@@ -0,0 +1,28 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2024-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CCACHE_CMDLINE "${CCACHE_PROGRAM}")
list(APPEND CCACHE_CMDLINE "base_dir=${CMAKE_SOURCE_DIR}")
list(APPEND CCACHE_CMDLINE "hash_dir=true")
list(APPEND CCACHE_CMDLINE "namespace=bareos")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_CMDLINE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_CMDLINE}")
endif()
45 changes: 45 additions & 0 deletions cmake/DebugEdit.cmake
@@ -0,0 +1,45 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2024-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

find_program(DEBUGEDIT_PROG debugedit HINTS /usr/lib/rpm)

option(DEBUGEDIT_REWRITE
"Rewrite DW_AT_comp_dir in ELF objects to the real path" ON
)

if(DEBUGEDIT_REWRITE
AND DEBUGEDIT_PROG
AND NOT HAVE_WIN32
)
get_directory_property(directory_targets BUILDSYSTEM_TARGETS)
foreach(target ${directory_targets})
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL EXECUTABLE
OR target_type STREQUAL SHARED_LIBRARY
OR target_type STREQUAL MODULE_LIBRARY
)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${DEBUGEDIT_PROG} -b /usr/src/bareos -d ${CMAKE_SOURCE_DIR}
$<TARGET_FILE:${target}>
)
endif()
endforeach()
endif()
49 changes: 49 additions & 0 deletions cmake/PrefixMap.cmake
@@ -0,0 +1,49 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2024-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

set(BAREOS_PREFIX_MAP "${CMAKE_SOURCE_DIR}=/usr/src/bareos")

check_c_compiler_flag(
-fdebug-prefix-map=${BAREOS_PREFIX_MAP} c_compiler_debug_prefix_map
)
check_cxx_compiler_flag(
-fdebug-prefix-map=${BAREOS_PREFIX_MAP} cxx_compiler_debug_prefix_map
)
if(c_compiler_debug_prefix_map AND cxx_compiler_debug_prefix_map)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=${BAREOS_PREFIX_MAP}")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fdebug-prefix-map=${BAREOS_PREFIX_MAP}"
)
endif()

check_c_compiler_flag(
-fmacro-prefix-map=${BAREOS_PREFIX_MAP} c_compiler_macro_prefix_map
)
check_cxx_compiler_flag(
-fmacro-prefix-map=${BAREOS_PREFIX_MAP} cxx_compiler_macro_prefix_map
)
if(c_compiler_macro_prefix_map AND cxx_compiler_macro_prefix_map)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmacro-prefix-map=${BAREOS_PREFIX_MAP}")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fmacro-prefix-map=${BAREOS_PREFIX_MAP}"
)
endif()
48 changes: 1 addition & 47 deletions core/CMakeLists.txt
Expand Up @@ -36,12 +36,6 @@ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME common)
include(GNUInstallDirs)
include(BareosHelper)

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)

# switch on CXX 17 Support
#
set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -114,46 +108,6 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
endif()
endif()

option(DEBUG_PREFIX_MAP
"remap absolute debug paths to relative if compiler supports it" ON
)
check_c_compiler_flag(
-fdebug-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=. c_compiler_debug_prefix_map
)
check_cxx_compiler_flag(
-fdebug-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.
cxx_compiler_debug_prefix_map
)
if(DEBUG_PREFIX_MAP
AND c_compiler_debug_prefix_map
AND cxx_compiler_debug_prefix_map
)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fdebug-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=."
)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fdebug-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=."
)
endif()

check_c_compiler_flag(
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=. c_compiler_macro_prefix_map
)
check_cxx_compiler_flag(
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.
cxx_compiler_macro_prefix_map
)
if(c_compiler_macro_prefix_map)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=."
)
endif()
if(cxx_compiler_macro_prefix_map)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=."
)
endif()

check_cxx_compiler_flag(-Winvalid-offsetof compiler_has_invalid_offsetof)
if(compiler_has_invalid_offsetof)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
Expand Down Expand Up @@ -609,7 +563,7 @@ message(STATUS "CMAKE_SUPPRESS_REGENERATION: " ${CMAKE_SUPPRESS_REGENERATION})
# there are also two variables exactly for this purpose:

# wheter or not
message(STATUS "CCACHE_FOUND: " ${CCACHE_FOUND})
message(STATUS "CCACHE: " ${CCACHE_PROGRAM})

# Choose the type of build. Example: SET(CMAKE_BUILD_TYPE Debug)
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
Expand Down
3 changes: 1 addition & 2 deletions core/platforms/packaging/bareos.spec
Expand Up @@ -809,7 +809,7 @@ This package contains the tray monitor (QT based).
%prep
# this is a hack so we always build in "bareos" and not in "bareos-version"
%setup -c -n bareos
mv bareos-*/* .
[ -d bareos-* ] && mv bareos-*/* .
%if 0%{?contrib}
%replace_python_shebang contrib/misc/bsmc/bin/bsmc
%replace_python_shebang contrib/misc/triggerjob/bareos-triggerjob.py
Expand Down Expand Up @@ -867,7 +867,6 @@ cmake .. \
-DSYSCONF_INSTALL_DIR:PATH=/etc \
-DSHARE_INSTALL_PREFIX:PATH=/usr/share \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DDEBUG_PREFIX_MAP:BOOL=OFF \
-Dprefix=%{_prefix}\
-Dlibdir=%{library_dir} \
-Dsbindir=%{_sbindir} \
Expand Down
4 changes: 3 additions & 1 deletion core/src/benchmarks/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2021-2023 Bareos GmbH & Co. KG
# Copyright (C) 2021-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -65,3 +65,5 @@ bareos_add_benchmark(
)

bareos_add_benchmark(digest LINK_LIBRARIES bareos benchmark::benchmark_main)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/cats/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -69,3 +69,5 @@ install(
PATTERN *.in EXCLUDE
PATTERN *.sql EXCLUDE
)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/console/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -57,3 +57,5 @@ install(
bareos_install_single_config_file(\"${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf\" \"${configtemplatedir}\" \".\")
"
)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/dird/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -201,3 +201,5 @@ install(CODE "set(configtemplatedir \"${configtemplatedir}\")")
install(CODE "set(SRC_DIR \"${PROJECT_SOURCE_DIR}\")")

install(SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-dird-configfiles.cmake)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/droplet/libdroplet/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2020-2023 Bareos GmbH & Co. KG
# Copyright (C) 2020-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -118,3 +118,5 @@ target_include_directories(
target_link_libraries(
droplet ${LIBXML2_LIBRARIES} ${JSONC_LIBRARIES} ${OPENSSL_LIBRARIES}
)

include(DebugEdit)
2 changes: 2 additions & 0 deletions core/src/fastlz/CMakeLists.txt
Expand Up @@ -34,3 +34,5 @@ set_target_properties(
bareosfastlz PROPERTIES VERSION "${BAREOS_NUMERIC_VERSION}"
SOVERSION "${BAREOS_VERSION_MAJOR}"
)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/filed/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -113,3 +113,5 @@ install(CODE "set(SRC_DIR \"${PROJECT_SOURCE_DIR}\")" COMPONENT filedaemon)
install(SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-filed-configfiles.cmake
COMPONENT filedaemon
)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/findlib/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -67,3 +67,5 @@ endif()
if(NOT HAVE_WIN32 AND GTest_FOUND)
# add_subdirectory(unittests)
endif()

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/findlib/unittests/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2021 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -35,3 +35,5 @@ set_property(
)

add_dependencies(check test_findlib)

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/lib/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -193,3 +193,5 @@ if(HAVE_WIN32)
set_target_properties(bareos PROPERTIES DEFINE_SYMBOL "BUILDING_DLL")
target_link_libraries(bareos PUBLIC ws2_32)
endif()

include(DebugEdit)
2 changes: 2 additions & 0 deletions core/src/lmdb/CMakeLists.txt
Expand Up @@ -43,3 +43,5 @@ if(HAVE_WIN32)
endif()

install(TARGETS bareoslmdb DESTINATION ${libdir})

include(DebugEdit)
4 changes: 3 additions & 1 deletion core/src/ndmp/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -210,3 +210,5 @@ if(build_ndmjob)
add_executable(ndmjob ${NDMJOB_SRCS})
target_link_libraries(ndmjob bareosndmp)
endif()

include(DebugEdit)

0 comments on commit 36e38f9

Please sign in to comment.