1
0
mirror of https://github.com/jordansissel/fpm synced 2024-12-21 00:24:13 +01:00
fpm/templates/deb.erb
Jordan Sissel 541550a74d Allow versions in Provides field for Debian packages
This fixes #1788. This also reverts #280. For #280, at the time, this
change to ignore versions was correct. Two years after #280, Debian
began allowing `Provides` field to have versions.

This change also fixes bug in gem-to-deb conversion where previously an
incorrect Provides syntax would be generated (but thanks to #280,
removed), so this bug was only noticed after #280 was undone!

Computers are hard sometimes.

Added tests for gem-to-deb conversion specifically for the Provides
field.

Tested manually with Docker on Ubuntu 14.04 and 18.04 and results meet
expectations.

The history here is follows:
* In 2012, fpm was patched to remove version specifiers in Provides
  field because Debian didn't support it.
* In 2014, Debian dpkg[1] added support for versions in Provides field
* Somewhere between 2015-2018, Debian and Ubuntu included this new
  version of dpkg.
* Debian packaging policy docs (v4.4.0) was updated to allow versions
  in the Provides field.

Expected impacts:
* Older versions of dpkg/etc should _ignore_ the presence of a version
  specifier. Testing on Ubuntu 14.04 confirmed this.
* Newer versions of dpkg/etc should respect the presence of a version
  specifier. Testing on Ubuntu 18.04 confirmed this.

[1] https://launchpad.net/debian/+source/dpkg/1.17.11
2021-07-06 14:25:06 -07:00

53 lines
2.3 KiB
Plaintext

Package: <%= name %>
Version: <%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>
License: <%= license %>
<% if !vendor.nil? and !vendor.empty? -%>
Vendor: <%= vendor %>
<% end -%>
Architecture: <%= architecture %>
Maintainer: <%= maintainer %>
Installed-Size: <%= attributes[:deb_installed_size] %>
<% if !dependencies.empty? and !attributes[:no_depends?] -%>
Depends: <%= dependencies.collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if !conflicts.empty? -%>
Conflicts: <%= conflicts.collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if attributes[:deb_breaks] and !attributes[:deb_breaks].empty? -%>
Breaks: <%= attributes[:deb_breaks].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if attributes[:deb_pre_depends] and !attributes[:deb_pre_depends].empty? -%>
Pre-Depends: <%= attributes[:deb_pre_depends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if attributes[:deb_build_depends] and !attributes[:deb_build_depends].empty? -%>
Build-Depends: <%= attributes[:deb_build_depends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if !provides.empty? -%>
<%# Turn each provides from 'foo = 123' to simply 'foo' because Debian :\ -%>
<%# http://www.debian.org/doc/debian-policy/ch-relationships.html -%>
Provides: <%= provides.join ", " %>
<% end -%>
<% if !replaces.empty? -%>
Replaces: <%= replaces.collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if attributes[:deb_recommends] and !attributes[:deb_recommends].empty? -%>
Recommends: <%= attributes[:deb_recommends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
<% if attributes[:deb_suggests] and !attributes[:deb_suggests].empty? -%>
Suggests: <%= attributes[:deb_suggests].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
<% end -%>
Section: <%= category %>
Priority: <%= attributes[:deb_priority] %>
Homepage: <%= url or "http://nourlgiven.example.com/" %>
<% lines = (description or "no description given").split("\n") -%>
<% firstline, *remainder = lines -%>
Description: <%= firstline %>
<% if remainder.any? -%>
<%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
<% end -%>
<% if attributes[:deb_field_given?] -%>
<% attributes[:deb_field].each do |field, value| -%>
<%= field %>: <%= value %>
<% end -%>
<% end -%>