Skip to contentSkip to conversation

psplash: add systemd support

PATCH New Stefan Agner 1 participant 1 message Jan 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 psplash: add systemd support

From: Stefan Agner <[email protected]>

Make use of the recently added systemd support in psplash. The utility psplash-systemd communicates boot progress to the splash screen. The splash is disabled once systemd consideres the system fully booted (progress is at 1.0). Note that this can take a while if systemd is stuck on a failing unit.

This change adds two systemd services. One service starts psplash itself (psplash-start.service) and the second service starts the helper utility psplash-systemd (psplash-systemd.service). The units are written such that psplash-systemd.service can be used indepenendenly. This is useful when starting psplash in initramfs (not using systemd).

---
Note that this does *not* move to the very latest version of psplash. The latest changes from Yann Dirson change how the header files for the splash logo and progress bar are generated which needs more work on the recipe side.

In fact, we probably could get rid of most of the logic which generates the header files in the recipe and make use of the built-in functionality now. It also would somewhat brake the recipe "API" as we probably would allow to define header files directly through file:// anymore.

I currently do not plan to work on this.

--
Stefan

 meta/recipes-core/psplash/files/psplash-init  |  8 ++--
 .../psplash/files/psplash-start.service       | 10 +++++
 .../psplash/files/psplash-systemd.service     | 10 +++++
 meta/recipes-core/psplash/psplash_git.bb      | 38 +++++++++++--------
 4 files changed, 47 insertions(+), 19 deletions(-)
 create mode 100644 meta/recipes-core/psplash/files/psplash-start.service
 create mode 100644 meta/recipes-core/psplash/files/psplash-systemd.service
meta/recipes-core/psplash/files/psplash-init +4 -4
index 4bee866b0d..f58e043733 100755
@@ -23,10 +23,10 @@ for x in $CMDLINE; do
         esac
 done
 
-export TMPDIR=/mnt/.psplash
-[ -d $TMPDIR ] || mkdir -p $TMPDIR
-if ! mountpoint -q $TMPDIR; then
-	mount tmpfs -t tmpfs $TMPDIR -o,size=40k
+export PSPLASH_FIFO_DIR=/mnt/.psplash
+[ -d $PSPLASH_FIFO_DIR ] || mkdir -p $PSPLASH_FIFO_DIR
+if ! mountpoint -q $PSPLASH_FIFO_DIR; then
+	mount tmpfs -t tmpfs $PSPLASH_FIFO_DIR -o,size=40k
 fi
 
 rotation=0
meta/recipes-core/psplash/files/psplash-start.service new file +10 -0
new file mode 100644
index 0000000000..9de8f6321a
@@ -0,0 +1,10 @@
+[Unit]
+Description=Start psplash boot splash screen
+DefaultDependencies=no
+Requires=psplash-systemd.service
+
+[Service]
+ExecStart=/usr/bin/psplash
+
+[Install]
+WantedBy=sysinit.target
meta/recipes-core/psplash/files/psplash-systemd.service new file +10 -0
new file mode 100644
index 0000000000..e14f42032d
@@ -0,0 +1,10 @@
+[Unit]
+Description=Start psplash-systemd progress communication helper
+DefaultDependencies=no
+After=systemd-start.service
+
+[Service]
+ExecStart=/usr/bin/psplash-systemd
+
+[Install]
+WantedBy=sysinit.target
meta/recipes-core/psplash/psplash_git.bb +23 -15
index 56734c1582..6ff0393194 100644
@@ -3,14 +3,16 @@ DESCRIPTION = "PSplash is a userspace graphical boot splash screen for mainly em
 HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/psplash"
 SECTION = "base"
 LICENSE = "GPLv2+"
-LIC_FILES_CHKSUM = "file://psplash.h;beginline=1;endline=16;md5=840fb2356b10a85bed78dd09dc7745c6"
+LIC_FILES_CHKSUM = "file://psplash.h;beginline=1;endline=8;md5=8f232c1e95929eacab37f00900580224"
 
-SRCREV = "2015f7073e98dd9562db0936a254af5ef56356cf"
+SRCREV = "773a3977d255e8f59a741ad6ce37c4d40f1feaa1"
 PV = "0.1+git${SRCPV}"
 PR = "r15"
 
 SRC_URI = "git://git.yoctoproject.org/${BPN} \
            file://psplash-init \
+           file://psplash-start.service \
+           file://psplash-systemd.service \
            ${SPLASH_IMAGES}"
 UPSTREAM_CHECK_COMMITS = "1"
 
@@ -66,7 +68,11 @@ python __anonymous() {
 
 S = "${WORKDIR}/git"
 
-inherit autotools pkgconfig update-rc.d update-alternatives
+inherit autotools pkgconfig update-rc.d update-alternatives systemd
+
+PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
+
+PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
 
 ALTERNATIVE_PRIORITY = "100"
 ALTERNATIVE_LINK_NAME[psplash] = "${bindir}/psplash"
@@ -97,8 +103,17 @@ python do_compile () {
 }
 
 do_install_append() {
-	install -d ${D}${sysconfdir}/init.d/
-	install -m 0755 ${WORKDIR}/psplash-init ${D}${sysconfdir}/init.d/psplash.sh
+	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
+		install -d ${D}${sysconfdir}/init.d/
+		install -m 0755 ${WORKDIR}/psplash-init ${D}${sysconfdir}/init.d/psplash.sh
+	fi
+
+	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+		install -d ${D}${systemd_unitdir}/system
+		install -m 644 ${WORKDIR}/psplash-start.service ${D}/${systemd_unitdir}/system
+		install -m 644 ${WORKDIR}/psplash-systemd.service ${D}/${systemd_unitdir}/system
+	fi
+
 	install -d ${D}${bindir}
 	for i in ${SPLASH_INSTALL} ; do
 		install -m 0755 $i ${D}${bindir}/$i
@@ -106,15 +121,8 @@ do_install_append() {
 	rm -f ${D}${bindir}/psplash
 }
 
+SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
+SYSTEMD_SERVICE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'psplash-start.service psplash-systemd.service', '', d)}"
+
 INITSCRIPT_NAME = "psplash.sh"
 INITSCRIPT_PARAMS = "start 0 S . stop 20 0 1 6 ."
-
-PACKAGE_WRITE_DEPS_append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}"
-pkg_postinst_${PN} () {
-	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
-		if [ -n "$D" ]; then
-			OPTS="--root=$D"
-		fi
-		systemctl $OPTS mask psplash.service
-	fi
-}
Signature · 1 line
2.17.1