Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release-debian-22.04.0 into 22.04.x #323

Merged
merged 12 commits into from
Jul 21, 2022
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ Don't coredump if connection fail on process start

They are inserted in bulk now.

*sql*

The mysql socket is defined with:
* /var/run/mysqld/mysqld.sock on Debian and similar distribs
* /var/lib/mysql/mysql.sock on RH and similar distribs
* /tmp/mysql.sock on others

### Clib

#### Fixes
Expand Down
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,38 @@ set(ALLOW_DUPLICATE_EXECUTABLE TRUE)

set(BUILD_ARGS "-w" "dupbuild=warn")

#
# Get distributions name
#
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
file(STRINGS "/etc/os-release" release
REGEX "^ID")
foreach (l ${release})
if (${l} MATCHES "ID_LIKE=.*")
string(REGEX REPLACE "ID_LIKE=\"(.*)\"" "\\1" like ${l})
endif ()

if (${l} MATCHES "ID=.*")
string(REGEX REPLACE "ID=\"(.*)\"" "\\1" id ${l})
endif ()
endforeach ()
string(TOLOWER "${like}" like)
string(TOLOWER "${id}" id)

if (("${id}" MATCHES "debian") OR ("${like}" MATCHES "debian") OR ("${id}" MATCHES "ubuntu") OR ("${like}" MATCHES "ubuntu"))
set(OS_DISTRIBUTOR "Debian")
elseif (("${id}" MATCHES "centos") OR ("${like}" MATCHES "centos"))
set(OS_DISTRIBUTOR "CentOS")
else ()
message(WARNING "lsb_release in not installed")
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif ()
else ()
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif ()

message(STATUS "${id} detected (compatible with ${OS_DISTRIBUTOR})")

# set -latomic if OS is Raspbian.
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")
Expand Down
5 changes: 3 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
*/
env.PROJECT='centreon-collect'
def serie = '22.04'
def maintenanceBranch = "${serie}.x"
def qaBranch = "dev-${serie}.x"
def maintenanceBranch = "master"
def qaBranch = "develop"
def buildBranch = env.BRANCH_NAME
env.REF_BRANCH = '${serie}.x'
if (env.CHANGE_BRANCH) {
Expand All @@ -22,6 +22,7 @@ if (env.BRANCH_NAME.startsWith('release-')) {
env.REPO = 'testing'
} else if ((env.BRANCH_NAME == env.REF_BRANCH) || (env.BRANCH_NAME == maintenanceBranch)) {
env.BUILD = 'REFERENCE'
env.REPO = 'testing'
} else if ((env.BRANCH_NAME == 'develop') || (env.BRANCH_NAME == qaBranch)) {
env.BUILD = 'QA'
env.REPO = 'unstable'
Expand Down
32 changes: 12 additions & 20 deletions broker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ if (WITH_ASAN)
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
endif ()

# Default MySQL socket
if (OS_DISTRIBUTOR STREQUAL "Debian" OR OS_DISTRIBUTOR STREQUAL "Ubuntu")
message(STATUS "deb based os")
add_definitions("-DMYSQL_SOCKET=\"/var/run/mysqld/mysqld.sock\"")
elseif (OS_DISTRIBUTOR STREQUAL "CentOS" OR OS_DISTRIBUTOR STREQUAL "RedHat")
message(STATUS "rpm based os")
add_definitions("-DMYSQL_SOCKET=\"/var/lib/mysql/mysql.sock\"")
else ()
message(STATUS "other os: ${OS_DISTRIBUTOR}")
add_definitions("-DMYSQL_SOCKET=/tmp/mysql.sock")
endif ()

include_directories("${PROJECT_SOURCE_DIR}/core/inc")
include_directories("${PROJECT_SOURCE_DIR}/neb/inc")
include_directories("${CMAKE_SOURCE_DIR}/engine/inc")
Expand Down Expand Up @@ -126,26 +138,6 @@ include(cmake/tool.cmake)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
add_definitions("-DASIO_STANDALONE")

#
# Get distributions name
#
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Attempting to determine OS distributor.")
execute_process(COMMAND "lsb_release" "--short" "--id"
RESULT_VARIABLE RETCODE
OUTPUT_VARIABLE OS_DISTRIBUTOR
ERROR_QUIET)
if (RETCODE EQUAL 0)
string(REGEX REPLACE "\n$" "" OS_DISTRIBUTOR "${OS_DISTRIBUTOR}")
else ()
message(WARNING "lsb_release in not installed")
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif ()
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif ()


#
# Options.
#
Expand Down
2 changes: 1 addition & 1 deletion broker/core/src/database_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ database_config::database_config(config::endpoint const& cfg) {
if (it != end)
_socket = it->second;
else
_socket = "/var/lib/mysql/mysql.sock";
_socket = MYSQL_SOCKET;
} else
_socket = "";

Expand Down
2 changes: 2 additions & 0 deletions ci/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ override_dh_auto_build:
override_dh_auto_install:
cd build && \
make -j9 install DESTDIR=../debian/tmp-centreon-collect

override_dh_dwz:
16 changes: 0 additions & 16 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,6 @@ else ()
set(GROUP "root")
endif ()

# Check OS distributor.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Attempting to determine OS distributor.")
execute_process(COMMAND "lsb_release" "--short" "--id"
RESULT_VARIABLE RETCODE
OUTPUT_VARIABLE OS_DISTRIBUTOR
ERROR_QUIET)
if (RETCODE EQUAL 0)
string(REGEX REPLACE "\n$" "" OS_DISTRIBUTOR "${OS_DISTRIBUTOR}")
else ()
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif ()
elseif ()
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif ()

# Set startup script to auto if not define.
if (NOT WITH_STARTUP_SCRIPT)
set(WITH_STARTUP_SCRIPT "auto")
Expand Down