From: Alban Bedel <alban.be...@aerq.com>

Per default systemd use a pager for the output of most of its tools
and it expect this pager to be color capable. But that is not the case
when the busybox `less` is used, which lead to output garbled by color
escape sequences.

To fix this issue add a profile frament that disable the systemd pager
when busybox `less` is detected.

Signed-off-by: Alban Bedel <alban.be...@aerq.com>
Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org>
(cherry picked from commit de7e36a7858ebca4615975967fcad1c399eacdb0)
Signed-off-by: Jermain Horsman <jermain.hors...@nedap.com>
Signed-off-by: Steve Sakoman <st...@sakoman.com>
---
 meta/recipes-core/systemd/systemd/systemd-pager.sh | 7 +++++++
 meta/recipes-core/systemd/systemd_244.5.bb         | 5 +++++
 2 files changed, 12 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/systemd-pager.sh

diff --git a/meta/recipes-core/systemd/systemd/systemd-pager.sh 
b/meta/recipes-core/systemd/systemd/systemd-pager.sh
new file mode 100644
index 0000000000..86e3e0ab78
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/systemd-pager.sh
@@ -0,0 +1,7 @@
+# Systemd expect a color capable pager, however the less provided
+# by busybox is not. This make many interaction with systemd pretty
+# annoying. As a workaround we disable the systemd pager if less
+# is not the GNU version.
+if ! less -V > /dev/null 2>&1 ; then
+       export SYSTEMD_PAGER=
+fi
diff --git a/meta/recipes-core/systemd/systemd_244.5.bb 
b/meta/recipes-core/systemd/systemd_244.5.bb
index 2bca1fbc82..98a580e2ea 100644
--- a/meta/recipes-core/systemd/systemd_244.5.bb
+++ b/meta/recipes-core/systemd/systemd_244.5.bb
@@ -18,6 +18,7 @@ SRC_URI += "file://touchscreen.rules \
            file://00-create-volatile.conf \
            file://init \
            file://99-default.preset \
+           file://systemd-pager.sh \
            
file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
            file://0003-implment-systemd-sysv-install-for-OE.patch \
            file://CVE-2021-33910.patch \
@@ -317,6 +318,9 @@ do_install() {
        # install default policy for presets
        # https://www.freedesktop.org/wiki/Software/systemd/Preset/#howto
        install -Dm 0644 ${WORKDIR}/99-default.preset 
${D}${systemd_unitdir}/system-preset/99-default.preset
+
+       # 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
 }
 
 python populate_packages_prepend (){
@@ -539,6 +543,7 @@ FILES_${PN} = " ${base_bindir}/* \
                 ${sysconfdir}/dbus-1/ \
                 ${sysconfdir}/modules-load.d/ \
                 ${sysconfdir}/pam.d/ \
+                ${sysconfdir}/profile.d/ \
                 ${sysconfdir}/sysctl.d/ \
                 ${sysconfdir}/systemd/ \
                 ${sysconfdir}/tmpfiles.d/ \
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#178878): 
https://lists.openembedded.org/g/openembedded-core/message/178878
Mute This Topic: https://lists.openembedded.org/mt/97755709/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to