Skip to content

Commit

Permalink
Merge pull request #2009 from SaltwaterC/main
Browse files Browse the repository at this point in the history
Add support for zstd compression for deb packages.
  • Loading branch information
jordansissel authored Dec 8, 2024
2 parents c028e71 + e0edc7e commit e66a359
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 16 additions & 3 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FPM::Package::Deb < FPM::Package
} unless defined?(SCRIPT_MAP)

# The list of supported compression types. Default is gz (gzip)
COMPRESSION_TYPES = [ "gz", "bzip2", "xz", "none" ]
COMPRESSION_TYPES = [ "gz", "bzip2", "xz", "zst", "none" ]

# https://www.debian.org/doc/debian-policy/ch-relationships.html#syntax-of-relationship-fields
# Example value with version relationship: libc6 (>= 2.2.1)
Expand Down Expand Up @@ -332,6 +332,9 @@ def extract_info(package)
when "xz"
controltar = "control.tar.xz"
compression = "-J"
when "zst"
controltar = "control.tar.zst"
compression = "-I zstd"
when 'tar'
controltar = "control.tar"
compression = ""
Expand All @@ -344,7 +347,7 @@ def extract_info(package)

build_path("control").tap do |path|
FileUtils.mkdir(path) if !File.directory?(path)
# unpack the control.tar.{,gz,bz2,xz} from the deb package into staging_path
# unpack the control.tar.{,gz,bz2,xz,zst} from the deb package into staging_path
# Unpack the control tarball
safesystem(ar_cmd[0] + " p #{package} #{controltar} | tar #{compression} -xf - -C #{path}")

Expand Down Expand Up @@ -454,6 +457,9 @@ def extract_files(package)
when "xz"
datatar = "data.tar.xz"
compression = "-J"
when "zst"
datatar = "data.tar.zst"
compression = "-I zstd"
when 'tar'
datatar = "data.tar"
compression = ""
Expand Down Expand Up @@ -662,6 +668,10 @@ def output(output_path)
datatar = build_path("data.tar.xz")
controltar = build_path("control.tar.xz")
compression_flags = ["-J"]
when "zst"
datatar = build_path("data.tar.zst")
controltar = build_path("control.tar.zst")
compression_flags = ["-I zstd"]
when "none"
datatar = build_path("data.tar")
controltar = build_path("control.tar")
Expand Down Expand Up @@ -733,7 +743,7 @@ def converted_from(origin)
else
# Also replace '::' in the perl module name with '-'
modulename = m["name"].gsub("::", "-")

# Fix any upper-casing or other naming concerns Debian has about packages
name = "#{attributes[:cpan_package_name_prefix]}-#{modulename}"

Expand Down Expand Up @@ -949,6 +959,9 @@ def write_control_tarball
when "xz"
controltar = "control.tar.xz"
compression_flags = ["-J"]
when "zst"
controltar = "control.tar.zst"
compression_flags = ["-I zstd"]
when "none"
controltar = "control.tar"
compression_flags = []
Expand Down
5 changes: 3 additions & 2 deletions spec/fpm/package/deb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def dpkg_field(field)

context "when run against lintian" do
before do
skip("Missing lintian program") unless have_lintian
skip("Missing lintian program") unless have_lintian
end

lintian_errors_to_ignore = [
Expand Down Expand Up @@ -535,7 +535,8 @@ def dpkg_field(field)
{
"bzip2" => "bz2",
"xz" => "xz",
"gz" => "gz"
"gz" => "gz",
"zst" => "zst"
}.each do |flag,suffix|
context "when --deb-compression is #{flag}" do
let(:target) { Stud::Temporary.pathname + ".deb" }
Expand Down

0 comments on commit e66a359

Please sign in to comment.