netdata: use builtin packaging service files

Netdata now provides its own systemd service files. They provide better
hardening than the one we were defining in the recipe.

Unfortunately, the CMakeLists.txt file wants to install them into /lib
rather than /usr/lib. I added mv commands to put them in the expected
location depending on usrmerge.

Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Enguerrand de Ribaucourt 2024-10-01 16:14:24 +02:00 committed by Khem Raj
parent 5ac897fae9
commit d801dfaa24
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 49 additions and 9 deletions

View File

@ -0,0 +1,38 @@
From 67b9343e986ac6c9e3482bec938aa31deaab3ce7 Mon Sep 17 00:00:00 2001
From: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Date: Tue, 1 Oct 2024 17:01:33 +0200
Subject: [PATCH] Do not hardcode systemd unit directories
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
---
CMakeLists.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 622bf88..ef3a771 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2533,7 +2533,7 @@ if(BUILD_FOR_PACKAGING)
install(FILES
${CMAKE_BINARY_DIR}/system/systemd/netdata.service
COMPONENT netdata
- DESTINATION lib/systemd/system)
+ DESTINATION $ENV{systemd_system_unitdir})
install(DIRECTORY
COMPONENT netdata
DESTINATION usr/lib/systemd/journald@netdata.conf.d)
@@ -2622,11 +2622,11 @@ if(NOT OS_WINDOWS)
install(FILES
${CMAKE_BINARY_DIR}/system/systemd/netdata-updater.service
COMPONENT netdata
- DESTINATION lib/systemd/system)
+ DESTINATION $ENV{systemd_system_unitdir})
install(FILES
system/systemd/netdata-updater.timer
COMPONENT netdata
- DESTINATION lib/systemd/system)
+ DESTINATION $ENV{systemd_system_unitdir})
endif()
endif()

View File

@ -7,13 +7,13 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=fc9b848046ef54b5eaee6071947abd24"
DEPENDS += "json-c libuv libyaml util-linux zlib lz4"
SRC_URI = "\
SRC_URI = " \
https://github.com/${BPN}/${BPN}/releases/download/v${PV}/${BPN}-v${PV}.tar.gz \
file://0001-cmake-Add-check-for-64bit-builtin-atomics.patch \
file://0002-Do-not-hardcode-systemd-unit-directories.patch \
file://netdata.conf \
file://netdata.service \
file://netdata-volatiles.conf \
"
"
SRC_URI[sha256sum] = "fb970a4b571ffd542b7d24220ef806a4c1b56c535e0f549a9978860a9f1dcc9c"
UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/tags"
@ -36,7 +36,8 @@ export LIBS
#systemd
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "netdata.service"
export SERVICE_FILES = "netdata.service netdata-updater.service netdata-updater.timer"
SYSTEMD_SERVICE:${PN} = "${SERVICE_FILES}"
SYSTEMD_AUTO_ENABLE:${PN} = "enable"
#User specific
@ -57,7 +58,7 @@ PACKAGECONFIG[systemd] = "-DENABLE_PLUGIN_SYSTEMD_JOURNAL=ON,-DENABLE_PLUGIN_SYS
PACKAGECONFIG[docker] = ",,virtual/docker,"
# ebpf doesn't compile (or detect) the cross compilation well
EXTRA_OECMAKE += "-DENABLE_PLUGIN_EBPF=OFF -DENABLE_PLUGIN_GO=OFF \
EXTRA_OECMAKE += "-DENABLE_PLUGIN_EBPF=OFF -DENABLE_PLUGIN_GO=OFF -DBUILD_FOR_PACKAGING=${@bb.utils.contains('DISTRO_FEATURES','systemd','ON','OFF',d)} \
-DENABLE_ACLK=OFF -DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=OFF -DCMAKE_INSTALL_PREFIX='${base_prefix}'"
do_install:append() {
@ -67,9 +68,6 @@ do_install:append() {
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
# Install systemd unit files
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${UNPACKDIR}/netdata.service ${D}${systemd_unitdir}/system
sed -i -e 's,@@datadir,${datadir_native},g' ${D}${systemd_unitdir}/system/netdata.service
install -Dm 0644 ${UNPACKDIR}/netdata-volatiles.conf ${D}${sysconfdir}/tmpfiles.d/netdata.conf
fi
@ -90,6 +88,10 @@ do_install:append() {
chown -R netdata:netdata ${D}${datadir}/netdata/web
}
FILES:${PN} += "${localstatedir}/cache/netdata/ ${localstatedir}/lib/netdata/"
FILES:${PN} += " \
${localstatedir}/cache/netdata/ \
${localstatedir}/lib/netdata/ \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_unitdir}/journald@netdata.conf.d', '', d)} \
"
RDEPENDS:${PN} = "bash python3-core zlib"