Skip to content

Commit

Permalink
add --cpan-package-reject-from-depends option to filter auto-depends
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Aran Cox committed Oct 27, 2022
1 parent 1564cd9 commit b4e138f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/cli-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down Expand Up @@ -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``
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/cli/cpan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
7 changes: 7 additions & 0 deletions lib/fpm/package/cpan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b4e138f

Please sign in to comment.