Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for zstd compression for deb packages. #2009

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -650,6 +656,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 @@ -721,7 +731,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 @@ -937,6 +947,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