[meta-selinux][PATCH] refpolicy_common: strip POLICY_CUSTOM_BUILDOPT before passing to make

Rohith Chiluka <[email protected]> Wed, 8 Jul 2026 07:47:35 +0000
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <SJ0PR02MB7821AE63AAB7FA8A268F99ADF1FF2@SJ0PR02MB7821.namprd02.prod.outlook.com>
  Please review the attached meta-selinux patch.

This fixes a refpolicy build failure when POLICY_CUSTOM_BUILDOPT is extended using :append from another layer. The appended value includes a leading space and the current refpolicy_common.inc passes it directly to make, causing the appended option to be interpreted as a make target.

Signed-off-by: Chiluka Rohith <[email protected]>
0059-refpolicy_common-strip-POLICY_CUSTOM_BUILDOPT-before.patch (application/octet-stream, 1.3 KB)
From e371d16abbe03a9cb102f6b5bd6b40b33c30557b Mon Sep 17 00:00:00 2001
From: Chiluka Rohith <[email protected]>
Date: Tue, 7 Jul 2026 15:42:13 +0530
Subject: [meta-selinux][PATCH] refpolicy_common: strip POLICY_CUSTOM_BUILDOPT
 before passing to make

POLICY_CUSTOM_BUILDOPT is passed directly to the refpolicy make command
as CUSTOM_BUILDOPT. When layers use ':append' to extend this variable
(e.g. POLICY_CUSTOM_BUILDOPT:append:distro = " option"), BitBake
introduces a leading space. Passing that raw value to make causes:

  make: *** No rule to make target 'option'.  Stop.
---
 recipes-security/refpolicy/refpolicy_common.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/recipes-security/refpolicy/refpolicy_common.inc b/recipes-security/refpolicy/refpolicy_common.inc
index 014714c..1566591 100644
--- a/recipes-security/refpolicy/refpolicy_common.inc
+++ b/recipes-security/refpolicy/refpolicy_common.inc
@@ -126,7 +126,7 @@ EXTRA_OEMAKE = "NAME=${POLICY_NAME} \
     DIRECT_INITRC=${POLICY_DIRECT_INITRC} \
     SYSTEMD=${POLICY_SYSTEMD} \
     MONOLITHIC=${POLICY_MONOLITHIC} \
-    CUSTOM_BUILDOPT=${POLICY_CUSTOM_BUILDOPT} \
+    CUSTOM_BUILDOPT=${@d.getVar('POLICY_CUSTOM_BUILDOPT').strip()} \
     QUIET=${POLICY_QUIET} \
     MLS_SENS=${POLICY_MLS_SENS} \
     MLS_CATS=${POLICY_MLS_CATS} \
-- 
2.34.1