Skip to contentSkip to conversation

systemd: fix a dead link under /var/log

PATCH Superseded [email protected] 2 participants 3 messages Feb 7, 2024 – Feb 18, 2024

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 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

Package this link into systemd-doc to fix above issue, meantime, set symlink according to log dir path

---
 meta/recipes-core/systemd/systemd_255.1.bb | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
meta/recipes-core/systemd/systemd_255.1.bb +14 -0
index 9e09c89355..eccc916af4 100644
@@ -386,6 +386,18 @@ do_install() {
         sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
             ${D}/${sysconfdir}/systemd/system.conf
     fi
+
+    if [ -f "${D}${prefix}/lib/tmpfiles.d/legacy.conf" ]; then
+        sed -i -e '/^L \/var\/log\/README/d' ${D}${prefix}/lib/tmpfiles.d/legacy.conf
+        
+        touch ${D}${prefix}/lib/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}${prefix}/lib/tmpfiles.d/legacy-doc.conf
+        else
+            echo "L /var/log/README - - - - ../../${datadir}/doc/systemd/README.logs" > ${D}${prefix}/lib/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:append = " ${prefix}/lib/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
#1 lore raw
Quoted 34 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Changqing Li
Sent: den 7 februari 2024 09:34
To: [email protected]
Subject: [OE-core] [PATCH V3] 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

Package this link into systemd-doc to fix above issue, meantime, set symlink according to log dir path

---
 meta/recipes-core/systemd/systemd_255.1.bb | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
meta/recipes-core/systemd/systemd_255.1.bb +0 -0
index 9e09c89355..eccc916af4 100644

meta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 388

Quoted 3 lines
meta/recipes-core/systemd/systemd_255.1.bb +0 -0
@@ -386,6 +386,18 @@ do_install() {
         sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
             ${D}/${sysconfdir}/systemd/system.conf
     fi

While here, please correct the indentation of the above if statement to use tabs like the rest of the do_install() function does.

meta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 400

Quoted 12 lines
meta/recipes-core/systemd/systemd_255.1.bb +12 -0
+
+    if [ -f "${D}${prefix}/lib/tmpfiles.d/legacy.conf" ]; then
+        sed -i -e '/^L \/var\/log\/README/d' ${D}${prefix}/lib/tmpfiles.d/legacy.conf
+
+        touch ${D}${prefix}/lib/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}${prefix}/lib/tmpfiles.d/legacy-doc.conf
+        else
+            echo "L /var/log/README - - - - ../../${datadir}/doc/systemd/README.logs" > ${D}${prefix}/lib/tmpfiles.d/legacy-doc.conf
+        fi
+
+    fi

The above solution is error prone as VOLATILE_LOG_DIR may have been redefined in a way that does not meet the expectations above. It is better to reuse what systemd's build system produced. You should also use ${nonarch_libdir} instead of ${prefix}/lib. Taken together:

	entry=$(grep '^L /var/log/README' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf 2>/dev/null)
	if [ "$entry" ]; then
		echo "$entry" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf
		sed -i -e '\%^L /var/log/README%d' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf
	fi

That way the link will only be setup via legacy-doc.conf if it was present in legacy.conf in the first place.

meta/recipes-core/systemd/systemd_255.1.bb FILES:${PN}-udev-rules = "\ · line 637

Quoted 8 lines
meta/recipes-core/systemd/systemd_255.1.bb +1 -0
 }
 
 python populate_packages:prepend (){
@@ -622,6 +634,8 @@ FILES:${PN}-udev-rules = "\
                         ${rootlibexecdir}/udev/rules.d/99-systemd.rules \
 "
 
+FILES:${PN}-doc:append = " ${prefix}/lib/tmpfiles.d/legacy-doc.conf"

There should be no need to use :append here:

FILES:${PN}-doc += "${nonarch_libdir}/tmpfiles.d/legacy-doc.conf"

Quoted 6 lines
meta/recipes-core/systemd/systemd_255.1.bb +1 -1
+
 CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \
 	${sysconfdir}/systemd/journald.conf \
 	${sysconfdir}/systemd/logind.conf \
--

2.25.1

//Peter

#2 lore raw
Quoted 61 lines · Peter Kjellerstedt

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 34 lines

-----Original Message-----
From:[email protected] <[email protected]> On Behalf Of Changqing Li
Sent: den 7 februari 2024 09:34
To:[email protected]
Subject: [OE-core] [PATCH V3] 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

Package this link into systemd-doc to fix above issue, meantime, set symlink according to log dir path

---
  meta/recipes-core/systemd/systemd_255.1.bb | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
meta/recipes-core/systemd/systemd_255.1.bb +0 -0
index 9e09c89355..eccc916af4 100644

meta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 388

Quoted 3 lines
meta/recipes-core/systemd/systemd_255.1.bb +0 -0
@@ -386,6 +386,18 @@ do_install() {
          sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
              ${D}/${sysconfdir}/systemd/system.conf
      fi

While here, please correct the indentation of the above if statement to use tabs like the rest of the do_install() function does.

meta/recipes-core/systemd/systemd_255.1.bb do_install() { · line 400

Quoted 13 lines
meta/recipes-core/systemd/systemd_255.1.bb +6 -0
+
+    if [ -f "${D}${prefix}/lib/tmpfiles.d/legacy.conf" ]; then
+        sed -i -e '/^L \/var\/log\/README/d' ${D}${prefix}/lib/tmpfiles.d/legacy.conf
+
+        touch ${D}${prefix}/lib/tmpfiles.d/legacy-doc.conf
+        if"${@'true' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 

'false'}"; then

meta/recipes-core/systemd/systemd_255.1.bb +6 -0
+            echo "L /var/log/README - - - - ../../../${datadir}/doc/systemd/README.logs" > ${D}${prefix}/lib/tmpfiles.d/legacy-doc.conf
+        else
+            echo "L /var/log/README - - - - ../../${datadir}/doc/systemd/README.logs" > ${D}${prefix}/lib/tmpfiles.d/legacy-doc.conf
+        fi
+
+    fi

The above solution is error prone as VOLATILE_LOG_DIR may have been redefined in a way that does not meet the expectations above. It is better to reuse what systemd's build system produced. You should also use ${nonarch_libdir} instead of ${prefix}/lib. Taken together:

Quoted 8 lines
         entry=$(grep '^L /var/log/README' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf 2>/dev/null)
         if [ "$entry" ]; then
                 echo "$entry" > ${D}${nonarch_libdir}/tmpfiles.d/legacy-doc.conf
                 sed -i -e '\%^L /var/log/README%d' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf
         fi

That way the link will only be setup via legacy-doc.conf if it was present in legacy.conf in the first place.

Hi,

Thanks, other comments fixed in V4,  and checking of VOLATILE_LOG_DIR is needed, please see commit message in V4.

Regards

Changqing

Quoted 21 lines

meta/recipes-core/systemd/systemd_255.1.bb FILES:${PN}-udev-rules = "\ · line 637

Quoted 9 lines
  }

  python populate_packages:prepend (){
meta/recipes-core/systemd/systemd_255.1.bb +1 -0
@@ -622,6 +634,8 @@ FILES:${PN}-udev-rules = "\
                          ${rootlibexecdir}/udev/rules.d/99-systemd.rules \
  "
 
+FILES:${PN}-doc:append = " ${prefix}/lib/tmpfiles.d/legacy-doc.conf"

There should be no need to use :append here:

FILES:${PN}-doc += "${nonarch_libdir}/tmpfiles.d/legacy-doc.conf"

Quoted 6 lines
meta/recipes-core/systemd/systemd_255.1.bb +1 -1
+
  CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \
       ${sysconfdir}/systemd/journald.conf \
       ${sysconfdir}/systemd/logind.conf \
--

2.25.1

//Peter