fluentbit: Mitigate init manager detection issues

Avoid following CMake failure which during do_configure stemming from
non-cross compile friendly condition check executed on a build host
which has /usr/share/upstart directory

  | CMake Error at src/CMakeLists.txt:550 (install):
  |   install DIRECTORY given unknown argument "/etc/fluent-bit/".

Also handle systemd init manager case more appropriately, so that it
works also when the build host does not have a /lib/systemd/system
directory.

Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Niko Mauno
2024-10-21 16:57:03 +00:00
committed by Khem Raj
parent 1f72f49027
commit 854cba9a25
3 changed files with 49 additions and 41 deletions
@@ -0,0 +1,41 @@
From c9969cc46e5e4d58db28c89b22bebe42d9f96962 Mon Sep 17 00:00:00 2001
From: Niko Mauno <niko.mauno@vaisala.com>
Date: Mon, 21 Oct 2024 16:02:46 +0000
Subject: [PATCH] CMakeLists.txt: Revise init manager deduction
The init manager deduction is not cross-compile friendly, so replace
the host specific condition checks with placeholders that can be
replaced in Yocto recipe.
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Upstream-Status: Inappropriate [configuration]
---
src/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 084f2c57d..f0f35f00b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -532,7 +532,7 @@ if(FLB_BINARY)
set(SYSTEMD_UNITDIR /lib/systemd/system)
endif()
- if(SYSTEMD_UNITDIR)
+ if(@INIT_MANAGER_IS_SYSTEMD@)
set(FLB_SYSTEMD_SCRIPT "${PROJECT_SOURCE_DIR}/init/${FLB_OUT_NAME}.service")
configure_file(
"${PROJECT_SOURCE_DIR}/init/systemd.in"
@@ -540,7 +540,7 @@ if(FLB_BINARY)
)
install(FILES ${FLB_SYSTEMD_SCRIPT} COMPONENT binary DESTINATION ${SYSTEMD_UNITDIR})
install(DIRECTORY DESTINATION ${FLB_INSTALL_CONFDIR} COMPONENT binary)
- elseif(IS_DIRECTORY /usr/share/upstart)
+ elseif(@INIT_MANAGER_IS_UPSTART@)
set(FLB_UPSTART_SCRIPT "${PROJECT_SOURCE_DIR}/init/${FLB_OUT_NAME}.conf")
configure_file(
"${PROJECT_SOURCE_DIR}/init/upstart.in"
--
2.39.2
@@ -1,40 +0,0 @@
From c3b891eeec691753fccdf8e0a4541dcba244ec6b Mon Sep 17 00:00:00 2001
From: Niko Mauno <niko.mauno@vaisala.com>
Date: Thu, 10 Oct 2024 11:06:07 +0300
Subject: [PATCH] Disable installing systemd service file
With this we avoid the the following BitBake error when using some
other init manager than SystemD:
ERROR: fluentbit-3.1.9-r0 do_package: QA Issue: fluentbit: Files/directories were installed but not shipped in any package:
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/fluent-bit.service
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
fluentbit: 4 installed and not shipped files. [installed-vs-shipped]
ERROR: fluentbit-3.1.9-r0 do_package: Fatal QA errors were found, failing task.
Upstream-Status: Inappropriate [hack]
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
---
src/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e24666484..c102806d0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -534,7 +534,7 @@ if(FLB_BINARY)
set(SYSTEMD_UNITDIR /lib/systemd/system)
endif()
- if(SYSTEMD_UNITDIR)
+ if(FALSE)
set(FLB_SYSTEMD_SCRIPT "${PROJECT_SOURCE_DIR}/init/${FLB_OUT_NAME}.service")
configure_file(
"${PROJECT_SOURCE_DIR}/init/systemd.in"
--
2.39.2
@@ -22,7 +22,7 @@ SRC_URI = "\
git://github.com/fluent/fluent-bit.git;branch=3.1;protocol=https \
file://0001-lib-Do-not-use-private-makefile-targets-in-CMakelist.patch \
file://0002-flb_info.h.in-Do-not-hardcode-compilation-directorie.patch \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0003-Disable-installing-systemd-service-file.patch', d)} \
file://0003-CMakeLists.txt-Revise-init-manager-deduction.patch \
"
SRC_URI:append:libc-musl = "\
file://0004-chunkio-Link-with-fts-library-with-musl.patch \
@@ -116,6 +116,13 @@ EXTRA_OECMAKE:append:riscv32 = " -DCMAKE_C_STANDARD_LIBRARIES=-latomic"
EXTRA_OECMAKE:append:riscv64 = " -DCMAKE_C_STANDARD_LIBRARIES=-latomic"
EXTRA_OECMAKE:append:x86 = " -DCMAKE_C_STANDARD_LIBRARIES=-latomic"
do_configure:prepend() {
sed -i \
-e 's#@INIT_MANAGER_IS_SYSTEMD@#'${@'TRUE' if d.getVar('INIT_MANAGER') == 'systemd' else 'FALSE'}'#' \
-e 's#@INIT_MANAGER_IS_UPSTART@#'${@'TRUE' if d.getVar('INIT_MANAGER') == 'upstart' else 'FALSE'}'#' \
${S}/src/CMakeLists.txt
}
# flex hardcodes the input file in #line directives leading to TMPDIR contamination of debug sources.
do_compile:append() {
find ${B} -name '*.c' -or -name '*.h' | xargs sed -i -e 's|${TMPDIR}|${TARGET_DBGSRC_DIR}/|g'