base-files: fix sysctl config installation on systemd-based systems

Systemd-based systems do not use the global /etc/sysctl.conf file. Instead,
they read configuration from individual files under /etc/sysctl.d. This
change installs our sysctl settings as /etc/sysctl.d/console.conf when
systemd is enabled.

For systems that do not use systemd, the configuration file is still
installed at /etc/sysctl.conf. The CONFFILES entry is also updated.

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2025-07-03 10:27:26 +02:00
parent b581ac2a3b
commit 5c96ae3ecd
2 changed files with 8 additions and 4 deletions

View File

@ -1,3 +1,2 @@
# Console log-level
kernel.printk = 4 4 1 7

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013-2024, Digi International Inc.
# Copyright (C) 2013-2025, Digi International Inc.
FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"
@ -7,7 +7,12 @@ SRC_URI:append:dey = " \
"
do_install:append:dey() {
install -m 0644 ${WORKDIR}/sysctl.conf ${D}${sysconfdir}/
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${sysconfdir}/sysctl.d
install -m 0644 ${WORKDIR}/sysctl.conf ${D}${sysconfdir}/sysctl.d/console.conf
else
install -m 0644 ${WORKDIR}/sysctl.conf ${D}${sysconfdir}/
fi
}
pkg_postinst_ontarget:${PN}() {
@ -56,4 +61,4 @@ pkg_postinst_ontarget:${PN}() {
inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)}
CONFFILES:${PN}:dey += "${sysconfdir}/sysctl.conf"
CONFFILES:${PN}:dey += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', '${sysconfdir}/sysctl.conf', d)}"