Skip to content

Commit

Permalink
Fix --deb-compression none
Browse files Browse the repository at this point in the history
Previously, we would pass the literal `""` as an argument to `tar`.
`tar` would interpret this as a file name, which does not exist, and
fail.

This fixes the command to just pass no compression flag at all to tar
when `--deb-compression none` is set.

I did not add tests since I couldn't figure out how to execute them -
this is my first time working in ruby.
  • Loading branch information
howardjohn authored and jordansissel committed Mar 21, 2022
1 parent 92886d9 commit eb5370d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -613,25 +613,24 @@ def output(output_path)
when "gz", nil
datatar = build_path("data.tar.gz")
controltar = build_path("control.tar.gz")
compression = "-z"
compression_flags = ["-z"]
when "bzip2"
datatar = build_path("data.tar.bz2")
controltar = build_path("control.tar.gz")
compression = "-j"
compression_flags = ["-j"]
when "xz"
datatar = build_path("data.tar.xz")
controltar = build_path("control.tar.xz")
compression = "-J"
compression_flags = ["-J"]
when "none"
datatar = build_path("data.tar")
controltar = build_path("control.tar")
compression = ""
compression_flags = []
else
raise FPM::InvalidPackageConfiguration,
"Unknown compression type '#{self.attributes[:deb_compression]}'"
end

args = [ tar_cmd, "-C", staging_path, compression ] + data_tar_flags + [ "-cf", datatar, "." ]
args = [ tar_cmd, "-C", staging_path ] + compression_flags + data_tar_flags + [ "-cf", datatar, "." ]
if tar_cmd_supports_sort_names_and_set_mtime? and not attributes[:source_date_epoch].nil?
# Use gnu tar options to force deterministic file order and timestamp
args += ["--sort=name", ("--mtime=@%s" % attributes[:source_date_epoch])]
Expand Down Expand Up @@ -906,13 +905,13 @@ def write_control_tarball
case self.attributes[:deb_compression]
when "gz", "bzip2", nil
controltar = "control.tar.gz"
compression = "-z"
compression_flags = ["-z"]
when "xz"
controltar = "control.tar.xz"
compression = "-J"
compression_flags = ["-J"]
when "none"
controltar = "control.tar"
compression = ""
compression_flags = []
else
raise FPM::InvalidPackageConfiguration,
"Unknown compression type '#{self.attributes[:deb_compression]}'"
Expand All @@ -922,7 +921,7 @@ def write_control_tarball
build_path(controltar).tap do |controltar|
logger.info("Creating", :path => controltar, :from => control_path)

args = [ tar_cmd, "-C", control_path, compression, "-cf", controltar,
args = [ tar_cmd, "-C", control_path ] + compression_flags + [ "-cf", controltar,
"--owner=0", "--group=0", "--numeric-owner", "." ]
if tar_cmd_supports_sort_names_and_set_mtime? and not attributes[:source_date_epoch].nil?
# Force deterministic file order and timestamp
Expand Down

0 comments on commit eb5370d

Please sign in to comment.