[1/2] perl.req: Allow filtering the found requirements.

Message ID 20221228204136.391950-1-stefan.schantl@ipfire.org
State New
Headers
Series [1/2] perl.req: Allow filtering the found requirements. |

Commit Message

Stefan Schantl Dec. 28, 2022, 8:41 p.m. UTC
  The filter mechanism easy can be used by adding something like
the following example in the corresponding nm file.

export FILTER_PERL_REQUIRES = \
	Some::Module \
	Example:: \
	abc

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/scripts/perl.req | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Patch

diff --git a/src/scripts/perl.req b/src/scripts/perl.req
index 29bde1f2..5a5a54e1 100644
--- a/src/scripts/perl.req
+++ b/src/scripts/perl.req
@@ -20,6 +20,8 @@ 
 # then these are treated as additional names which are required by the
 # file and are printed as well.
 
+my @filter = split(/ /, $ENV{'FILTER_PERL_REQUIRES'});
+
 my $BUILDROOT = shift;
 
 # Check if BUILDROOT is set
@@ -45,6 +47,8 @@  foreach my $perlver (sort keys %perlreq) {
 }
 
 foreach my $module (sort keys %global_require) {
+	next if (&is_filtered($module));
+
 	if (length($global_require{$module}) == 0) {
 		print "perl($module)\n";
 
@@ -388,3 +392,11 @@  sub process_file {
 
 	return;
 }
+
+sub is_filtered($) {
+	my ($module) = @_;
+
+	foreach my $item (@filter) {
+		return 1 if (index($module, $item) != -1);
+	}
+}