Skip to contentSkip to conversation

systemd: use if..then in prerm scriptlet

PATCH New Dan McGregor 1 participant 1 message Sep 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd: use if..then in prerm scriptlet

From: Daniel McGregor <[email protected]>

Using the [ test ] && foo construct in the prerm scriptlet causes the prerm scriptlet to fail if the final test condition fails, which with rpm prevents the removal of the package. Switch to using if;then;fi instead, since it doesn't cause the scriptlet to fail.

---
 meta/classes-recipe/systemd.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes-recipe/systemd.bbclass +2 -1
index 4e687135f13..5a0550b287b 100644
@@ -74,8 +74,9 @@ if type systemctl >/dev/null 2>/dev/null; then
 		fi
 
 		# same as above, --global flag is not supported for stop so do disable only
-		[ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}" ] && \
+		if [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}" ]; then
 			systemctl --global disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}
+		fi
 	fi
 fi
 }