Skip to content
This repository was archived by the owner on Jul 10, 2022. It is now read-only.

Add support for bionic #164

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Add support for bionic
Bartlomiej Sawicki committed Apr 24, 2019

Verified

This commit was signed with the committer’s verified signature.
tornqvist Carl Törnqvist
commit 4104407625a793f41b53a199cbd54ed32cdcfb0e
19 changes: 15 additions & 4 deletions lib/deb/s3/package.rb
Original file line number Diff line number Diff line change
@@ -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