From b4e138ffd742cede22c11a2c1126b6f8d23654a7 Mon Sep 17 00:00:00 2001 From: Aran Cox Date: Thu, 27 Oct 2022 14:26:50 -0500 Subject: [PATCH] add --cpan-package-reject-from-depends option to filter auto-depends The auto-depends for cpan modules worked well on rpm because of the use of capabilities (ie: perl(IO::Handle)) but deb packages of CPAN modules generate dependencies that might not exist because they are provided by another package and therefore need to be filtered out. For instance, perl(IO::Handle) would be turned into libio-handle-perl, and that package doesn't exist. The IO/Handle.pm file is actually in package perl-base. Prior to this patch, fpm would filter out a short list of modules (vars, warnings, strict, and Config) and with this patch you can add to that list with --cpan-package-reject-from-depends. --- docs/cli-reference.rst | 5 +++++ docs/packages/cli/cpan.rst | 2 ++ lib/fpm/package/cpan.rb | 7 +++++++ lib/fpm/package/deb.rb | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/cli-reference.rst b/docs/cli-reference.rst index 8ffaa312c2..6994447ff7 100644 --- a/docs/cli-reference.rst +++ b/docs/cli-reference.rst @@ -228,6 +228,9 @@ General Options * ``--cpan-package-name-postfix NAME_POSTFIX`` - (cpan only) Name to prefix the package name with. +* ``--cpan-package-reject-from-depends MODULE`` + - (cpan only) Filter modules from the generated depends. + * ``--[no-]cpan-test`` - (cpan only) Run the tests before packaging? @@ -668,6 +671,8 @@ cpan - Name to prefix the package name with. * ``--cpan-package-name-postfix NAME_POSTFIX`` - Name to prefix the package name with. +* ``--cpan-package-reject-from-depends MODULE`` + - (cpan only) Filter modules from the generated depends. * ``--cpan-perl-bin PERL_EXECUTABLE`` - The path to the perl executable you wish to run. * ``--cpan-perl-lib-path PERL_LIB_PATH`` diff --git a/docs/packages/cli/cpan.rst b/docs/packages/cli/cpan.rst index 202ae7f67e..ea75f39b2a 100644 --- a/docs/packages/cli/cpan.rst +++ b/docs/packages/cli/cpan.rst @@ -16,6 +16,8 @@ - Name to prefix the package name with. * ``--cpan-package-name-postfix NAME_POSTFIX`` - Name to prefix the package name with. +* ``--cpan-package-reject-from-depends MODULE`` + - Remove module from those generated with auto-depend. * ``--cpan-perl-bin PERL_EXECUTABLE`` - The path to the perl executable you wish to run. * ``--cpan-perl-lib-path PERL_LIB_PATH`` diff --git a/lib/fpm/package/cpan.rb b/lib/fpm/package/cpan.rb index d2ce4457c6..6b18710177 100644 --- a/lib/fpm/package/cpan.rb +++ b/lib/fpm/package/cpan.rb @@ -25,6 +25,13 @@ class FPM::Package::CPAN < FPM::Package option "--package-name-postfix", "NAME_POSTFIX", "Name to prefix the package name with.", :default => "" + option "--package-reject-from-depends", "MODULE", + "Filter modules matching MODULE from those generated by " \ + "the auto-depends for CPAN modules. This flag can be specified " \ + "multiple times. Use the perl module name, IE: URI::Escape.", + :multivalued => true, :attribute_name => :rejects, + :default => ['vars','warnings','strict','Config'] + option "--test", :flag, "Run the tests before packaging?", :default => true diff --git a/lib/fpm/package/deb.rb b/lib/fpm/package/deb.rb index 004e50b9f7..77b69e1ced 100644 --- a/lib/fpm/package/deb.rb +++ b/lib/fpm/package/deb.rb @@ -707,7 +707,9 @@ def converted_from(origin) end end - rejects = [ "perl(vars)", "perl(warnings)", "perl(strict)", "perl(Config)" ] + rejects = attributes[:rejects].map do |skip| + "perl(#{skip})" + end self.dependencies = self.dependencies.reject do |dep| # Reject non-module Perl dependencies like 'vars' and 'warnings' rejects.include?(dep)