[PATCH 1/2] perl: Add option to prevent COMPLEMENTARY_GLOB from ignoring perl-modules

William.Lyu
2024-01-16T16:56:25Z

From: William Lyu <William.Lyu@windriver.com>

When perl-modules is added via COMPLEMENTARY_GLOB, all perl-module-*
packages recommended by perl-modules are ignored due to the defined
behavior of COMPLEMENTARY_GLOB.

This patch creates a new package perl-modules-force-all that RDEPENDS on
the same set of packages perl-modules recommends. If another recipe
always needs the packages recommended by perl-modules, it can add
perl-modules-force-all to RDEPENDS to make sure that the recommended
packages by perl-modules are not ignored by COMPLEMENTARY_GLOB.

Signed-off-by: William Lyu <William.Lyu@windriver.com>
---
meta/recipes-devtools/perl/perl_5.38.2.bb | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/meta/recipes-devtools/perl/perl_5.38.2.bb b/meta/recipes-devtools/perl/perl_5.38.2.bb
index a9d684cfc5..f75c5aa971 100644
--- a/meta/recipes-devtools/perl/perl_5.38.2.bb
+++ b/meta/recipes-devtools/perl/perl_5.38.2.bb
@@ -311,6 +311,14 @@ ALTERNATIVE_LINK_NAME[Thread.3] = "${mandir}/man3/Thread.3"
ALLOW_EMPTY:${PN}-modules = "1"
PACKAGES += "${PN}-modules "

+# When perl-modules is added through COMPLEMENTARY_GLOB, as it is recommending
+# packages, all its recommendations will be ignored. So, we create a
+# perl-modules-force-all package depending on the same set of packages as listed
+# in perl-modules to provide a way to guarantee COMPLEMENTARY_GLOB not removing
+# these packages.
+ALLOW_EMPTY:${PN}-modules-force-all = "1"
+PACKAGES += "${PN}-modules-force-all "
+
PACKAGESPLITFUNCS =+ "split_perl_packages"

python split_perl_packages () {
@@ -328,6 +336,20 @@ python split_perl_packages () {
packages = filter(lambda p: 'perl-module-' in p, d.getVar('PACKAGES').split())
d.setVar(d.expand("RRECOMMENDS:${PN}-modules"), ' '.join(packages))

+ # perl-modules-force-all provides a way to prevent COMPLEMENTARY_GLOB
+ # from removing the packages specified in perl-modules.
+ # perl-modules-force-all contains the same set of packages as perl-modules.
+ d.setVar(
+ d.expand("RDEPENDS:${PN}-modules-force-all"),
+ d.getVar(d.expand("RRECOMMENDS:${PN}-modules"))
+ )
+
+ # As perl-modules-force-all depends on all other, potentially non-existent,
+ # perl packages, we allow these packages to be empty to prevent build
+ # errors.
+ for pkg in d.getVar(d.expand("RDEPENDS:${PN}-modules-force-all")).split():
+ d.setVar(d.expand("ALLOW_EMPTY:" + pkg), "1")
+
# Read the pre-generated dependency file, and use it to set module dependecies
for line in open(d.expand("${WORKDIR}") + '/perl-rdepends.txt').readlines():
splitline = line.split()
--
2.43.0