Skip to content

Commit

Permalink
Applying original repos PR 158
Browse files Browse the repository at this point in the history
  • Loading branch information
braxton9460 committed Feb 24, 2020
1 parent 5e6ac28 commit 877bdb1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/deb/s3/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,22 @@ 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

# 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 zxf #{package} --to-stdout #{control_file}"
end

Dir.mktmpdir do |path|
Expand Down

0 comments on commit 877bdb1

Please sign in to comment.