Skip to content

Commit

Permalink
Apply fix for Ubuntu Bionic packages
Browse files Browse the repository at this point in the history
Taken from krobertson#164
  • Loading branch information
enochcheung committed Aug 5, 2019
1 parent 5e6ac28 commit 245a5cc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/deb/s3/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,31 @@ def extract_control(package)
if system("which dpkg > /dev/null 2>&1")
`dpkg -f #{package}`
else
# use ar to determine control file name (control.ext)
package_files = `ar t #{package}`
control_file = package_files.split("\n").select do |file|
file.start_with?("control.")
end.first
if control_file === "control.tar.gz"
compression = "z"
else
compression = "J"
end

# ar fails to find the control.tar.gz tarball within the .deb
# on Mac OS. Try using ar to list the control file, if found,
# use ar to extract, otherwise attempt with tar which works on OS X.
extract_control_tarball_cmd = "ar p #{package} control.tar.gz"
extract_control_tarball_cmd = "ar p #{package} #{control_file}"

begin
safesystem("ar t #{package} control.tar.gz &> /dev/null")
safesystem("ar t #{package} #{control_file} &> /dev/null")
rescue SafeSystemError
warn "Failed to find control data in .deb with ar, trying tar."
extract_control_tarball_cmd = "tar zxf #{package} --to-stdout control.tar.gz"
extract_control_tarball_cmd = "tar #{compression}xf #{package} --to-stdout #{control_file}"
end

Dir.mktmpdir do |path|
safesystem("#{extract_control_tarball_cmd} | tar -zxf - -C #{path}")
safesystem("#{extract_control_tarball_cmd} | tar -#{compression}xf - -C #{path}")
File.read(File.join(path, "control"))
end
end
Expand Down

0 comments on commit 245a5cc

Please sign in to comment.