diff mbox series

[V3] systemd: fix a dead link under /var/log

Message ID 20240207083337.2180157-1-changqing.li@windriver.com
State New
Headers show
Series [V3] systemd: fix a dead link under /var/log | expand

Commit Message

Changqing Li Feb. 7, 2024, 8:33 a.m. UTC
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

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

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 meta/recipes-core/systemd/systemd_255.1.bb | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Peter Kjellerstedt Feb. 9, 2024, 9:40 p.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Changqing Li
> Sent: den 7 februari 2024 09:34
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH V3] 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
> 
> Package this link into systemd-doc to fix above issue, meantime, set
> symlink according to log dir path
> 
> Signed-off-by: Changqing Li <changqing.li@windriver.com>
> ---
>  meta/recipes-core/systemd/systemd_255.1.bb | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/meta/recipes-core/systemd/systemd_255.1.bb b/meta/recipes-core/systemd/systemd_255.1.bb
> index 9e09c89355..eccc916af4 100644
> --- a/meta/recipes-core/systemd/systemd_255.1.bb
> +++ b/meta/recipes-core/systemd/systemd_255.1.bb
> @@ -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.

> +
> +    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.

>  }
> 
>  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"

> +
>  CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \
>  	${sysconfdir}/systemd/journald.conf \
>  	${sysconfdir}/systemd/logind.conf \
> --
> 2.25.1

//Peter
Changqing Li Feb. 18, 2024, 5:43 a.m. UTC | #2
On 2/10/24 05:40, Peter Kjellerstedt wrote:
> 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.
>
>> -----Original Message-----
>> From:openembedded-core@lists.openembedded.org  <openembedded-core@lists.openembedded.org>  On Behalf Of Changqing Li
>> Sent: den 7 februari 2024 09:34
>> To:openembedded-core@lists.openembedded.org
>> Subject: [OE-core] [PATCH V3] 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
>>
>> Package this link into systemd-doc to fix above issue, meantime, set
>> symlink according to log dir path
>>
>> Signed-off-by: Changqing Li<changqing.li@windriver.com>
>> ---
>>   meta/recipes-core/systemd/systemd_255.1.bb | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/meta/recipes-core/systemd/systemd_255.1.bb b/meta/recipes-core/systemd/systemd_255.1.bb
>> index 9e09c89355..eccc916af4 100644
>> --- a/meta/recipes-core/systemd/systemd_255.1.bb
>> +++ b/meta/recipes-core/systemd/systemd_255.1.bb
>> @@ -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.
>
>> +
>> +    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.

Hi,

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

Regards

Changqing

>
>>   }
>>
>>   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"
>
>> +
>>   CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \
>>        ${sysconfdir}/systemd/journald.conf \
>>        ${sysconfdir}/systemd/logind.conf \
>> --
>> 2.25.1
> //Peter
>
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd_255.1.bb b/meta/recipes-core/systemd/systemd_255.1.bb
index 9e09c89355..eccc916af4 100644
--- a/meta/recipes-core/systemd/systemd_255.1.bb
+++ b/meta/recipes-core/systemd/systemd_255.1.bb
@@ -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 \