jordansissel / fpm

Effing package management! Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
http://fpm.readthedocs.io/en/latest/
Other
11.15k stars 1.07k forks source link

Provides line broken for Debian systems when building CPAN based packages. #1458

Open finncolman opened 6 years ago

finncolman commented 6 years ago

On a Debian based distribution, the inclusion of this feature within v1.91. and newer of fpm: https://github.com/jordansissel/fpm/pull/1340 has resulted in a provides like of the form: perl(Capture::Tiny) when building CPAN based packages. This results in a error when you try to apt-get install the Debian package as this is not a valid Provides line for a Debian package. Also setting the provides attribute simply appends another setting, so there is no way to override this either.

dpkg: warning: parsing file
`Provides' field, reference to `perl':

I've found that if I patch the cpan.rb like this:

# diff -u cpan.rb ~/cpan.rb
--- cpan.rb 2018-01-12 01:35:57.584181559 +0000
+++ /root/cpan.rb   2018-01-12 01:35:01.940287249 +0000
@@ -101,7 +101,7 @@
     unless metadata["module"].nil?
       metadata["module"].each do |m|
-        self.provides << cap_name(m["name"]) + " = #{self.version}"
+#        self.provides << cap_name(m["name"]) + " = #{self.version}"
       end
     end

then the produced package doesn't introduce the problematic Provides line

finncolman commented 6 years ago

This patch preserves the existing behaviour except for debian:

--- cpan.rb 2018-01-24 10:58:24.575510870 +1300
+++ cpan_new.rb 2018-01-19 08:09:23.000000000 +1300
@@ -385,16 +385,27 @@
   end # def metadata

   def cap_name(name)
-    return "perl(" + name.gsub("-", "::") + ")"
+    case attributes[:output_type]
+      when "deb"; deb_name(name)
+      else; return "perl(" + name.gsub("-", "::") + ")"
+    end
   end # def cap_name

   def fix_name(name)
     case name
       when "perl"; return "perl"
-      else; return [attributes[:cpan_package_name_prefix], name].join("-").gsub("::", "-")
+      else 
+        case attributes[:output_type]
+          when "deb"; deb_name(name)
+          else; return [attributes[:cpan_package_name_prefix], name].join("-").gsub("::", "-")
+        end
     end
   end # def fix_name

+  def deb_name(name)
+    return "lib" + name.gsub("::", "-").downcase + "-perl"
+  end # def deb_name
+
   def httpfetch(url)
     uri = URI.parse(url)
     if ENV['http_proxy']