diff mbox series

systemd: use if..then in prerm scriptlet

Message ID 20250923190146.1788359-1-danismostlikely@gmail.com
State New
Headers show
Series systemd: use if..then in prerm scriptlet | expand

Commit Message

Dan McGregor Sept. 23, 2025, 7:01 p.m. UTC
From: Daniel McGregor <daniel.mcgregor@vecima.com>

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.

Signed-off-by: Daniel McGregor <daniel.mcgregor@vecima.com>
---
 meta/classes-recipe/systemd.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 4e687135f13..5a0550b287b 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -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
 }