Skip to contentSkip to conversation

systemd.bbclass: enable all services specified in ${SYSTEMD_SERVICE}

PATCH Peter Kjellerstedt 2 participants 2 messages Oct 16, 2019

lore
Share & tools
lore
#0 lore raw
Quoted 30 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Mikko Rapeli
Sent: den 16 oktober 2019 14:32
To: [email protected]
Subject: [OE-core] [PATCH] systemd.bbclass: enable all services specified in ${SYSTEMD_SERVICE}

This has been the traditional way of enabling systemd services. It may conflict with presets feature, but other layers, image classes and recipes add services to be enabled using SYSTEMD_SERVICE variable also with read-only rootfs, e.g. IMAGE_FEATURES has stateless-rootfs and systemd_preset_all task is not executed.

Fixes startup of custom services from our recipes using custom image classes with various BSP layers. In the worst case even serial console getty service wasn't starting due to dependency no not enabled services.

---
 meta/classes/systemd.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/systemd.bbclass +0 -0
index 1dca099..ae03c6f 100644

meta/classes/systemd.bbclass if type systemctl >/dev/null 2>/dev/null; then · line 39

Quoted 8 lines
meta/classes/systemd.bbclass +1 -1
@@ -33,7 +33,7 @@ if type systemctl >/dev/null 2>/dev/null; then
 	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
 		for service in ${SYSTEMD_SERVICE_ESCAPED}; do
 			case "${service}" in
-			*@*)
+			*)
 				systemctl ${OPTS} enable "${service}"
 				;;
 			esac

Not much point in leaving the case statement if it only has a capture all case. I.e., the above simplifies to:

	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
		for service in ${SYSTEMD_SERVICE_ESCAPED}; do
			systemctl ${OPTS} enable "$service"

(also note the change of "${service}" to "$service" to avoid using ${...} for shell variables where not necessary as this causes them to unnecessarily end up in the bitbake hash for the function.)

//Peter

#1 lore raw
Quoted 42 lines · Peter Kjellerstedt
Quoted 30 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Mikko Rapeli
Sent: den 16 oktober 2019 14:32
To: [email protected]
Subject: [OE-core] [PATCH] systemd.bbclass: enable all services specified in ${SYSTEMD_SERVICE}

This has been the traditional way of enabling systemd services. It may conflict with presets feature, but other layers, image classes and recipes add services to be enabled using SYSTEMD_SERVICE variable also with read-only rootfs, e.g. IMAGE_FEATURES has stateless-rootfs and systemd_preset_all task is not executed.

Fixes startup of custom services from our recipes using custom image classes with various BSP layers. In the worst case even serial console getty service wasn't starting due to dependency no not enabled services.

---
 meta/classes/systemd.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/systemd.bbclass +0 -0
index 1dca099..ae03c6f 100644

meta/classes/systemd.bbclass if type systemctl >/dev/null 2>/dev/null; then · line 39

Quoted 8 lines
meta/classes/systemd.bbclass +1 -1
@@ -33,7 +33,7 @@ if type systemctl >/dev/null 2>/dev/null; then
 	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
 		for service in ${SYSTEMD_SERVICE_ESCAPED}; do
 			case "${service}" in
-			*@*)
+			*)
 				systemctl ${OPTS} enable "${service}"
 				;;
 			esac

Not much point in leaving the case statement if it only has a capture all case. I.e., the above simplifies to:

Quoted 7 lines
	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
		for service in ${SYSTEMD_SERVICE_ESCAPED}; do
			systemctl ${OPTS} enable "$service"

(also note the change of "${service}" to "$service" to avoid using ${...} for shell variables where not necessary as this causes them to unnecessarily end up in the bitbake hash for the function.)

Thanks, I'll send a v2.

-Mikko