Skip to content

Commit

Permalink
When bzip2 is used for compression, use gzip on the control.tar.
Browse files Browse the repository at this point in the history
This fixes a bug where fpm would create an invalid debian package file.
When `--deb-compression bzip2` was used, fpm would create
'control.tar.bz2' file inside the debian package. Debian does not
support bzip2-compressed control files. Per the deb(5) manpage:

> The second required member is named control.tar. It is a tar archive containing the package control information, either not compressed (supported since dpkg 1.17.6), or compressed with gzip (with .gz extension) or xz (with .xz extension, supported since 1.17.6)

With this commit, when bzip2 is chosen for data compression, fpm will
use gzip compression on the control.tar file.
  • Loading branch information
tiandrey authored and jordansissel committed Nov 3, 2021
1 parent 60de482 commit 97dfed3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def output(output_path)
compression = "-z"
when "bzip2"
datatar = build_path("data.tar.bz2")
controltar = build_path("control.tar.bz2")
controltar = build_path("control.tar.gz")
compression = "-j"
when "xz"
datatar = build_path("data.tar.xz")
Expand Down Expand Up @@ -863,12 +863,9 @@ def write_control_tarball

# Tar up the staging_path into control.tar.{compression type}
case self.attributes[:deb_compression]
when "gz", nil
when "gz", "bzip2", nil
controltar = "control.tar.gz"
compression = "-z"
when "bzip2"
controltar = "control.tar.bz2"
compression = "-j"
when "xz"
controltar = "control.tar.xz"
compression = "-J"
Expand Down
11 changes: 9 additions & 2 deletions spec/fpm/package/deb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,16 @@ def dpkg_field(field)
deb.output(target)
end

it "should use #{suffix} for data and control files" do
control_suffix = case flag
when 'bzip2'
'gz'
else
suffix
end

it "should use #{suffix} for data file and #{control_suffix} for control file" do
list = `ar t #{target}`.split("\n")
insist { list }.include?("control.tar.#{suffix}")
insist { list }.include?("control.tar.#{control_suffix}")
insist { list }.include?("data.tar.#{suffix}")
end
end
Expand Down

0 comments on commit 97dfed3

Please sign in to comment.