diff mbox series

[meta-security,v2] systemd: fix empty file list with sed

Message ID 20250519145637.24305-1-mikko.rapeli@linaro.org
State New
Headers show
Series [meta-security,v2] systemd: fix empty file list with sed | expand

Commit Message

Mikko Rapeli May 19, 2025, 2:56 p.m. UTC
If measured-uki support is not enabled or build is continuing
from previous stages, then the matching file list can be empty.
Fixes build failure where sed says no input files.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 meta-tpm/recipes-core/systemd/systemd_%.bbappend | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

v2: fixed sed command to unquote FILES variable

v1: https://lists.yoctoproject.org/g/yocto-patches/message/1523
diff mbox series

Patch

diff --git a/meta-tpm/recipes-core/systemd/systemd_%.bbappend b/meta-tpm/recipes-core/systemd/systemd_%.bbappend
index 82b79ba..867c111 100644
--- a/meta-tpm/recipes-core/systemd/systemd_%.bbappend
+++ b/meta-tpm/recipes-core/systemd/systemd_%.bbappend
@@ -11,7 +11,10 @@  PACKAGECONFIG:append = " \
 # TODO: use swtpm-native to calculate TPM measurements
 do_install:append() {
     if "${@bb.utils.contains('DISTRO_FEATURES', 'tpm2', 'true', 'false', d)}"; then
-        sed -i -e "s/^ConditionSecurity=measured-uki/ConditionSecurity=tpm2/g" \
-            $( grep -rl ^ConditionSecurity=measured-uki ${D} )
+        FILES=$( grep -rl ^ConditionSecurity=measured-uki ${D} || true )
+        if [ "$FILES" != "" ]; then
+            sed -i -e "s/^ConditionSecurity=measured-uki/ConditionSecurity=tpm2/g" \
+                $FILES
+        fi
     fi
 }