Skip to content

Commit

Permalink
netdata: use builtin packaging service files
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
deribaucourt authored and kraj committed Oct 3, 2024
1 parent 5ac897f commit d801dfa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 67b9343e986ac6c9e3482bec938aa31deaab3ce7 Mon Sep 17 00:00:00 2001
From: Enguerrand de Ribaucourt <[email protected]>
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 <[email protected]>
---
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/[email protected])
@@ -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()

20 changes: 11 additions & 9 deletions meta-webserver/recipes-webadmin/netdata/netdata_1.47.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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() {
Expand All @@ -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

Expand All @@ -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}/[email protected]', '', d)} \
"

RDEPENDS:${PN} = "bash python3-core zlib"

0 comments on commit d801dfa

Please sign in to comment.