Skip to content

Commit d4b986c

Browse files
aranc23Aran Coxjordansissel
authored
CPAN->deb related fixes (jordansissel#1947)
* fix comment at end of cpan class * make &perldepfix create correct dependencies for cpan->deb packages prior version created automatic dependencies for deb packages that weren't named according to the standard specified here: https://www.debian.org/doc/packaging-manuals/perl-policy/ch-module_packages.html * add --cpan-package-name-postfix and fix automatic names cpan pkgs use --cpan-package-name-prefix and --cpan-package-name-postfix to create the cpan package name do not assume a dash between the prefix and the package name change the defualt prefix from perl to perl- because for deb packages you want the prefix to be lib and do not want a - * 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. * update getting-started.rst to reflect cpan related changes * Revert "update getting-started.rst to reflect cpan related changes" This reverts commit ae1a628. * Revert "add --cpan-package-reject-from-depends option to filter auto-depends" This reverts commit b4e138f. * Revert "add --cpan-package-name-postfix and fix automatic names cpan pkgs" This reverts commit 1564cd9. * 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. * use Debian style names for CPAN modules --------- Co-authored-by: Aran Cox <aran-cox@uiowa.edu> Co-authored-by: Jordan Sissel <131818+jordansissel@users.noreply.github.com>
1 parent 088be70 commit d4b986c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/fpm/package/cpan.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class FPM::Package::CPAN < FPM::Package
2222
option "--package-name-prefix", "NAME_PREFIX",
2323
"Name to prefix the package name with.", :default => "perl"
2424

25+
option "--package-reject-from-depends", "MODULE",
26+
"Filter modules matching MODULE from those generated by " \
27+
"the auto-depends for CPAN modules. This flag can be specified " \
28+
"multiple times. Use the perl module name, IE: URI::Escape.",
29+
:multivalued => true, :attribute_name => :rejects,
30+
:default => ['vars','warnings','strict','Config']
31+
2532
option "--test", :flag,
2633
"Run the tests before packaging?", :default => true
2734

lib/fpm/package/deb.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,19 @@ def converted_from(origin)
787787
self.provides = self.provides.reject { |p| p.empty? }
788788

789789
if origin == FPM::Package::CPAN
790+
791+
# By default, we'd prefer to name Debian-targeted Perl packages using the
792+
# same naming scheme that Debian itself uses, which is usually something
793+
# like "lib<module-name-hyphenated>-perl", such as libregexp-common-perl
794+
#
795+
logger.info("Changing package name to match Debian's typical libmodule-name-perl style")
796+
self.name = "lib#{self.name.sub(/^perl-/, "")}-perl"
797+
790798
# The fpm cpan code presents dependencies and provides fields as perl(ModuleName)
791799
# so we'll need to convert them to something debian supports.
792800

793-
# Replace perl(ModuleName) > 1.0 with Debian-style perl-ModuleName (> 1.0)
801+
# Replace perl(Module::Name) > 1.0 with Debian-style libmodule-name-perl (> 1.0)
802+
# per: https://www.debian.org/doc/packaging-manuals/perl-policy/ch-module_packages.html
794803
perldepfix = lambda do |dep|
795804
m = dep.match(/perl\((?<name>[A-Za-z0-9_:]+)\)\s*(?<op>.*$)/)
796805
if m.nil?
@@ -801,7 +810,7 @@ def converted_from(origin)
801810
modulename = m["name"].gsub("::", "-")
802811

803812
# Fix any upper-casing or other naming concerns Debian has about packages
804-
name = "#{attributes[:cpan_package_name_prefix]}-#{modulename}"
813+
name = "lib#{modulename}-perl"
805814

806815
if m["op"].empty?
807816
name
@@ -812,7 +821,9 @@ def converted_from(origin)
812821
end
813822
end
814823

815-
rejects = [ "perl(vars)", "perl(warnings)", "perl(strict)", "perl(Config)" ]
824+
rejects = attributes[:rejects].map do |skip|
825+
"perl(#{skip})"
826+
end
816827
self.dependencies = self.dependencies.reject do |dep|
817828
# Reject non-module Perl dependencies like 'vars' and 'warnings'
818829
rejects.include?(dep)

0 commit comments

Comments
 (0)