systemd: fix a dead link under /var/log
PATCH v4 1/1 systemd: fix a dead link under /var/log
From: Changqing Li <[email protected]>
Commit 6fe23ff31c0 changed README to a symlink to README.logs, and install README.logs under systemd doc dir.
But for OE, systemd doc dir is splited into package systemd-doc, when it is not installed on the target, there will be an dead link:
Eg:
root@intel-x86-64:/var/log# ls -l README lrwxrwxrwx 1 root root 39 Jun 20 08:57 README -> ../../usr/share/doc/systemd/README.logs root@intel-x86-64:/var/log# ls -l ../../usr/share/doc/systemd/README.logs ls: cannot access '../../usr/share/doc/systemd/README.logs': No such file or directory
First, package this link into systemd-doc to fix above issue. Second, create the symlink according to the value of VOLATILE_LOG_DIR, when VOLATILE_LOG_DIR is true, /var/log is a link to /var/volatile/log, so /var/log/README need link to ../../../usr/share/doc/systemd/README.logs, while VOLATILE_LOG_DIR is false, /var/log is a dir, so /var/log/README need link to ../../usr/share/doc/systemd/README.logs.
--- meta/recipes-core/systemd/systemd_255.1.bb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
meta/recipes-core/systemd/systemd_255.1.bb +18 -4
@@ -382,10 +382,22 @@ do_install() { # add a profile fragment to disable systemd pager with busybox less install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh - if [ -n "${WATCHDOG_TIMEOUT}" ]; then - sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \ - ${D}/${sysconfdir}/systemd/system.conf - fi + if [ -n "${WATCHDOG_TIMEOUT}" ]; then + sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \ + ${D}/${sysconfdir}/systemd/system.conf + fi + + if [ -f "${D}${nonarch_libdir}/tmpfiles.d/legacy.conf" ] \ + && grep -q '^L \/var\/log\/README' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf 2>/dev/null; then + + sed -i -e '/^L \/var\/log\/README/d' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf + touch ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf + if "${@'true' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'false'}"; then + echo "L /var/log/README - - - - ../../../${datadir}/doc/systemd/README.logs" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf + else + echo "L /var/log/README - - - - ../../${datadir}/doc/systemd/README.logs" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf + fi + fi } python populate_packages:prepend (){
@@ -622,6 +634,8 @@ FILES:${PN}-udev-rules = "\ ${rootlibexecdir}/udev/rules.d/99-systemd.rules \ " +FILES:${PN}-doc += "${nonarch_libdir}/tmpfiles.d/legacy-doc.conf" + CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \ ${sysconfdir}/systemd/journald.conf \ ${sysconfdir}/systemd/logind.conf \
Signature · 1 line
2.25.1
Quoted 42 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Changqing Li
Sent: den 18 februari 2024 06:41
To: [email protected]
Subject: [OE-core] [PATCH V4] systemd: fix a dead link under/var/logFrom: Changqing Li <[email protected]>
Commit
6fe23ff31c0changed README to a symlink to README.logs, and install README.logs under systemd doc dir.But for OE, systemd doc dir is splited into package systemd-doc, when it is not installed on the target, there will be an dead link:
Eg:root@intel-x86-64:/var/log# ls -l README lrwxrwxrwx 1 root root 39 Jun 20 08:57 README -> ../../usr/share/doc/systemd/README.logs root@intel-x86-64:/var/log# ls -l ../../usr/share/doc/systemd/README.logs ls: cannot access '../../usr/share/doc/systemd/README.logs': No such file or directoryFirst, package this link into systemd-doc to fix above issue. Second, create the symlink according to the value of
VOLATILE_LOG_DIR, whenVOLATILE_LOG_DIRis true,/var/logis a link to/var/volatile/log, so/var/log/READMEneed link to ../../../usr/share/doc/systemd/README.logs, whileVOLATILE_LOG_DIRis false,/var/logis a dir, so/var/log/READMEneed link to ../../usr/share/doc/systemd/README.logs.Signed-off-by Changqing Li <[email protected]>--- meta/recipes-core/systemd/systemd_255.1.bb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)meta/recipes- renamed from meta/recipes-core/systemd/systemd_255.1.bb +0
-0core/systemd/systemd_255.1.bb
index9e09c89355..db21b70718100644meta/recipes-core/systemd/systemd_255.1.bb +0
-1@@ -382,10 +382,22 @@ do_install() { # add a profile fragment to disable systemd pager with busybox less install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh - if [ -n "${WATCHDOG_TIMEOUT}" ]; then
meta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 391
Quoted 10 lines
meta/recipes-core/systemd/systemd_255.1.bb +7
-3- sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \ - ${D}/${sysconfdir}/systemd/system.conf - fi + if [ -n "${WATCHDOG_TIMEOUT}" ]; then + sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \ + ${D}/${sysconfdir}/systemd/system.conf + fi + + if [ -f "${D}${nonarch_libdir}/tmpfiles.d/legacy.conf" ] \ + && grep -q '^L \/var\/log\/README' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf 2>/dev/null; then
If you format the above like this instead, then the \ on the first line is not needed:
if [ -f "${D}${nonarch_libdir}/tmpfiles.d/legacy.conf" ] &&
grep -q '^L \/var\/log\/README' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf 2>/dev/null; thenActually, since you pass grep's stderr to /dev/null, you can skip the first test. This will work just as well even if the file does not exist:
if grep -q '^L \/var\/log\/README' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf 2>/dev/null; thenmeta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 394
Quoted 3 lines
meta/recipes-core/systemd/systemd_255.1.bb +3
-0+ + sed -i -e '/^L \/var\/log\/README/d' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf + touch ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf
Remove the touch, it is not needed. The echo below will create the file.
meta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 399
Quoted 5 lines
meta/recipes-core/systemd/systemd_255.1.bb +5
-0+ if "${@'true' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'false'}"; then + echo "L /var/log/README - - - - ../../../${datadir}/doc/systemd/README.logs" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf + else + echo "L /var/log/README - - - - ../../${datadir}/doc/systemd/README.logs" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf + fi
If the link information added to legacy.conf by systemd's build system isn't correct and we have set it ourselves, then we may as well create the link as an absolute link instead and thereby avoid the need to differentiate depending on the value of VOLATILE_LOG_DIR. Might as well correct /var/log to ${localstatedir}/log too:
echo "L ${localstatedir}/log/README - - - - ${datadir}/doc/systemd/README.logs" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.confQuoted 14 lines
meta/recipes-core/systemd/systemd_255.1.bb +3
-1+ fi } python populate_packages:prepend (){@@ -622,6 +634,8 @@ FILES:${PN}-udev-rules = "\ ${rootlibexecdir}/udev/rules.d/99-systemd.rules \ " +FILES:${PN}-doc += "${nonarch_libdir}/tmpfiles.d/legacy-doc.conf" + CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \ ${sysconfdir}/systemd/journald.conf \ ${sysconfdir}/systemd/logind.conf \ --
Quoted 1 line
2.25.1
//Peter