Message ID | 20240218054112.3637709-1-changqing.li@windriver.com |
---|---|
State | New |
Headers | show |
Series | [V4] systemd: fix a dead link under /var/log | expand |
> -----Original Message----- > From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Changqing Li > Sent: den 18 februari 2024 06:41 > To: openembedded-core@lists.openembedded.org > Subject: [OE-core] [PATCH V4] systemd: fix a dead link under /var/log > > From: Changqing Li <changqing.li@windriver.com> > > 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. > > Signed-off-by: Changqing Li <changqing.li@windriver.com> > --- > meta/recipes-core/systemd/systemd_255.1.bb | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/meta/recipes-core/systemd/systemd_255.1.bb b/meta/recipes- > core/systemd/systemd_255.1.bb > index 9e09c89355..db21b70718 100644 > --- a/meta/recipes-core/systemd/systemd_255.1.bb > +++ b/meta/recipes-core/systemd/systemd_255.1.bb > @@ -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 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; then Actually, 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; 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 Remove the touch, it is not needed. The echo below will create the file. > + 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.conf > + 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 \ > -- > 2.25.1 //Peter
diff --git a/meta/recipes-core/systemd/systemd_255.1.bb b/meta/recipes-core/systemd/systemd_255.1.bb index 9e09c89355..db21b70718 100644 --- a/meta/recipes-core/systemd/systemd_255.1.bb +++ b/meta/recipes-core/systemd/systemd_255.1.bb @@ -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 \